Using insert stored procedures


Author
Message
Randy Smith
Randy Smith
StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)
Group: Forum Members
Posts: 18, Visits: 193
Can anyone give me a sample of saving data with a stored procedure. I am trying to return the uniqueidentifier and I'm not sure exactly how to go about this.

Thanks in advance.

Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
So, your server assigns the new GUID for the new record? And the primary key is a GUID?



Then you'll want your stored procedure to look like this:



CREATE Procedure sp_MyTable_Insert ( @field_pk GUID OUTPUT, @field_1 INT, @field_2 INT)

AS

BEGIN

SELECT @field_pk = NEWID();

INSERT INTO MyTable (field_pk, field_1, field_2)

VALUES (@field_pk, @field_1, @field_2);

END   

GO



Don't forget to define the GUID as a OUTPUT. Then get the guid and insert it into the row as the pk, and it will be returned and retrieved into the business object by the output variable.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search