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

Dynamic SQl, PREPARE statement gives -312


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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: 6966
Location: porcelain throne

PostPosted: Wed Jul 28, 2010 2:46 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Dynamic file allocation using JCL JCL & VSAM 8
Search our Forums:

Back to Top