pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karthikeyan Sundaram <skarthi98@hotmail.com>
To: Joe <dev@freedomcircle.net>
Cc: pgsql-admin@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Urgent help in bit_string data type
Date: Wed, 11 Apr 2007 15:01:07 -0700
Message-ID: <BAY131-W421F946C7905459DCFE10B05F0@phx.gbl> (raw)


Thanks Joe,
 
  Here is my next question.
 
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_vwdo insteadinsert 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?
 
Regards
skarthi
> Date: Wed, 11 Apr 2007 17:44:01 -0400> From: dev@freedomcircle.net> Subject: Re: [ADMIN] [SQL] Urgent help in bit_string data type> To: skarthi98@hotmail.com> CC: pgsql-admin@postgresql.org; pgsql-sql@postgresql.org> > Hi skarthi,> > On Wed, 2007-04-11 at 13:30 -0700, Karthikeyan Sundaram wrote:> > insert into test_a values (to_char(1,'9'));> > > > ERROR: column "b" is of type bit but expression is of type> > text> > HINT: You will need to rewrite or cast the expression.> > As suggested by the error, you should use a cast, e.g.,> > insert into test_a values 9::bit(3);> > This will result in binary '001' being inserted because you need 4 bits> to represent decimal 9.> > Joe> > > ---------------------------(end of broadcast)---------------------------> TIP 6: explain analyze is your friend
_________________________________________________________________
Take a break and play crossword puzzles - FREE!
http://games.msn.com/en/flexicon/default.htm?icid=flexicon_ wlmemailtaglinemarch07=

view thread (6+ messages)  latest in thread

Message-ID: <BAY131-W421F946C7905459DCFE10B05F0@phx.gbl>
Permalink:  ../BAY131-W421F946C7905459DCFE10B05F0@phx.gbl/
Also on:    postgresql.org/message-id/BAY131-W421F946C7905459DCFE10B05F0@phx.gbl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: skarthi98@hotmail.com, dev@freedomcircle.net, pgsql-admin@postgresql.org
  Subject: Re: [SQL] Urgent help in bit_string data type
  In-Reply-To: <BAY131-W421F946C7905459DCFE10B05F0@phx.gbl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox