Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dynamic SQl, PREPARE statement gives -312

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
anju subrahmanian

New User


Joined: 11 Jul 2010
Posts: 21
Location: Bangalore

PostPosted: Wed Jul 28, 2010 11:58 am    Post subject: Dynamic SQl, PREPARE statement gives -312
Reply with quote

In my cobol program, am using dynamic sql, but 'PREPARE' statement gives me an sql code -312 at run time. Please find details below

EXEC SQL
PREPARE SQLSTMT FROM :WS-SQL-STATEMENT
END-EXEC.

where WS-SQL-STATEMENT contains below sql statement

UPDATE tablename
SET UNT_PAR_VALUE_AMNT = :FUND-UNT-PAR-VALUE-AM
WHERE SPNSR_NO = :FUND-SPONSOR-NO AND
SPONSR_FUND_NO = :FUND-SPONSR-FUND-NO

variable FUND-UNT-PAR-VALUE-AM is defined in a copybook and the same is included in cobol program using 'sql include' statement.

Below is error I get.

SQLCODE = -312, ERROR: FUND IS AN UNDEFINED OR UNUSABLE HOST

VARIABLE OR IS USED IN A DYNAMIC SQL STATEMENT OR A TRIGGER

DEFINITION

What could be the reason for error......
Back to top
View user's profile Send private message

anju subrahmanian

New User


Joined: 11 Jul 2010
Posts: 21
Location: Bangalore

PostPosted: Wed Jul 28, 2010 2:32 pm    Post subject:
Reply with quote

Can we use host variables in Dynamic SQL statement?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Wed Jul 28, 2010 2:46 pm    Post subject:
Reply with quote

IBM Redbook, Squeezing the Most out of dynamic SQL on Z/os and os390
Back to top
View user's profile Send private message
anju subrahmanian

New User


Joined: 11 Jul 2010
Posts: 21
Location: Bangalore

PostPosted: Wed Jul 28, 2010 3:43 pm    Post subject:
Reply with quote

Dick, thanks a lot for the document.

Looks like we cannot use host variables in dynamic sql. But the whatever I am trying to achieve becomes difficult.

My requirement is below.

I want to update a table, but the columns of the table that need to updated is not fixed. i.e, for example this time I want to update only one coulmn of the table, but in a different situation I have to update 2 or 3 columns.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us