Hi Peter,
There're few problems with your VFP code. First, you've to check return value of VFP SPT functions. The negative value would indicate that there was an ODBC error. The AERROR() function can provide detailed information about it. Second, the output parameters should be passed to SQLEXEC by reference. Also, you don't need SQLPREPARE() function.
gnConnHandle = SQLCONNECT('qcm_Connect1')
IF gnConnHandle < 0
= AERROR(laOdbcError)
...
ENDIF
pcbabychgid = ""
lcSQLQry = [EXEC dbo.usp_create_char_key 'dbo.babychg', 'babychgid', 12, ?@pcbabychgid]
lnSptResult = SQLEXEC(gnConnHandle, lcSQLQry)
IF lnSptResult < 0
= AERROR(laOdbcError)
...
ENDIF
...
pnRetval = 0
pcbabychgid = ""
lcSQLQry = [{?@pnRetval=CALL dbo.usp_create_char_key('dbo.babychg', 'babychgid', 12, ?@pcbabychgid)}]
lnSptResult = SQLEXEC(gnConnHandle, lcSQLQry)
IF lnSptResult < 0
= AERROR(laOdbcError)
...
ENDIF
...
Next time please create new thread for your question.
<snip>
>It correctly returns the desired result to the calling proc in SQL which then uses that value for further processing. So I have attempted to translate this into VFP dialog based upon info in this thread as follows:
>
>*// VFP code used to emulate SQL proc call as above
> STORE SQLCONNECT('qcm_Connect1') TO gnConnHandle
>
> PRIVATE pcbabychgid
> pcbabychgid = ''
>
> lcSQLQry = "EXEC dbo.usp_create_char_key 'dbo.babychg', 'babychgid', 12, ?pcbabychgid OUTPUT"
> w = SQLPREPARE(gnConnHandle, lcSQLQry)
> y = SQLEXEC(gnConnHandle)
> x = pcbabychgid
>
>*// end of VFP code used to emulate SQL proc call as above
>
<snip>
>
>Since the above failed, based upon data in this thread I have now also tried the alternate approaches as below:
>Version a.
> lcSQLQry = [{?@pnRetval=CALL dbo.usp_create_char_key 'dbo.babychg', 'babychgid', 12, ?pcbabychgid OUTPUT}]
> w = SQLPREPARE(gnConnHandle, lcSQLQry)
> y = SQLEXEC(gnConnHandle)
> x = pcbabychgid
>
>Version b
> lnResult = SQLEXEC(gnConnHandle, [{?@pnRetval=CALL dbo.usp_create_char_key 'dbo.babychg', 'babychgid', 12, ?pcbabychgid OUTPUT}])
> x = pcbabychgid
>
>So far, none of these options has produced the desired result. Do you have any clues as to what I am doing wrong? Please advise. Thnx. /psb
--sb--