Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Don´t return value

Posted on 2010-11-28
5
Medium Priority
?
822 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

670 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