Jump to content
Kyle Miller

TFDUpdateSQL, Stored Procedure - Setting field value from output variable

Recommended Posts

Given:

1. Database is MSSQL

2. TFDQuery & an TFDUpdateSQL assigned as the update object.

3. TFDUpdateSQL.InsertSql executes a stored procedure to perform insert, which affects a number of tables.

4. TFDUpdateSQL.InsertSql stored procedure returns an ID field value, which is the key field in TFDQuery. Ex: UserId.

5. UserId is an AutoInc TField in the TFDQuery.

 

What is the proper way to push the value returned by the stored procedure into the AutoInc field on an inserted record? Previous methods I used are not working.

 

Here is some code that does NOT work:

declare @SysUserId int;
exec dbo.SysUserUpdate @SysUserID = @SysUserID output, @UserName = :UserName, @Password=:Password,
     @FullName = :FullName, @EmailAddress = :EmailAddress, @CompanyLocationId = :CompanyLocationId,
     @IsActive = :IsActive,
     @SysApplicationKey = :SysApplicationKey, @ModuleAccess1 = :ModuleAccess1, @ModuleAccess2 = :ModuleAccess2,
     @PolicyAccess1 = :PolicyAccess1, @PolicyAccess2 = :PolicyAccess2

select :SysUserId=@SysUserId

 

Share this post


Link to post

Thanks for the reply. I changed the Select as you have. No dice. The autoinc field still says -1 after InsertSql runs.

 

Any properties on the TFDAutoIncField or TFDQuery to check?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×