UPPER as default on a column
Posted in 2006
Topics: Data Types & Schema Design
Hello Running Informix version 10 FC5 is it possible to use the UPPER function as a default on a field? for example : create table 'informix'.city_state_zip ( id SERIAL not null, city VARCHAR(30) not null, state CHAR(2) not null default upper(), zip CHAR(11) where the state field will automagically populate to upper case, ie. enter tx and the value converts to TX? Thanks in advance, Tom
NO only literals.
But the below code using triggers seems to work well.
create table zzz_city_state_zip (
id SERIAL not null,{
create table zzz_city_state_zip (
id SERIAL not null,
city VARCHAR(30) not null,
state CHAR(2) not null,
zip CHAR(11)
) ;
create trigger
zzz_city_state_zip_insert
insert on
zzz_city_state_zip
referencing
new as n
for each row (
execute function upper(n.state) into zzz_city_state_zip.state
);
create trigger
zzz_city_state_zip_update
update of state on
zzz_city_state_zip
referencing
old as o
new as n
for each row (
execute function upper(n.state) into zzz_city_state_zip.state
);
insert into zzz_city_state_zip values(0, "Honululu", "hi", "99999");
insert into zzz_city_state_zip values(0, "San Antonio", "tx", "99999");
insert into zzz_city_state_zip values(0, "Fairbanks", "ak", "99999");
insert into zzz_city_state_zip values(0, "Fort Walton Bch", "fl","99999");
select * from zzz_city_state_zip;
tomcaml@yahoo.com wrote:
> Hello
>
> Running Informix version 10 FC5
>
> is it possible to use the UPPER function as a default on a field?
>
> for example :
> create table 'informix'.city_state_zip (
> id SERIAL not null,
> city VARCHAR(30) not null,
> state CHAR(2) not null default upper(),
> zip CHAR(11)
>
>
> where the state field will automagically populate to upper case, ie.
> enter tx and the value converts to TX?
>
> Thanks in advance,
> Tom