When I run the below program I get the SQL0332 message -- Character conversion between CCSID 13488 and CCSID 65535 not valid.-- on the FETCH stm.
I try to read a table with an unicode field which I want to display on a web page from my RPG. Actually I will not know in advance the select statement when in production phase. I wrote this Q&D program for testing purpose to check how I can display unicode fields on a web page.
My QRPGLESRC source file has CCSID 1147 (France + Euro symbol).
My job has CCSID 1147.
My table is defined as below :
The SQLRPGLE program
Then I CHGJOB CCSID(37) and ran again the program. This time the program worked but I get ÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚ.. . in TABLEFETCH.F2 field when I debug past the FETCH stm.
Why does the program seem to work when CCSID 37 and why do I get SQL0332 when CCSID 1147?
What am I doing wrong? Can you please shed a light on this?
Thanks in advance.
I try to read a table with an unicode field which I want to display on a web page from my RPG. Actually I will not know in advance the select statement when in production phase. I wrote this Q&D program for testing purpose to check how I can display unicode fields on a web page.
My QRPGLESRC source file has CCSID 1147 (France + Euro symbol).
My job has CCSID 1147.
My table is defined as below :
PHP Code:
Data Field Buffer Buffer Field
Field Type Length Length Position Usage
F1 CHAR 5 5 1 Both
Default value . . . . . . . . . . . . . . : None
Coded Character Set Identifier . . . . . : 1147
TITRELI GRAPHIC 40 80 6 Both
Default value . . . . . . . . . . . . . . :
'THIS IS A TITLE'
Coded Character Set Identifier . . . . . : 13488
UCS2 or Unicode conversion . . . . . . . : *CONVERT
PHP Code:
h DftActGrp( *No )
H Option( *SrcStmt )
* -------------------------------------------------------------------------------------
* sql Descriptor Area
* -------------------------------------------------------------------------------------
d sqlDA DS qualified
d sqlDAId 8a
d sqlDABC 10i 0
d sqlN 5i 0
d sqld 5i 0
d sql_var 80a
d sqlvar DS dim(2) qualified based(psqlvar)
d sqlType 5i 0
d sqllendec 5i 0
d sqlRsv 12a
d sqlData *
d sqlInd *
d sqlNameLen 5i 0
d sqlName 30a
* Variables de travail
d pa_Request s 512a inz('select * from MyTable')
d varying
d i s 5i 0
d TableFetch ds qualified
d F1 5a
d F2 1000a
/free
exec sql set option commit = *none;
*inlr = *on;
clear sqlDA;
// Preparation instruction
exec sql PREPARE Sqlstm FROM :pa_Request;
// Erreur sur Prepare
if sqlcod <> 0;
dsply sqlcod;
return;
endif;
exec sql DECLARE C1 cursor FOR Sqlstm;
exec sql Open C1;
if sqlcod <> 0;
dsply sqlcod;
return;
endif;
sqlDA.sqlN = 0;
psqlvar = %addr(sqlda.sql_var);
clear sqlvar;
// Acces initial a sqlDA pour determiner le nb de zones a extraire
exec sql DESCRIBE Sqlstm INTO :sqlDA;
doW sqlDA.sqlN < sqlDA.sqld;
sqlDA.sqlN += 1;
exec sql DESCRIBE Sqlstm INTO :sqlDA;
enddo;
For i = 1 to sqlDA.sqlN;
// Adressage zones de travail de reception
sqlvar(1).sqlData = %addr(TableFetch.F1);
sqlvar(2).sqlData = %addr(TableFetch.F2);
exec sql FETCH C1
USING DESCRIPTOR :SQLDA; //SQL0332 happens here
if sqlcod <> 0;
dsply sqlcod;
return;
endif;
clear TableFetch;
endfor;
exec sql close C1;
...
Why does the program seem to work when CCSID 37 and why do I get SQL0332 when CCSID 1147?
What am I doing wrong? Can you please shed a light on this?
Thanks in advance.
Comment