From: | Joe <dev(at)freedomcircle(dot)net> |
---|---|
To: | Karthikeyan Sundaram <skarthi98(at)hotmail(dot)com> |
Cc: | pgsql-admin(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [SQL] Urgent help in bit_string data type |
Date: | 2007-04-11 23:00:23 |
Message-ID: | 1176332423.782.10.camel@pampa |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-sql |
Hi skarthi,
On Wed, 2007-04-11 at 15:01 -0700, Karthikeyan Sundaram wrote:
> create table test_a (b bit(3));
>
> create view test_vw (b1, b2, b3)
> as select
> to_number(substring(b,1,1)::int,'9') as b1,
> to_number(substring(b,2,1)::int,'9') as b2,
> to_number(substring(b,3,1)::int,'9') as b3 from test_a;
>
> create or replace rule test_a_ins as on insert to test_vw
> do instead
> insert into test_a (b) values (COALESCE(new.b1::bit,'1')||
> COALESCE(new.b2::bit,'0')||COALESCE(new.b3::bit,'0')::bit);
>
> ERROR: cannot cast type numeric to bit
>
> How will I resolve this?
*My* question is why are you doing such convoluted conversions, from bit
string to text, then to int, etc.? It seems to me like you want to
manipulate bits and if that's the case, you should be using the bit
string operators, as someone pointed out a couple of days ago. In case
you haven't looked at them, please see:
http://www.postgresql.org/docs/8.2/static/functions-bitstring.html
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | Karthikeyan Sundaram | 2007-04-11 23:29:45 | Re: [SQL] Urgent help in bit_string data type |
Previous Message | Karthikeyan Sundaram | 2007-04-11 22:01:07 | Re: [SQL] Urgent help in bit_string data type |
From | Date | Subject | |
---|---|---|---|
Next Message | Karthikeyan Sundaram | 2007-04-11 23:29:45 | Re: [SQL] Urgent help in bit_string data type |
Previous Message | Karthikeyan Sundaram | 2007-04-11 22:01:07 | Re: [SQL] Urgent help in bit_string data type |