pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karthikeyan Sundaram <skarthi98@hotmail.com>
To: postgres admin <pgsql-admin@postgresql.org>
To: postgres sql <pgsql-sql@postgresql.org>
Subject: Question on pgpsql function
Date: Sun, 8 Apr 2007 12:47:42 -0700
Message-ID: <BAY131-W13C024D09AE528E6496EECB05A0@phx.gbl> (raw)


Hi Everybody,
 
   I am using Postgres 8.1.0 and I have a requirement.
 
 I have a table 
 
  create table weekly_tbl (id int, week_flag bit(7) not null default '1111111');
 
I want to create a function like this
 
create function week_func (int) returns weekly_tbl as 
$$
  select id,
           substr(week_flag,1,1) as monday_flag,
           substr(week_flag,2,1) as tuesday_flag,
           substr(week_flag,3,1) as wednesday_flag,
           substr(week_flag,4,1) as thursday_flag,
           substr(week_flag,5,1) as friday_flag,
           substr(week_flag,6,1) as saturday_flag,
           substr(week_flag,7,1) as sunday_flag
    from weekly_tbl where id=$1;
$$
language SQL;
 
 I am getting an error message 
ERROR:  function substr(bit, integer, integer) does not existHINT:  No function matches the given name and argument types. You may need to add explicit type casts.CONTEXT:  SQL function "week_func"
 
I know I can do this in view.  But for a purpose, I don't want to do it in view. Can somebody help me?
 
Regards
skarthi
 
_________________________________________________________________
It’s tax season, make sure to follow these few simple tips 
http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.aspx?icid=WLMartagline=

view thread (3+ messages)  latest in thread

Message-ID: <BAY131-W13C024D09AE528E6496EECB05A0@phx.gbl>
Permalink:  ../BAY131-W13C024D09AE528E6496EECB05A0@phx.gbl/
Also on:    postgresql.org/message-id/BAY131-W13C024D09AE528E6496EECB05A0@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, pgsql-admin@postgresql.org
  Subject: Re: Question on pgpsql function
  In-Reply-To: <BAY131-W13C024D09AE528E6496EECB05A0@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