Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How Do I Create This Procedure?
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
01116731
Message ID:
01116765
Views:
26
Ok, I have the SP correct now.

Here's my code. SQL is returning 'Incorrect syntax near 'gen_new_id'.'
sSqlConnStr = "DRIVER=SQL Server;SERVER=dserver3;database=newmegadb;uid=sa;password="

iConnHandle = SQLSTRINGCONNECT(sSqlConnStr)

IF iConnHandle > 0

  nKey = 0
  nResult = SQLEXEC(iConnHandle, "gen_new_id ?@nKey")

  IF nResult < 0
    AERROR(aErrInfo)
    MESSAGEBOX(aErrInfo[2])
  ELSE
    ? nKey
  ENDIF

SQLDISCONNECT(iConnHandle)

ELSE
	? "Not connected"
ENDIF
>The OUTPUT clause is missing in the sample SP code and your SP call is not entirely correct
...
> @newID int OUTPUT
>...
>
>nKey = 0
>nResult = SQLEXEC(iConnHandle, "gen_new_id ?@nKey")
>
>
>
>>Thanks Sergey. Thats exactly what I need.
>>
>>I'm having trouble calling it from VFP:
>>
>>Heres the proc:
>>
>>CREATE PROCEDURE gen_new_id
>> @key_name	varchar(50),
>> @newID int
>>AS
>>
>>SET NOCOUNT ON
>>
>>UPDATE gen_new_id
>>SET
>> @newID = id_value = id_value + 1
>>WHERE
>> key_name = @key_name
>>
>>IF @@ERROR <> 0
>> RETURN 1
>>ELSE
>> RETURN 0
>>
>>
>>and my code. I don't think I'm doing this right.
>>
>>
>>sSqlConnStr = "DRIVER=SQL Server;SERVER=dserver3;database=newmegadb;uid=sa;password="
>>
>>iConnHandle = SQLSTRINGCONNECT(sSqlConnStr)
>>
>>IF iConnHandle > 0
>>
>>	cKey = "my_key"
>>
>>	nResult = SQLEXEC(iConnHandle, "get_new_id @cKey")
>>
>>	? nResult
>>
>>	SQLDISCONNECT(iConnHandle)
>>	
>>ELSE
>>	? "Not connected"
>>ENDIF
>>
>>
>>
>>
>>
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform