X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 138C811F6059 for ; Tue, 18 Apr 2006 16:09:14 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -1.87 X-Spam-Level: X-Spam-Status: No, score=-1.87 required=5 tests=[AWL=0.234, BAYES_00=-2.599, HTML_40_50=0.496, HTML_MESSAGE=0.001, SPF_PASS=-0.001] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id tdB2nxY-PbkX for ; Tue, 18 Apr 2006 16:09:03 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.203]) by postgresql.org (Postfix) with ESMTP id 9E36311F6293 for ; Tue, 18 Apr 2006 16:08:59 -0300 (ADT) Received: by nz-out-0102.google.com with SMTP id z3so792551nzf for ; Tue, 18 Apr 2006 12:08:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=uVU7bfBp1KSNpsBFzdUVCHEX+F0SHz8j0H2sPvVptkCehN55ApThGSIOgWLKof7z4fVtSZxfsQTj4lEjsBbQqH3BsMcLnAGgQpFpd1G3KGgipO13Yklj5t5mzLENCq72X9H61dvpNBGtJg0hgw04ziurNIBmZNHd7XQXCbsJCPI= Received: by 10.65.40.11 with SMTP id s11mr1615326qbj; Tue, 18 Apr 2006 12:08:59 -0700 (PDT) Received: by 10.65.197.10 with HTTP; Tue, 18 Apr 2006 12:08:59 -0700 (PDT) Message-ID: <647d31c20604181208l21bc7091sc43e58f55db28e8b@mail.gmail.com> Date: Tue, 18 Apr 2006 15:08:59 -0400 From: "Mark True" To: "Andreas Kretschmer" Subject: Re: Looking for some help with cascading updates... Cc: pgsql-sql@postgresql.org In-Reply-To: <20060418184959.GA2576@KanotixBox> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_24237_6581026.1145387339190" References: <647d31c20604181119m43ba3c7ay3d467dd9446a6fd8@mail.gmail.com> <20060418183101.GA31339@KanotixBox> <647d31c20604181144g63b9ecc2t800e4e2d5fa91f0e@mail.gmail.com> <20060418184959.GA2576@KanotixBox> X-Archive-Number: 200604/118 X-Sequence-Number: 24927 ------=_Part_24237_6581026.1145387339190 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Next silly question, how do you get your database to like plpgsql... I do CREATE LANGUAGE 'plpgsql' and it says it is not defined? --Mark On 4/18/06, Andreas Kretschmer wrote: > > Mark True schrieb: > > > I guess I should have clarified. I am having trouble figuring out how > to > > construct the IF statement to see if that item exists in the foreign > table > > something like: > > > > count=3Dselect count(*) from table; > > > > if count=3D0 { > > insert fkey into myOtherTable > > } > > a real example: > (table harz_ufpos references harz_uf) > > > create or replace function gh_insert(text,int,int,text,int,float) returns > int as $$ > declare c int; > begin > select into c count(*) from harz_uf where (uf,ab) =3D ($1,$2); > if c =3D 0 then > insert into harz_uf (uf,ab,beschreibung,aktiv) values > ($1,$2,$4,'t'); > end if; > > insert into harz_ufpos (uf,pos,anzahl,rest,flaeche) values > ($1,$3,$5,$5,$6); > > return 1; > end; > $$ language 'plpgsql'; > > > HTH, Andreas > -- > Really, I'm not out to destroy Microsoft. That will just be a completely > unintentional side effect. (Linus Torvalds) > "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 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > ------=_Part_24237_6581026.1145387339190 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Next silly question, how do you get your database to like plpgsql...
I do CREATE LANGUAGE 'plpgsql' and it says it is not defined?

--Mar= k


On 4/18/06, Andreas Kretschmer <akr= etschmer@spamfence.net> wrote:
Mark True <darfoo@gmail.com> = schrieb:

> I guess I should have clarified.  I am havin= g trouble figuring out how to
> construct the IF statement to see if = that item exists in the foreign table
> something like:
>
> count=3Dselect count(*) from table= ;
>
> if count=3D0 {
> insert fkey into myOtherTable
&= gt; }

a real example:
(table harz_ufpos references harz_uf)

create or replace function gh_insert(text,int,int,text,int,float) retur= ns int as $$
declare c       int;
begin=
        select into c count(*) = from harz_uf where (uf,ab) =3D ($1,$2);
     &n= bsp;  if c =3D 0 then
            &nb= sp;   insert into harz_uf (uf,ab,beschreibung,aktiv) values = ($1,$2,$4,'t');
        end if;<= br>
        insert into harz_ufp= os (uf,pos,anzahl,rest,flaeche) values ($1,$3,$5,$5,$6);

  = ;      return 1;
end;
$$ language 'plpgsql';


HTH, Andreas
--
Really,= I'm not out to destroy Microsoft. That will just be a completely
uninte= ntional side effect.         &= nbsp;           &nbs= p;        (Linus Torvalds)
"= ;If I was god, I would recompile penguin with --enable-fly." &nbs= p;  (unknow)
Kaufbach, Saxony, Germany, Europe.      &= nbsp;       N 51.05082=B0, E 13.56889=B0=

---------------------------(end of broadcast)----------------------= -----
TIP 1: if posting/reading through Usenet, please send an appropria= te
       subscribe-nomail command to majordomo@postgresql.org so that = your
       message can get through to the= mailing list cleanly

------=_Part_24237_6581026.1145387339190--