Re: Looking for some help with cascading updates...

Поиск
Список
Период
Сортировка
От Mark True
Тема Re: Looking for some help with cascading updates...
Дата
Msg-id 647d31c20604181208l21bc7091sc43e58f55db28e8b@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Looking for some help with cascading updates...  (Andreas Kretschmer <akretschmer@spamfence.net>)
Ответы Re: Looking for some help with cascading updates...
Re: Looking for some help with cascading updates...
Список pgsql-sql
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 <akretschmer@spamfence.net> wrote:
Mark True <darfoo@gmail.com> 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=select count(*) from table;
>
> if count=0 {
> 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) = ($1,$2);
        if c = 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°, E 13.56889°

---------------------------(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

В списке pgsql-sql по дате отправления:

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Looking for some help with cascading updates...
Следующее
От: Ron Peterson
Дата:
Сообщение: create temp table in rule