Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Don´t return value

Posted on 2010-11-28
5
Medium Priority
?
827 Views
Last Modified: 2012-05-10
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
Comment
Question by:digistarsystem
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:kotukunui
ID: 34227658
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
 

Author Comment

by:digistarsystem
ID: 34227789
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
 
LVL 3

Expert Comment

by:kotukunui
ID: 34227897
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
 

Accepted Solution

by:
digistarsystem earned 0 total points
ID: 34260668
Thank you Kutukuni, with the concept and your references, I can solve the problem.

Regards,
0
 

Author Closing Comment

by:digistarsystem
ID: 34289910
The sulotions suply, is part of the global solutions.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question