Joined: 13 Dec 2008 Posts: 38 Location: Mexico City
Hi all
I am trying to do a DB2 Select from a table in C language.But the job is abending with an error code
Code:
SELECT TXN_ID,PARAM_A,PARAM_B
INTO DCLMONITOR.TXN_ID,
DCLMONITOR.PARAM_A.PARAM_A_data,
DCLMONITOR.PARAM_A.PARAM_B_data
FROM BMXSMG.MONITOR WHERE
TXN_ID = :ws_record->ws_txn_id ;
error code:
Code:
SQLCODE = -84;
strcpy( SQLSTATE, "42612" ) ;
CCN5256 (S) A parameter of type "char *" cannot be initialized with an expression of type "unsigned char Ý5¨"
CCN6205 (I) The error occurred while converting to parameter 1 ofy(char *, const char *)".
Joined: 13 Dec 2008 Posts: 38 Location: Mexico City
We have made some change to the code,but still facing same problem
Here is the sample code:
Code:
EXEC SQL
SELECT PARAM_A,PARAM_B
INTO
:ws_paramaa,
:ws_parambb
FROM BMXSMG.MONITOR WHERE
TXN_ID =:ws_tran_id ;
where definitions for host variables are as:
Code:
EXEC SQL BEGIN DECLARE SECTION;
char ws_tran_id<:5:>;
char ws_paramaa<:10:>;
char ws_parambb<:10:>;
EXEC SQL END DECLARE SECTION;
Declare table statement:
Code:
EXEC SQL DECLARE MONITOR TABLE
( TXN_ID CHAR(4) NOT NULL,
PARAM_A VARCHAR(10) NOT NUL
PARAM_B VARCHAR(10) NOT NUL
)
and the compiler generated output:
Code:
334 | /***$$$
335 | EXEC SQL
336 | SELECT PARAM_A,PARAM_B
337 | INTO
338 | :ws_paramaa,
339 | :ws_parambb
340 | FROM BMXSMG.MONITOR WHERE
341 | TXN_ID =:ws_tran_id
342 | $$$***/
343 | SQLCODE = -84;
344 | strcpy( SQLSTATE, "42612" ) ;
==========================¬
"//'SYS09100.T150007.RA000.BMXSMGDB.SYSCIN.H01'", line 344.11: CCN5256 (S) A parameter of type "char *" cannot be initialized with nsigned char Ý5¨".
"//'SYS09100.T150007.RA000.BMXSMGDB.SYSCIN.H01'", line 344.11: CCN6205 (I) The error occurred while converting to parameter 1 of "strcpy(char *, const char *)".
Can you please tell us whether there is something wrong in the SELECT statement or in declaration of variables?SQLCODE = -84 refers to UNACCEPTABLE SQL STATEMENT.What does that refer to in our case?Also,why is the strcpy generated?
then expand (on the left side) looking for
Declaration of fixed-length, null-terminated and variable-length character host variables in C and C++ embedded SQL applications