Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id DCFF49FBAB8 for ; Tue, 3 Apr 2007 15:33:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 73427-02 for ; Tue, 3 Apr 2007 15:33:40 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from bay0-omc2-s32.bay0.hotmail.com (bay0-omc2-s32.bay0.hotmail.com [65.54.246.168]) by postgresql.org (Postfix) with ESMTP id E2BA79FBA1B for ; Tue, 3 Apr 2007 15:33:40 -0300 (ADT) Received: from BAY131-W18 ([65.55.136.53]) by bay0-omc2-s32.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Tue, 3 Apr 2007 11:33:39 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_47a274a9-43f0-4957-8d64-219b1a59f2df_" X-Originating-IP: [67.116.31.14] From: Karthikeyan Sundaram To: Andreas Kretschmer , Subject: Re: plpgsql function question Date: Tue, 3 Apr 2007 11:33:39 -0700 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 03 Apr 2007 18:33:39.0023 (UTC) FILETIME=[98EEC5F0:01C7761E] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/40 X-Sequence-Number: 28040 --_47a274a9-43f0-4957-8d64-219b1a59f2df_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, =20 I guess there is some misunderstanding from my question =20 Let me elaborate more clearly. =20 My Table is=20 =20 Create table a ( i int, j varchar(20), k date); =20 Create or replace function a_func (in p_i int, in p_j varchar, in p_k date)= returns int as $$ ----- do the validation return 1; $$ language 'plpgsql'; =20 This works fine =20 What I want is something like this create or replace functinon a_func (in a%rowtype) returns int as $$ ---- do the validation $$ language 'plpgsql'; =20 execute a_func(1, 'good','04/02/2007'); =20 > Date: Tue, 3 Apr 2007 20:18:43 +0200> From: akretschmer@spamfence.net> T= o: pgsql-sql@postgresql.org> Subject: Re: [SQL] plpgsql function question> = > Karthikeyan Sundaram schrieb:> > > > > Hi,> > > >= I am having a requirement here.> > > > 1) I need to write a plpgsql functi= on where it takes the input> > parameter of a structure of a table.> > Beca= use? To build this table? You can pass an ascii-text with the> table-defini= tion and EXECUTE this string.> > > > 2) The table has 15 columns> > Okay. A= nd the problem is?> > > > 3) It does lots of validation based on the parame= ter and finally> > returns an integer as output parameters> > Okay. create = function ... returns int as $$ ... return 1; end; $$> language plpgsql;> > = > > > > Q) How will I passe the table structure as as parameter> > As i sai= d, for instance as simple text and EXECUTE this.> > > > 2) Do I need to cre= ate a type?> > No.> > > Andreas> -- > Really, I'm not out to destroy Micros= oft. That will just be a completely> unintentional side effect. (Linus Torv= alds)> "If I was god, I would recompile penguin with --enable-fly." (unknow= )> Kaufbach, Saxony, Germany, Europe. N 51.05082=B0, E 13.56889=B0> > -----= ----------------------(end of broadcast)---------------------------> TIP 9:= In versions below 8.0, the planner will ignore your desire to> choose an i= ndex scan if your joining column's datatypes do not> match _________________________________________________________________ i'm making a difference.=A0Make every IM count for the cause of your choice= . Join Now. http://clk.atdmt.com/MSN/go/msnnkwme0080000001msn/direct/01/?href=3Dhttp://= im.live.com/messenger/im/home/?source=3Dwlmailtagline= --_47a274a9-43f0-4957-8d64-219b1a59f2df_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi,
 
  I guess there is some misunderstanding from my question
 
  Let me elaborate more clearly.
 
   My Table is
 
 Create table a (
 i int,
 j varchar(20),
 k date);
 
Create or replace function a_func (in p_i int, in p_j varchar, in p_k date)= returns int as
$$
  ----- do the validation
  return 1;
$$
language 'plpgsql';
 
This works fine
 
What I want is something like this
create or replace functinon a_func (in a%rowtype) returns int as
$$
   ---- do the validation
$$
language 'plpgsql';
 
execute a_func(1, 'good','04/02/2007');
 
 


> Date: Tue, 3 Apr 2007 20:18:43 +0200
> From: a= kretschmer@spamfence.net
> To: pgsql-sql@postgresql.org
> Subje= ct: Re: [SQL] plpgsql function question
>
> Karthikeyan Sundar= am <skarthi98@hotmail.com> schrieb:
>
> >
> &g= t; Hi,
> >
> > I am having a requirement here.
> &= gt;
> > 1) I need to write a plpgsql function where it takes the = input
> > parameter of a structure of a table.
>
> Be= cause? To build this table? You can pass an ascii-text with the
> tab= le-definition and EXECUTE this string.
>
>
> > 2) Th= e table has 15 columns
>
> Okay. And the problem is?
> <= BR>>
> > 3) It does lots of validation based on the parameter = and finally
> > returns an integer as output parameters
> > Okay. create function ... returns int as $$ ... return 1; end; $$> language plpgsql;
>
>
> >
> > Q) How= will I passe the table structure as as parameter
>
> As i sai= d, for instance as simple text and EXECUTE this.
>
>
> = > 2) Do I need to create a type?
>
> No.
>
> <= BR>> Andreas
> --
> Really, I'm not out to destroy Microsof= t. That will just be a completely
> unintentional side effect. (Linus= Torvalds)
> "If I was god, I would recompile penguin with --enable-f= ly." (unknow)
> Kaufbach, Saxony, Germany, Europe. N 51.05082=B0, E 1= 3.56889=B0
>
> ---------------------------(end of broadcast)--= -------------------------
> TIP 9: In versions below 8.0, the planner= will ignore your desire to
> choose an index scan if your joining co= lumn's datatypes do not
> match


i'm making a differenc= e.=A0Make every IM count for the cause of your choice. Join Now.= = --_47a274a9-43f0-4957-8d64-219b1a59f2df_--