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

Facing problem with varchar col in multi-row insert


IBM Mainframe Forums -> DB2
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Sangita

New User


Joined: 02 Jun 2005
Posts: 17

PostPosted: Fri Dec 04, 2009 4:46 pm
Reply with quote

I am trying to implement multi-row insert into DB2 Table in my application program but facing problem with varchar column. Below is the declaration.

05 WS-INS-NAME OCCURS 10 TIMES.
49 WS-INS-NAME-LEN PIC S9(4) COMP VALUE ZEROES.
49 WS-INS-NAME-TEXT PIC X(21) VALUE SPACES.

I am getting below error during compilation.

'UNDEFINED OR UNUSABLE HOST VARIABLE "WS-INS-NAME"'

I will appreciate any help. Thanks.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Dec 04, 2009 5:34 pm
Reply with quote

well, since we can not see your sql
and the error message is predicated on the sql and the host variable
how about a half answer -
you have an undefined or unusable host variable.

have a good weekbegin.
Back to top
View user's profile Send private message
Sangita

New User


Joined: 02 Jun 2005
Posts: 17

PostPosted: Fri Dec 04, 2009 9:22 pm
Reply with quote

Thanks for the half answer....

here is the insert sql

EXEC SQL
INSERT INTO AL_039
(CLNT_KEY_SEQ, CLNT_NO, CLNT_NAME, LAST_UPDT_ID)
VALUES (:WS-INS-KEY-SEQ, :WS-CLNT-NO, :WS-INS-NAME,
:WS-LAST-UPDT-ID)
FOR :WS-ROWS ROWS
END-EXEC.

LAST_UPDT_ID is also varchar but I am not using array for this host variable as it has one value for each row.

Problem is with varchar with occurs as I mentioned in my original post. If I remove this column , the program works fine.

Hope I have provided full question and this time I expect a full answer.
Thanks in advance.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Fri Dec 04, 2009 9:41 pm
Reply with quote

Are you pre-compiling with STDSQL(YES)? Does WS-INS-NAME appears in the XREF? What data type does the XREF give for it?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Dec 05, 2009 2:13 am
Reply with quote

Do not know how germane this is but:

using a ROWSET UPDATE Cursor for varchar would not work unless I,
as you have done with the last_update column,
only referenced a host variable sans occurs.

I found that I had to do individual UPDATEs WHERE CURRENT CURSOR when my varchar host variable was different (array) for each row.

Has been a while
(6 months ago at a different site - so I don't have access to code/DB2 parms etc...)
and as a result can not provide an answer to Akatsukami's comment.

nor did I ever find an example in the documentation
(Redbooks and tech manuals)
concerning multi-row UPDATE of varchar with an array.
though, the FETCH will populate the array properly.

This was DB2 vsn 7.
Back to top
View user's profile Send private message
Sangita

New User


Joined: 02 Jun 2005
Posts: 17

PostPosted: Mon Dec 07, 2009 10:35 am
Reply with quote

Akatsukami,

Per-compile option is with STDSQL(N0). Could this be a problem?
WS-INS-NAME is present in cross-reference listing but it does not allocate any data type. But WS-LAST-UPDT-ID which is also a varchar without any OCCURS clause is in the listing and has been allocated datatype.

Thanks.
Back to top
View user's profile Send private message
Sangita

New User


Joined: 02 Jun 2005
Posts: 17

PostPosted: Mon Dec 07, 2009 11:40 am
Reply with quote

One more precompile option that I guess could give problem is
NEWFUN(YES) option which is set to NO currenctly.
Could this be a problem?
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Converting VARCHAR to XML DB2 1
No new posts Problem moving a cobol program into E... COBOL Programming 3
No new posts Sort to insert record in an empty file. DFSORT/ICETOOL 5
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
Search our Forums:


Back to Top