Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return data from =SQLExec()
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00065405
Message ID:
00065515
Vues:
43
>>>>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.
Believe it or not I usually start out by reading the book :) Must have missed something this time. I will go check it out and see if it helps. Thanks for the info.

George
Everything we see or seems
Is but a dream within a dream
- Edgar Allen Poe
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform