Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 6970
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 Enterprise PL/I - dynamic allocation ... prino PL/I & Assembler 0 Mon Jan 29, 2018 10:17 pm
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts ON 2 AND EVERY 1 - Statement ??? UmeySan COBOL Programming 2 Tue Jul 25, 2017 1:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us