Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How Do I Create This Procedure?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01116731
Message ID:
01116784
Vues:
35
UPDATE System_Keys
SET
 @NewID = id = id + 1
WHERE
 key_name = @key_name
>Ok, now it doesn't error. But it returns 0.00 on each run. The table is not
>being incremented.
>
>While we're at at, I could a reference for VFP developers on creating
>SQL SP's. Any ideas?
>
>
>
>
>
>>
nResult = SQLEXEC(iConnHandle, "EXEC sp_GenerateSystemId ?cKey, ?@nId")
>>
>>
>>>Ok, this just isn't working. It should be simple.
>>>
>>>Again, here's the SQL code. There are 2 params.
>>>
>>>
>>>CREATE PROCEDURE sp_GenerateSystemId
>>> @key_name varchar(50),
>>> @newID int OUTPUT
>>>AS
>>>
>>>SET NOCOUNT ON
>>>
>>>UPDATE System_Keys
>>>SET
>>> id = id + 1
>>>WHERE
>>> key_name = @key_name
>>>
>>>IF @@ERROR <> 0
>>> RETURN 0
>>>ELSE
>>> RETURN -1
>>>
>>>
>>>And here's my code:
>>>
>>>
>>>sSqlConnStr = "DRIVER=SQL Server;SERVER=dserver3;database=newmegadb;uid=sa;password="
>>>
>>>iConnHandle = SQLSTRINGCONNECT(sSqlConnStr)
>>>
>>>IF iConnHandle > 0
>>>
>>>	cKey = "key_name"
>>>	nId = 0
>>>	nResult = SQLEXEC(iConnHandle, "EXEC sp_GenerateSystemId ?@cKey, ?@nId")
>>>
>>>	IF nResult < 0
>>>		AERROR(aErrInfo)
>>>		MESSAGEBOX(aErrInfo[2],48)
>>>	ELSE
>>>		? nId
>>>	ENDIF
>>>
>>>	SQLDISCONNECT(iConnHandle)
>>>	
>>>ELSE
>>>	? "Not connected"
>>>ENDIF
>>>
>>>
>>>SQL is returning 'Formal parameter '@key_name' was defined as OUTPUT but the actual
>>>parameter not declared OUTPUT.'
>>>
>>>I don't see how 'key_name' was defined as output???
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform