|
View previous topic :: View next topic
|
| Author |
Message |
Sangita
New User
Joined: 02 Jun 2005 Posts: 17
|
|
|
|
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 |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
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 |
|
 |
Sangita
New User
Joined: 02 Jun 2005 Posts: 17
|
|
|
|
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 |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| 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 |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
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 |
|
 |
Sangita
New User
Joined: 02 Jun 2005 Posts: 17
|
|
|
|
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 |
|
 |
Sangita
New User
Joined: 02 Jun 2005 Posts: 17
|
|
|
|
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 |
|
 |
|
|