![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
|
And do OpenAPI and ESQLC use the same parts of GCA? I use your ESQLC code to insert the Hello World string and the hex dump is showing each wide char is two bytes as I would expect. I use my OpenAPI equivalent...with your US_ASSIGN stuff and NVARCHAR struct and my hex dump is showing 4 bytes per wide char....and a truncation in the string. typedef struct _NVARCHAR { II_UINT2 len; /* The number of characters, not bytes */ wchar_t text[200]; /* So its fixed, hang me its only a test */ } MY_NVARCHAR; ... UC_ASSIGN(input_widechar, L"This is a big Hello World...and a wide one too!"); /* So the input_widechar len is 47 and everyone is happy*/ ... setDescrParm.sd_descriptor[1].ds_dataType = IIAPI_NVCH_TYPE; setDescrParm.sd_descriptor[1].ds_nullable = FALSE; setDescrParm.sd_descriptor[1].ds_length = sizeof(MY_NVARCHAR); /* 804? I expected 802 */ setDescrParm.sd_descriptor[1].ds_precision = 0; setDescrParm.sd_descriptor[1].ds_scale = 0; setDescrParm.sd_descriptor[1].ds_columnType = IIAPI_COL_QPARM; setDescrParm.sd_descriptor[1].ds_columnName = NULL; ... putParmParm.pp_parmData[1].dv_null = FALSE; putParmParm.pp_parmData[1].dv_length = sizeof(MY_NVARCHAR); putParmParm.pp_parmData[1].dv_value =&input_widechar; Marty -----Original Message----- From: Alex Hanshaw [mailto:Alex.Hanshaw (AT) ingres (DOT) com] Sent: 07 October 2010 10:12 To: Martin Bowes Subject: RE: [Info-Ingres] OpenAPI and nvarchar type Hi Marty The len is the number of characters in the nvarchar struct used. The gca length describes the number of bytes. So when GCA transmits the nvarchar it transmits sizeof(i2) + (var.len * sizeof(wchar_t)) bytes. There's some code in adf/adu which checks the size of wchat_t and provides portability across platforms that use different sizes. You may find this useful if your application is going to be used on more than one platform. Alex -----Original Message----- From: Martin Bowes [mailto:martin.bowes (AT) ctsu (DOT) ox.ac.uk] Sent: 07 October 2010 10:01 To: Ingres and related product discussion forum Cc: Alex Hanshaw Subject: RE: [Info-Ingres] OpenAPI and nvarchar type Hi All, So your using wchar_t stuff? Given thogo01's description that wchar_t may be 4 bytes on some hosts, I'd assumed we might be better off with a stucture: nvarchar struct { II_UINT2 len; /* Number of characters, not bytes */ II_UINT2 text[]; } I counter checked my existing programs usage of wchar_t and found by doing hex dumps of the data that I was indeed loading 4 byte character items into my test table. I was busily rewriting my test case accordingly using iconv to make some test data. Getting confused now! Marty -----Original Message----- From: Ingres Forums [mailto:info-ingres (AT) kettleriverconsulting (DOT) com] Sent: 07 October 2010 09:23 To: info-ingres (AT) kettleriverconsulting (DOT) com Subject: Re: [Info-Ingres] OpenAPI and nvarchar type Hi Marty A recently worked on a number of bugs that did this type of thing in an ESQLC program. The test case used MACROS for the assignments: #define UC_ASSIGN(l, r) wcscpy((l.text), (r)); (l).len = wcslen((l).text) #define UC_TERM(v) (v).text[(v).len] = L'\0' nvarchar struct { short len; wchar_t text[GW155_COL_LEN]; } res_nvarchar As you can see there is no "* 2" on the length because the .len field represents the number of characters (as Gordy pointed out) You should make sure you have the fix for Bugs 123442, 123912 and 123728. These all relate to the use of nchar/nvarchar variables in ESQLC and Java. I've attached the tests case for Bug 123442 (esqlc and java) as you might me able to make some use of the code as a template. If you need any help with wchar_t usage or have any questions don't hesitate to ask. Chris Clark wrote the java scripts for the above bugs and I'm sure he'll be able to answer any questions if I can't. Regards Alex |
#8
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |