Insert or update a text field with a char ?
Posted in 2003
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
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/