Need help with Service Stored Procedures (SSPs)
Author: tomas.johansson@abilita.fi (tomas.johansson)
Hi, I'm struggling with an external stored procedure I'm trying to call from Uniface. If I run the stored procedure directly within Uniface using the sql command like so: sql "exec STR_TEST '%%name.test',''","mss" I do get value back in $result. However if I try to access the same stored procedure using Service Stored Procedures instead, using the following code: activate "TUSTRUDOK2".STR_TEST(in, out) then I do not receive any value in the out variable. One important thing to note is that in the stored procedure I'm inserting data into a table. If I modify the stored procedure to only perform a select statement I do not have any problems getting value back in the out variable of my SSP. Also note that even though I do not receive a return value the insert statement is still performed correctly. I'm working against Microsoft SQL Server and I'm currenlty using Uniface MSS driver U4.0. Here is the procedure not working with SSP: [spoiler] CREATE PROCEDURE [STR_TEST] @name as varchar(50) AS BEGIN declare @returnid table (id uniqueidentifier) INSERT INTO tjtest( name ) output inserted.id into @returnid VALUES( @name ) select 'Hello ' + @name + '! ID: ' + CONVERT(VARCHAR(50), r.id) from @returnid r END GO [/spoiler] And here's a slightly simplified version which do work with SSP: [spoiler]CREATE PROCEDURE [STR_TEST] @name as varchar(50) AS BEGIN select 'Hello ' + @name + '! ID: ' + CONVERT(VARCHAR(50), NEWID()) END GO[/spoiler] For completeness here's my test table to where I'm inserting data: [spoiler] CREATE TABLE tjtest( [id] [uniqueidentifier] NULL, [name] [varchar](50) NULL ) GO ALTER TABLE [tjtest] ADD CONSTRAINT [DF_tjtest_id] DEFAULT (newsequentialid()) FOR [id] GO [/spoiler] So how can I configure the SSP to also return back the resulting value when I'm inserting data inside the stored procedure? And then to my second question, when calling a stored procedure that performs inserts I have to explicitly call commit in Uniface in order for the transaction to complete, is there a way to circumvent this and perform insert operations inside the stored procedure without Uniface interfering? Tomas

Knut



