Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return data from =SQLExec()
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00065405
Message ID:
00065511
Views:
42
>>>I am trying to write a stored procedure on SQL Server 6.5 that will be called from VFP 5 using SQLExec(). The procedure finds a value that I am looking for, puts it into a variable, updates the table to make that value unavailable to other users (marked as assigned), and returns the value to a VFP cursor.
>>>
>>>The procedure works fine execpt that the values from the SELECT statement are not returned to VFP. Any ideas about what I am doing wrong or what I need to do?
>>>
>>>I am trying to get the value for @min from the statement: SELECT * FROM mins WHERE m_min=@m_min.
>>>
>>>The code for the stored procedures is below:
>>>
>>>
>>>CREATE PROCEDURE spgetmin AS
>>>
>>>DECLARE @m_min varchar(10)
>>>DECLARE @m_assigned varchar(1)
>>>DECLARE @m_recvd_date datetime
>>>
>>>DECLARE gmin SCROLL CURSOR
>>>	FOR select * from mins where m_assigned='N' ORDER BY m_min
>>>	FOR UPDATE OF m_assigned
>>>OPEN gmin
>>>FETCH FIRST FROM gmin INTO @m_min, @m_assigned, @m_recvd_date
>>>BEGIN TRANSACTION
>>>	SELECT * FROM mins WHERE m_min=@m_min
>>>	UPDATE mins SET m_assigned='Y' WHERE CURRENT OF gmin
>>>IF @@ERROR <> 0
>>>	BEGIN
>>>	ROLLBACK TRANSACTION
>>>	END
>>>ELSE
>>>	BEGIN
>>>	COMMIT TRANSACTION
>>>	END
>>>
>>>DEALLOCATE gmin
>>>
>>
>>I think you need to add an output parameter to your CREATE PROCEDURE clause e.g.
>>
>>CREATE PROCEDURE spgetmin @minout varchar(10) OUTPUT AS ...
>>
>>Then assign the value of of @m_min to @minout like this:
>>
>>SELECT @minout = @m_min
>>
>>I think this is how it's done in SQLServer (it's been a while).
>>
>>HTH
>Thanks for the quick reply. I tried this while dorking around with it this afternoon. Your syntax is correct but I think the OUTPUT is for a calling stored procedure. While the way you mentioned works, I still get no outpu to VFP, darnit.
>
>Any other ideas?

Check out the Developer's Guide (I know, I know: read the book?) starting at the bottom of page 549. It gives an example of using input and output parameters with SQLEXEC.
"It is an important and popular fact that things are not always what they seem. For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much -- the wheel, New York, wars and so on -- whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man -- for precisely the same reasons." - Douglas Adams
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform