Re: plpgsql function question

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: plpgsql function question
Date: 2007-04-03 19:24:19
Message-ID: 20070403192419.GA19007@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

am Tue, dem 03.04.2007, um 11:33:39 -0700 mailte Karthikeyan Sundaram folgendes:
> Hi,
>
> I guess there is some misunderstanding from my question

Maybe.

>
> 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';

What's the reason? For an INSERT or UPDATE - check? You can use a
TRIGGER and check the NEW-structure. Or create a new type, based on the
table-structure. Than you can create your function.

test=# create type a as ( i int, j varchar(20), k date);
CREATE TYPE
test=*# create function my_a (IN foo a) returns int as $$begin return 1; end; $$ language plpgsql;
CREATE FUNCTION
test=*#

> > Date: Tue, 3 Apr 2007 20:18:43 +0200
> > From: akretschmer(at)spamfence(dot)net
> > To: pgsql-sql(at)postgresql(dot)org
> > Subject: Re: [SQL] plpgsql function question

Please, no silly text above and fullquote below, i'm reading from top to
bottom...

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2007-04-03 20:14:20 Re: A long-running transaction
Previous Message Steve Midgley 2007-04-03 18:35:37 Re: [pgsql-sql] Daily digest v1.2492 (19 messages)