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
 

 

Facing problem with varchar col in multi-row insert

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Facing problem with varchar col in multi-row insert
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: 6966
Location: porcelain throne

PostPosted: Fri Dec 04, 2009 5:34 pm    Post subject:
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    Post subject: Reply to: Facing problem with varchar col in multi-row inser
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: 1746
Location: Bloomington, IL

PostPosted: Fri Dec 04, 2009 9:41 pm    Post subject:
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: 6966
Location: porcelain throne

PostPosted: Sat Dec 05, 2009 2:13 am    Post subject:
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    Post subject: Reply to: Facing problem with varchar col in multi-row inser
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    Post subject: Reply to: Facing problem with varchar col in multi-row inser
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.    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 SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm


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