1. Rick Domogalik
  2. PowerBuilder
  3. Monday, 22 July 2019 17:08 PM UTC

I am having some issues calling a stored procedure. I get an error that "the cursor is not open" when it tries to FETCH the output. The stored procedure simply returns the next record number off a stack and increments it up by 1.

I can get the procedure to execute with no errors, the error pops in the FETCH section.

String ls_recnum
ls_recnum = Space(100)

connect using sqlca;

DECLARE sproc_getevent PROCEDURE FOR dbo.sp_getevent 
    @result = :ls_recnum OUTPUT 
USING SQLCA;

EXECUTE sproc_getevent;
If sqlca.SQLCode < 0 Then
    MessageBox( "Error Calling proc - sp_getevent", sqlca.SQLErrText,    StopSign!)
    Return
End If

FETCH sproc_getevent INTO :ls_recnum;
If sqlca.SQLCode < 0 Then
    MessageBox( "Error Fetching proc - sp_getevent", sqlca.SQLErrText, StopSign!)
    Return
End If

CLOSE sproc_getevent;
MessageBox("RecNum", ls_recnum)

Any help would be appreciated.

Matthew Balent Accepted Answer Pending Moderation
  1. Monday, 22 July 2019 17:56 PM UTC
  2. PowerBuilder
  3. # 1

You need to OPEN the cursor prior to the FETCH.

OPEN sproc_getevent;

Prior to the Execute.

Comment
  1. Rick Domogalik
  2. Tuesday, 23 July 2019 13:17 PM UTC
Thanks for the help. I am now getting another weird error. In my script after adding the open.



Database C0038: SQLSTATE = 22005{Microsoft}{ODBC SQL Server Driver}Invalid character value for cast specification.



I have checked the argument for the stored procedure and have the right data type. It is Varchar(7) in the procedure and I have a string declared. I have seen several suggested fixes for this error, but none seem to fix the issue.

I have tried adding ;StripParmNames='Yes' and CallEscape='No' to the end of my connection string for the database.



If I remove the argument totally from the declare, it prompts me that it needs the @result parameter.



Any thoughts?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.