IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Stored Procedure Returning Incorrect value


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 03, 2010 4:03 pm
Reply with quote

removed "EXTERNAL NAME PBP00010 " also ?
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Wed Nov 03, 2010 4:24 pm
Reply with quote

Yes GuyC , both FENCED and EXTERNAL are removed.

Below is my SP procedure:


Code:

CREATE PROCEDURE BP.PBP00024 (INOUT V_ACT_ID char(09))                     
--  FENCED                                                                 
    RESULT SETS 0                                                           
--  EXTERNAL NAME PBP00024                                                 
    LANGUAGE SQL                                                           
    MODIFIES SQL DATA                                                       
    COLLID CBP001BD                                                         
--  PARAMETER STYLE GENERAL                                                 
    NOT DETERMINISTIC                                                       
    ASUTIME NO LIMIT                                                       
    PROGRAM TYPE MAIN                                                       
    SECURITY DB2                                                           
    COMMIT ON RETURN NO                                                     
    STAY RESIDENT NO                                                       
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 03, 2010 5:03 pm
Reply with quote

this works on my side :
Code:
--drop PROCEDURE GUYCTEST                   ;
CREATE PROCEDURE GUYCTEST (INOUT V_ACT_ID char(9))                     
    RESULT SETS 0                                                           
    LANGUAGE SQL                                                           
    MODIFIES SQL DATA                                                       
    COLLID CBP001BD                                                         
    NOT DETERMINISTIC                                                       
    ASUTIME NO LIMIT                                                       
    PROGRAM TYPE MAIN                                                       
    SECURITY DB2                                                           
    COMMIT ON RETURN NO                                                     
    STAY RESIDENT NO     
   
    BEGIN                                                                           
                                                                               
    DECLARE v_base_n2      INTEGER;                                             

     SET v_base_n2    =  10;
     SET V_ACT_ID     =  char(v_base_n2);                                               
 --                                                                               
 --                                                                               
 END
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Wed Nov 03, 2010 5:07 pm
Reply with quote

It works for me when i run it standalone(we have AQT tool through which i can run the SP).

However , when i call it through COBOL program , it returns no value ..
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Wed Nov 03, 2010 5:07 pm
Reply with quote

Please let me know , how did u run it ?
through COBOL ?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 03, 2010 5:45 pm
Reply with quote

I don't do cobol anymore.
I'll try to get a cobol test pgm when I have the time.

At least now you/I know it's not your SP.
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Wed Nov 03, 2010 5:50 pm
Reply with quote

Thanks Guyc for your support.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 03, 2010 6:09 pm
Reply with quote

extract :
Code:
WORKING-STORAGE.
...
01  ws-misc.                                             
    05  ws-invar                pic  x(09).             
...
PROCEDURE DIVISION.
    move 'XXX' to ws-invar             
    display 'Befor[' ws-invar ']'     
    exec sql                           
        CALL myuserid.GUYCTEST(:ws-invar)
    end-exec                           
    perform sqlstate-check       
    display 'After[' ws-invar ']'     
    goback
    .
...

returns :
Code:
Befor[XXX      ]
After[10       ]
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Fri Nov 12, 2010 11:53 am
Reply with quote

Thanks GuyC..

It does not run it my shop.. Did you bind WLM (store procedure environment) while registering the SP ?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Nov 15, 2010 2:14 pm
Reply with quote

bind wlm ?
The stored procedure is native, so no extra binding steps are necessary.
I precompiled/compiled/linked/bound the calling program just like any other DB2 program.
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Tue Nov 16, 2010 11:45 am
Reply with quote

Thanks GuyC,

Infact i did the same. It is not working in my system. Instead of cobol , we tried to hit the SP from Java , it is working fine.

Seems that it is issue with COBOL program.

Thoughts?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Nov 16, 2010 3:03 pm
Reply with quote

not if your sqlcode is still 000.
Could be something with (descending plausiblility):
- parameter style : GENERAL WITH NULLS vs PARAMETER STYLE GENERAL
- different versions of the same SP.
- APF-authorized WLM Environments
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Thu Nov 18, 2010 8:46 am
Reply with quote

Thanks GuyC and Others.

Finally it is working now.

Thanks
Rajesh
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Nov 18, 2010 12:52 pm
Reply with quote

thx for letting us know.
What was the final problem?
Back to top
View user's profile Send private message
raj1984

New User


Joined: 28 Oct 2010
Posts: 16
Location: India

PostPosted: Thu Nov 18, 2010 12:59 pm
Reply with quote

Solution suggested by our DBA was to change the variable name.
I declared V_ACT_ID in SP and declared same variable in program as well.
But he wanted to change the name of variable . Basically same variable (name ) should not be used in both SP and COBOL pgm.

Seems to be strange but it is working .

Thanks
Rajesh
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Invoke stored procedure via batch JCL. DB2 2
No new posts Calling COBOL DB2 program from a COBO... COBOL Programming 2
No new posts Cond parameter and Rc code of a proce... JCL & VSAM 5
This topic is locked: you cannot edit posts or make replies. Internal Autonomous Stored Procedure ... DB2 6
No new posts Stored procedure cpu utilization DB2 1
Search our Forums:

Back to Top