TD and MS-SqlServer: How To Insert with Output parameter?

General discussion forum about all databases other than SqlBase.
sos

TD and MS-SqlServer: How To Insert with Output parameter?

Post by sos » 16 Feb 2011, 12:13

in .NET or TSQL no problem, but i cant get in Team Developer...

create Table Test (Field1 int, Field2 varchar(100)) -- Field1 is PK, but has no identity (1,1)!

i want to insert Data from TD Application, the mission is to receive the value for Field1
TSQL: runs ok
insert into Test (Field1) Output Inserted.Field1 select max(Field1)+1 from Test

TD: How can i get the value for Field1
insert into Test (Field1) Output Inserted.Field1 select max(Field1)+1 into :m from Test
sqlprepareandexecute -> returns syntax error in sql
sqlfetchnext

thank you
michael

UVS

Re: TD and MS-SqlServer: How To Insert with Output parameter?

Post by UVS » 16 Feb 2011, 18:48

I may be wrong but I don't think you can get output parameters this way from SQL using this method. I would suggest rolling it all into a store procedure and running it that way.

MartinD

sos

Re: TD and MS-SqlServer: How To Insert with Output parameter?

Post by sos » 17 Feb 2011, 13:38

Thank you Martin,
in .NET Code and TSQL it works fine, but i think there is no way in TD...

UVS

Re: TD and MS-SqlServer: How To Insert with Output parameter?

Post by UVS » 17 Feb 2011, 22:34

Well, there is a way to do this...
Use a stored procedure. Some DB folks say to always use stored procedures to handle inserts, edits and deletions. A stored procedure can return any infomation you want.

MartinD

Return to “General Discussion”

Who is online

Users browsing this forum: [Ahrefs], [Ccbot] and 2 guests