Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 829
  • Last Modified:

Don´t return value

Hi Sir, I try the same example, but I have problem with return value,does not return anything, I use or connect my PowerBuilder aplications to the SQL Server 2008, across ODBC Connections, do you have some suggestion?, I appreciate your help..!!!!
0
digistarsystem
Asked:
digistarsystem
  • 3
  • 2
1 Solution
 
kotukunuiCommented:
Are you using a Datawindow connected to the stored procedure or are you using embedded SQL in PowerScript?

If a datawindow, what value to you get returned by the retrieve() function call?

If inline SQL, what value is in sqlca.sqlcode when the stored procedure is called?

Post some example code of what you are doing and any detail about configuration that you think is relevant and I'll see if I can diagnose the issue.
0
 
digistarsystemAuthor Commented:
Hello Kotuunui, I use embedded SQL, the sqlca.sqlcode return a 0, but the SP don´t return anythins value, above I describe the SP and the script called a SP:

***********************
Stored Procedure
***********************


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[sp_getkeymax]
      @table_name nvarchar(500),@column_name nvarchar(500),@keymax nvarchar(500) OUTPUT
WITH EXECUTE AS CALLER
AS
BEGIN

  SET NOCOUNT ON;

  DECLARE @nombre_tabla nvarchar(500), @nombre_columna nvarchar(500),  
            @SQLString nvarchar(500),@SQLString_Incidente nvarchar(500),
            @Parametros nvarchar(500)

  SELECT @nombre_columna = @column_name
  SELECT @nombre_tabla = @table_name
 
  SET @SQLString = 'select @keymax = max('+@nombre_columna+') from '+@nombre_tabla
  SET @Parametros = N'@keymax int OUTPUT'
  EXEC sp_executesql @SQLString,@Parametros,@keymax = @keymax OUTPUT
  SET @SQLString = 'Update Bitacora_GetKeyMax Set nombre_tabla = '''+@nombre_tabla+''',nombre_columna = '''+@nombre_columna +''',valor_columna = '''+@keymax+''''

 SET @Parametros = N'@keymax int OUTPUT'
 EXEC sp_executesql @SQLString ,@Parametros,@keymax = @keymax OUTPUT

return @keymax
END

*********************
Calling a SP
*********************

string key_max

DECLARE  sp_getmaxkey_procedure PROCEDURE  FOR sp_getmaxkey  @table_name = "articulos",@colum_name = "codigo_articulo",@maxkey = key_max  USING sqlca;

EXECUTE sp_getmaxkey_procedure;

FETCH sp_getmaxkey_procedure INTO :key_max;

0
 
kotukunuiCommented:
I have read in other articles that PowerBuidler doesn't like OUTPUT paramters in embedded SQL in this format

Open the POwerBuilder Help and go to the section called "Dynamic SQL Format 4 SQL statement
" and look at the examples

Example 3  This example is for a stored procedure with a return value for a SQL Native Client (SNC) connection:

integer var1, ReturnVal

string var2

 

PREPARE SQLSA FROM  "execute @rc = myproc @parm1=?, @parm2=? OUTPUT ";

 

DESCRIBE SQLSA INTO SQLDA ;

 

DECLARE my_proc DYNAMIC PROCEDURE FOR SQLSA ;

 

SetDynamicParm(SQLDA, 1, var1)

SetDynamicParm(SQLDA, 2, var2)

 

EXECUTE DYNAMIC my_proc USING DESCRIPTOR SQLDA ;

 

//fetch result set

. . .

 

//fetch return value and output parameter

FETCH my_proc USING DESCRIPTOR SQLDA ;

 

//get return value

CHOOSE CASE SQLDA.OutParmType[1]

CASE TypeInteger!

   rc =  GetDynamicNumber(SQLDA, 1)

CASE TypeLong!

   rc =  GetDynamicNumber(SQLDA, 1)

CASE TypeString!

   Var2 = GetDynamicString(SQLDA, 1)

END CHOOSE

 

//get output value

 

CHOOSE CASE SQLDA.OutParmType[2]

CASE TypeString!

   Var2 = GetDynamicString(SQLDA, 2)

CASE TypeInteger!

   rc =  GetDynamicNumber(SQLDA, 2)

CASE TypeLong!

   rc =  GetDynamicNumber(SQLDA, 2)

END CHOOSE

 

CLOSE my_proc ;

You will probably need to use this format rather than the Format 1 as per your example. I read a PB bug list entry saying that this had been fixed but it appears not...
0
 
digistarsystemAuthor Commented:
Thank you Kutukuni, with the concept and your references, I can solve the problem.

Regards,
0
 
digistarsystemAuthor Commented:
The sulotions suply, is part of the global solutions.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now