C UDR : Text to Char or reverse
Posted in 2006
Sven wanted to write a C UDR on IDS 10 that converts TEXT (simple large object) columns to/from LVARCHAR, but found the DataBlade API doesn't directly support TEXT/BYTE and that no cast from TEXT to LVARCHAR exists. Carsten pointed to IBM docs noting that C UDRs can accept TEXT arguments because character data is passed as mi_lvarchar, suggesting a pass-through function declared as TEXT in/LVARCHAR out. Madison Pruet pointed to his developerWorks 'cdr check' article, whose classicBlob_checksum routine reads byte/text data; Sven compiled it but hit an 'Illegal cmd passed to cdrcmd' error on 10.00.xC3, and Madison confirmed it requires 10.00.xC4 or later (the cdrcmd interfaces being undocumented). No confirmation of a working TEXT-to-LVARCHAR solution is recorded.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
Hi all, i implented some c-udr's in ids 10 successfully. The new request is to cast text-fields (simple large objetcs) and/or reverse. Main-problem is to cast TEXT-Field to the lvarchar-type. IBM-Doc and IDN says : you can't use text-fields in udr's but as arguments to routines you can. (this i need) IIUG-Archives gives only 1 example in ESQL/C (loc_t & Co.). Nothing in C which demonstrates handling with TEXT-Fields. CDI says : It works ! Write a C-UDR-Routine ! Google says : look at CDI, IIUG or IBM Question : Is there any stuff, wich shows this TEXT-Field-Handling in C-UDR ? Are there whole routines or examples ? regards Sven IDS 10FC5 Sol.5.9 64Bit
On Thu, 2006-12-21 at 15:11 +0100, news.hansenet.de wrote: > Hi all, > > > > i implented some c-udr's in ids 10 successfully. > > The new request is to cast text-fields (simple large objetcs) and/or > reverse. > > Main-problem is to cast TEXT-Field to the lvarchar-type. > > > IBM-Doc and IDN says : you can't use text-fields in udr's but as arguments > to routines you can. (this i need) > > IIUG-Archives gives only 1 example in ESQL/C (loc_t & Co.). Nothing in C > which demonstrates handling with TEXT-Fields. > > CDI says : It works ! Write a C-UDR-Routine ! > > Google says : look at CDI, IIUG or IBM > > > > Question : Is there any stuff, wich shows this TEXT-Field-Handling in C-UDR > ? Are there whole routines or examples ? http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.dapip.doc/dapip67.htm says: "The DataBlade API does not provide *direct* support for simple large objects. Therefore, it cannot directly access TEXT and BYTE columns." [Emphasis mine.] However, it also says, for server-side only, which is what you need: "C UDRs can accept TEXT data as arguments because the database server passes all character data in the mi_lvarchar data type." This is outside my comfort zone, but this sounds as if an identity function that takes a mi_lvarchar and returns it verbatim should do what you need as long as the UDRs are created on the SQL side as taking TEXT and returning LVARCHAR, and vice versa. (This is in theory, based on not much more than the documentation I've linked to. Your mileage may vary.) Hope this helps, -- Carsten Haese | Phone: (419) 861-3331 Software Engineer | Direct Line: (419) 794-2531 Unique Systems, Inc. | FAX: (419) 893-2840 1687 Woodlands Drive | Cell: (419) 343-7045 Maumee, OH 43537 | Email: carsten@uniqsys.com
news.hansenet.de wrote: > Hi all, > > > > i implented some c-udr's in ids 10 successfully. > > The new request is to cast text-fields (simple large objetcs) and/or > reverse. > > Main-problem is to cast TEXT-Field to the lvarchar-type. > > > IBM-Doc and IDN says : you can't use text-fields in udr's but as arguments > to routines you can. (this i need) > > IIUG-Archives gives only 1 example in ESQL/C (loc_t & Co.). Nothing in C > which demonstrates handling with TEXT-Fields. > > CDI says : It works ! Write a C-UDR-Routine ! > > Google says : look at CDI, IIUG or IBM > > > > Question : Is there any stuff, wich shows this TEXT-Field-Handling in C-UDR > ? Are there whole routines or examples ? > > You might want to check out the entry in developer works which I entered concerning the using of "cdr check". http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0604pruet/ I'm pretty sure that the routine for classicBlob_checksum is reading a byte/text. You'll need to be on v.10, for this, however. > > > regards > > Sven > > > IDS 10FC5 Sol.5.9 64Bit > > > > > > > > > >
Hi Madison,
great script ..
i have compiled your project successfully.
my Script :
------------------------
create table rtrt (
rt1 TEXT
);
load from rtrt.unl insert into rtrt;
select checksum(rt1,0) from rtrt
------------------------
is getting the error :
------------------------
(expression)
(U0001) - Illegal cmd passed to cdrcmd
Error in line 10Near character position 33
------------------------
I found that i am using ids10.0FC3 on this server. Do i need FC4 really to
access TEXT-Fields ? (I am upgrading at the moment).
I cant get any information about, what your are doing with "cdrcmd_4" and
how it works.
Do you have any more informations ?
"Madison Pruet" <mpruet@tx.rr.com> schrieb im Newsbeitrag
news:458AA633.3060209@tx.rr.com...
> news.hansenet.de wrote:
>> Hi all,
>>
>>
>>
>> i implented some c-udr's in ids 10 successfully.
>>
>> The new request is to cast text-fields (simple large objetcs) and/or
>> reverse.
>>
>> Main-problem is to cast TEXT-Field to the lvarchar-type.
>>
>>
>> IBM-Doc and IDN says : you can't use text-fields in udr's but as
>> arguments to routines you can. (this i need)
>>
>> IIUG-Archives gives only 1 example in ESQL/C (loc_t & Co.). Nothing in C
>> which demonstrates handling with TEXT-Fields.
>>
>> CDI says : It works ! Write a C-UDR-Routine !
>>
>> Google says : look at CDI, IIUG or IBM
>>
>>
>>
>> Question : Is there any stuff, wich shows this TEXT-Field-Handling in
>> C-UDR ? Are there whole routines or examples ?
>>
>>
>
> You might want to check out the entry in developer works which I entered
> concerning the using of "cdr check".
>
> http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0604pruet/
>
> I'm pretty sure that the routine for classicBlob_checksum is reading a
> byte/text. You'll need to be on v.10, for this, however.
>
>
>>
>>
>> regards
>>
>> Sven
>>
>>
>> IDS 10FC5 Sol.5.9 64Bit
>>
>>
>>
>>
>>
>>
>>
>>
>>
Hi Carsten, this IBM-Site i have already seen. Taking TEXT is done by "REFERENCES TEXT". But this reference i can't use in the C-UDR. and i cant cast TEXT to LVARCHAR (You get the IFX-Error "No cast from text to lvarchar"). Sven "Carsten Haese" <carsten@uniqsys.com> schrieb im Newsbeitrag news:mailman.679.1166712735.29126.informix-list@iiug.org... > On Thu, 2006-12-21 at 15:11 +0100, news.hansenet.de wrote: >> Hi all, >> >> >> >> i implented some c-udr's in ids 10 successfully. >> >> The new request is to cast text-fields (simple large objetcs) and/or >> reverse. >> >> Main-problem is to cast TEXT-Field to the lvarchar-type. >> >> >> IBM-Doc and IDN says : you can't use text-fields in udr's but as >> arguments >> to routines you can. (this i need) >> >> IIUG-Archives gives only 1 example in ESQL/C (loc_t & Co.). Nothing in C >> which demonstrates handling with TEXT-Fields. >> >> CDI says : It works ! Write a C-UDR-Routine ! >> >> Google says : look at CDI, IIUG or IBM >> >> >> >> Question : Is there any stuff, wich shows this TEXT-Field-Handling in >> C-UDR >> ? Are there whole routines or examples ? > > http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.dapip.doc/dapip67.htm > says: "The DataBlade API does not provide *direct* support for simple > large objects. Therefore, it cannot directly access TEXT and BYTE > columns." [Emphasis mine.] > > However, it also says, for server-side only, which is what you need: "C > UDRs can accept TEXT data as arguments because the database server > passes all character data in the mi_lvarchar data type." > > This is outside my comfort zone, but this sounds as if an identity > function that takes a mi_lvarchar and returns it verbatim should do what > you need as long as the UDRs are created on the SQL side as taking TEXT > and returning LVARCHAR, and vice versa. (This is in theory, based on not > much more than the documentation I've linked to. Your mileage may vary.) > > Hope this helps, > > -- > Carsten Haese | Phone: (419) 861-3331 > Software Engineer | Direct Line: (419) 794-2531 > Unique Systems, Inc. | FAX: (419) 893-2840 > 1687 Woodlands Drive | Cell: (419) 343-7045 > Maumee, OH 43537 | Email: carsten@uniqsys.com >
Sven Radtke wrote:
> Hi Madison,
>
>
> great script ..
>
>
> i have compiled your project successfully.
>
>
>
> my Script :
> ------------------------
> create table rtrt (
> rt1 TEXT
> );>
> load from rtrt.unl insert into rtrt;>
>
> select checksum(rt1,0) from rtrt
> ------------------------
>
> is getting the error :
>
> ------------------------
> (expression)
>
>
> (U0001) - Illegal cmd passed to cdrcmd
> Error in line 10> Near character position 33
> ------------------------
>
>
> I found that i am using ids10.0FC3 on this server. Do i need FC4 really to
> access TEXT-Fields ? (I am upgrading at the moment).
>
>
> I cant get any information about, what your are doing with "cdrcmd_4" and
> how it works.
>
> Do you have any more informations ?
The document from the web site mentions that this only works in
v10.00.xC4 and above. We're not documenting the cdrcmd interfaces.
>
>
>
>
>
>
>
>
>
>
> "Madison Pruet" <mpruet@tx.rr.com> schrieb im Newsbeitrag
> news:458AA633.3060209@tx.rr.com...
>> news.hansenet.de wrote:
>>> Hi all,
>>>
>>>
>>>
>>> i implented some c-udr's in ids 10 successfully.
>>>
>>> The new request is to cast text-fields (simple large objetcs) and/or
>>> reverse.
>>>
>>> Main-problem is to cast TEXT-Field to the lvarchar-type.
>>>
>>>
>>> IBM-Doc and IDN says : you can't use text-fields in udr's but as
>>> arguments to routines you can. (this i need)
>>>
>>> IIUG-Archives gives only 1 example in ESQL/C (loc_t & Co.). Nothing in C
>>> which demonstrates handling with TEXT-Fields.
>>>
>>> CDI says : It works ! Write a C-UDR-Routine !
>>>
>>> Google says : look at CDI, IIUG or IBM
>>>
>>>
>>>
>>> Question : Is there any stuff, wich shows this TEXT-Field-Handling in
>>> C-UDR ? Are there whole routines or examples ?
>>>
>>>
>> You might want to check out the entry in developer works which I entered
>> concerning the using of "cdr check".
>>
>> http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0604pruet/
>>
>> I'm pretty sure that the routine for classicBlob_checksum is reading a
>> byte/text. You'll need to be on v.10, for this, however.
>>
>>
>>>
>>> regards
>>>
>>> Sven
>>>
>>>
>>> IDS 10FC5 Sol.5.9 64Bit
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>
Related threads
- Column name length in Informix
- Caching Data to Buffers
- Checkpoint Duration
- dbaccess standalone.
- Getting executable name.