Comments (9)
Original comment by António Ramos (Bitbucket: ramstein74, GitHub: ramstein74).
Thank you very much. Working now!
from nodejs-idb-connector.
Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).
-
Not sure if your project use the global npm path or the local one. It depends on how you install idb-connector (-g or not). Would you check the effective version of nodejs and idb-connector and ensure the upgraded idb-connector is the one used by your code?
-
Would you try to run my test code?
const db2i = require("idb-connector");
const dbconn = new db2i.dbconn();
dbconn.conn("*LOCAL");
const dbstmt = new db2i.dbstmt(dbconn);
const wchar = "ÇÇÇÇÇÇÇÇ";
dbstmt.exec("SELECT * FROM (VALUES CHAR('" + wchar + "')) AS X (C)", (rs) => {
console.log("[char output] " + rs[0].C);
console.log("[char expect] " + wchar);
dbstmt.close();
});
Below is the test results between 1.1.4 and 1.1.5 on my system. You can see that 1.1.4 truncate half of the input while 1.1.5 not. (my terminal does not support the encoding but it does not matter)
bash-4.4$ npm -g i [email protected]
[idb-connector] Success: "/QOpenSys/pkgs/lib/nodejs10/lib/node_modules/idb-connector/lib/binding/Release/node-v64-ibmi-ppc64/db2ia.node" is installed via remote
+ [email protected]
updated 1 package in 10.019s
bash-4.4$ node test.js
[char output] ÇÇÇÇ
[char expect] ÇÇÇÇÇÇÇÇ
bash-4.4$ npm -g i [email protected]
[idb-connector] Success: "/QOpenSys/pkgs/lib/nodejs10/lib/node_modules/idb-connector/lib/binding/Release/node-v64-ibmi-ppc64/db2ia.node" is installed via remote
+ [email protected]
updated 1 package in 9.428s
bash-4.4$ node test.js
[char output] ÇÇÇÇÇÇÇÇ
[char expect] ÇÇÇÇÇÇÇÇ
from nodejs-idb-connector.
Original comment by António Ramos (Bitbucket: ramstein74, GitHub: ramstein74).
I updated to 1.1.5 and still get only the first 5 "ÇÇÇÇÇ" instead the full 10 "ÇÇÇÇÇÇÇÇÇÇ"
if i write "1234567890" i get "1234567890"
from nodejs-idb-connector.
Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).
Hello @ramstein74 ,
The only concern is that bigger buffer requires more memory usage.
Anyway, I have updated idb-connector to v1.1.5 to use a bigger buffer for those Unicode characters. You can upgrade it to verify that.
code change --> src/db2ia/dbstmt.cc
from nodejs-idb-connector.
Original comment by António Ramos (Bitbucket: ramstein74, GitHub: ramstein74).
i´m using tables not creating ones.
I´m trying to modernize my erp with some nodejs code.
I created a table and a field c with len 10
i pasted "ÇÇÇÇÇÇÇÇÇÇ"
if i query it i get only "ÇÇÇÇÇ" only five instead of 10 Ç
according to Kevin Adler
"The problem is that ibm_db uses the returned column size information to determine the size of the buffer to allocate on the SQLBindCol. In this case a column size of 10 will result in a 10-byte buffer being allocated. However, converting to UTF-8 will see the byte length of the column increase to greater than the size of the buffer. A 'Ç' is 1 byte in single byte EBCDIC code pages, but 2 bytes in UTF-8. If the data expands beyond the buffer size, the result will be truncated and the total size of the data will be returned in the indicator."
so a Ç takes 2 bytes and i get only the first 5 Ç because your driver thinks it already have the 10 bytes.
Is it correct ?
How can you help me solve this issue and get the 10 Ç chars inside my field of len 10 ?
regards
from nodejs-idb-connector.
Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).
Hello @ramstein74 , I checked the code and found that idb-connector only expands the buffer for wide characters --> https://bitbucket.org/litmis/nodejs-idb-connector/src/master/src/db2ia/dbstmt.cc#lines-1927
Using Kevin's code in ibmdb/python-ibmdb#359, I can recreate the truncated issue if I use the char column to store the string -->
create or replace table xumeng.english(c char(10) ccsid 37);
But if I use the nchar column, there is no error -->
create or replace table xumeng.english(c nchar(10) ccsid 37);
If possible, would you try to query the string from a nchar column? If it resolve the problem, then it is the same issue as the python ibm_db.
from nodejs-idb-connector.
Original comment by António Ramos (Bitbucket: ramstein74, GitHub: ramstein74).
i tried also the python ibm_db to query my db2 and found apparently the same issue.
I opened an isssue in github about that python bug.
I think nodejs idb-connector may have the same problem.
ibmdb/python-ibmdb#359
can anybody comment on this?
regards
António
from nodejs-idb-connector.
Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).
Issue #47 was marked as a duplicate of this issue.
from nodejs-idb-connector.
Original comment by Xu Meng (Bitbucket: mengxumx, GitHub: dmabupt).
Do you have an url that I can access to recreate the issue?
I am not sure if it is a HTTP encoding issue. I am not familiar with express, but you may try to add a HTTP respond tag to set the correct encoding like
#!javascript
res.set('Content-Type', 'text/html;charset=utf-8');
res.send(result);
stm.close();
from nodejs-idb-connector.
Related Issues (20)
- Character conversion between CCSID 1208 and CCSID 65535 not valid. HOT 7
- Set SQL_ATTR_NON_HEXCCSID CLI environment attribute by default
- Error SQLSTATE=02000 SQLCODE=100 HOT 4
- Error SQLSTATE=38501 SQLCODE=-443 does not return the true message HOT 1
- idb-connector not compatible with Node.js v16.x HOT 30
- Error SQLSTATE=02000 SQLCODE=100 HOT 1
- Error SQLSTATE=22504 SQLCODE=-191 Mixed data or UTF-8 data not properly formed. HOT 22
- Use of BINARY Parameter w/Stored Procedure Call Corrupts the Node Process HOT 3
- Handling permanent JOB... HOT 1
- Some issues when calling SP with dbstmt.bindParameters() HOT 1
- Error: SQLSTATE=22504 SQLCODE=-191 Mixed data or UTF-8 data not properly formed. HOT 1
- Not receiving output from Stored Procedure and no clear example..
- temporary memory of job increases massive when using CLOB/JSON field in SQL-request HOT 3
- Connection Pool HOT 3
- Add package-lock.json? HOT 1
- the sql state error seems to be fixed, but we have a different issue HOT 4
- idb-connector *SP calls returns invalid numeric data -- Node 18, IDB-Connector 1.2.18 HOT 21
- test: cleanup test infrastructure HOT 1
- CLOB: truncation of the last char ! HOT 6
- Fix license headers on source files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-idb-connector.