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:
00065635
Vues:
53
>>>>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
>>Ok, checked the docs. I was able to get the example to work but not mine (of course). I am including the stored procedure as well as the call I make to execute the sp in hopes that someone has an idea as to what I am doing wrong.
>>
>>Here is the stored procedure:
>>
>>CREATE PROCEDURE spgetmin
>>	@min_ret varchar(10) OUTPUT
>>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
>>SELECT @min_ret=@m_min
>>BEGIN TRANSACTION
>>	UPDATE mins SET m_assigned='Y' WHERE CURRENT OF gmin
>>IF @@ERROR <> 0
>>
>>	BEGIN
>>	ROLLBACK TRANSACTION
>>
>>	END
>>ELSE
>>	BEGIN
>>	COMMIT TRANSACTION
>>	END
>>
>>DEALLOCATE gmin
>>
>>
>>And here is the VFP code I use to execute the stored procedure. What I really want is the output parameter in VFP:
>>
>>
>>consql=SQLCONN('upsize')
>>=sqlsetprop(consql,'Asynchronous',.T.)
>>sputest=0
>>DO WHILE sputest=0
>>	sputest=SQLEXEC(consql,"use att_test;{call spgetmin (?@moutput)}")
>>ENDDO
>>IF sputest=-1
>>	lnCount=AERROR(laError)
>>	IF lnCount > 0
>>		lcErrorMsg=laError[2]
>>		nErrorNo=laError[1]
>>		nODBCErrorno=laError[5]
>>		cErrorMsg=lcErrorMsg+"["+LTRIM(STR(nErrorNo))+":"+LTRIM(STR(nODBCErrorno))+"]"
>>		=MESSAGEBOX(cErrorMsg+CHR(13)+'Update Error: Changes Rolled Back')
>>	ENDIF
>>ENDIF
>>=sqldisc(consql)
>>
>>
>>Any help would be GREATLY appreciated!
>>Thanks,
>>George
>
>Did you declare the variable moutput somewhere in your Fox code before you run the SQLEXEC? The variable has to exist before you use it in the SQLEXEC call.

Yes, the variable is declared just above the VFP code listed here, just forgot to include that. I have tried initializing it as an empty string and with a single char such as 'x'. I cannot get the darn thing to return a value. I have also tried convert the return variable on the SQL Server side to an integer (the return should actually be a 10 digit phone number) and initialize moutput value as 0. This is driving me insane!
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