Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Thorsten Geelhaar, on IDS 9.21.UC4, asked how to insert or update a TEXT column with a char value and convert between them from shell or Perl. Jonathan Leffler said there are no TEXT literals and no built-in cast between TEXT or BYTE and CHAR, so one would need a UDR cast. He said Perl DBI with DBD::Informix can insert and update TEXT with some help on updates. Casting attempts failed.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
hello ,
Is it possible to insert or update a text field with a char ?
Something like this:
Create table T1 {
t_serial serial
lstring text}
insert into T1 values ("my text");
update T1 set lstring = "my text" ;
Another question is if i can convert a char to a text field or a text field to a char ?
PS: I know the normal way in esql, but i am searching for a way how i can insert or update text
fields with shell- or perlscripts.
Thx for any tips and replies
Thorsten
Thorsten Geelhaar wrote:
> Is it possible to insert or update a text field with a char?
> Something like this:
>
> Create table T1 {
> t_serial serial
> lstring text> }
Use parentheses '()' not braces '{}'... :-)
> insert into T1 values ("my text");
> update T1 set lstring = "my text" ;
No; there are no TEXT literals.
> Another question is if i can convert a char to a text field or a text
> field to a char?
Since you don't say which server you're using, it isn't possible to
tell whether you could write and install a cast operator as a UDR.
> PS: I know the normal way in esql, but i am searching for a way how i
> can insert or update text fields with shell- or perlscripts.
Perl with DBI and DBD::Informix can handle both INSERT and UPDATE of
TEXT fields, albeit with a little help from you, the programmer, on
UPDATE. Basically, you have to tell it which columns in the SET
clause correspond to TEXT values.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
Hello Jonathan,
Jonathan Leffler wrote:
> Thorsten Geelhaar wrote:
>
>> Is it possible to insert or update a text field with a char?
>> Something like this:
>>
>> Create table T1 {
>> t_serial serial
>> lstring text>> }
>
>
> Use parentheses '()' not braces '{}'... :-)
Was just on the fly :-)
>
>> insert into T1 values ("my text");
>> update T1 set lstring = "my text" ;>
>
>
> No; there are no TEXT literals.
>
>> Another question is if i can convert a char to a text field or a text
>> field to a char?
>
>
> Since you don't say which server you're using, it isn't possible to tell
> whether you could write and install a cast operator as a UDR.
>
Sorry, I am using an informix 2000 Server (9.21 UC4).
>> PS: I know the normal way in esql, but i am searching for a way how i
>> can insert or update text fields with shell- or perlscripts.
>
>
> Perl with DBI and DBD::Informix can handle both INSERT and UPDATE of
> TEXT fields, albeit with a little help from you, the programmer, on
> UPDATE.
Ok,thx that helps concernly Perl.
Can you say want you mean with the casting. I tried to cast from
text to char and vice versa, but it doesnt work.
Thorsten
Thorsten Geelhaar wrote:
> Jonathan Leffler wrote:
>> Thorsten Geelhaar wrote:
>> No; there are no TEXT literals.
>>> Another question is if i can convert a char to a text field or a text
>>> field to a char?
>>
>> Since you don't say which server you're using, it isn't possible to
>> tell whether you could write and install a cast operator as a UDR.
>
> Sorry, I am using an informix 2000 Server (9.21 UC4).
>
> Can you say want you mean with the casting. I tried to cast from
> text to char and vice versa, but it doesnt work.
That's why you have to write it - there isn't a built-in cast from
BYTE or TEXT to CHAR or vice-versa. I think I remember reading that
someone had written such operations - I recommend poking around the
IIUG Software Archive or the Google archive of c.d.i postings.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.