| From: | Daniel Martini <dmartini(at)uni-hohenheim(dot)de> |
|---|---|
| To: | Jamie Deppeler <jamie(at)doitonce(dot)net(dot)au> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: rules |
| Date: | 2004-11-26 07:45:14 |
| Message-ID: | 1101455114.41a6df0a8e7a7@webmail.uni-hohenheim.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi,
Citing Jamie Deppeler <jamie(at)doitonce(dot)net(dot)au>:
> sample sql querty
>
> INSERT INTO schema.table2
> (
> "field1",
> "field2",
> "field3",
> "field4",
> "field5",
> "field6",
> "field7",
> "field8",
> "field9",
> )
> VALUES
> (
> SELECT
> table1."name",
> table1.notes,
> table1.hrs,
> table1.days,
> table3.value,
> table31.value,
> table4.ratename,
> table4.maxhrs,
> table4.appliesafter,
> table4.rate,
> table5.value,
> table5."name"
> FROM
> (inner joins)
> Where
> primary = number
> )
>
> which i would like to make into a rule if possible
First of all, you should fix your query. Problems I see:
- You're inserting more values than you specified fields.
- On postgresql you don't have to use the
insert into foo (...) values (select ...)
construct, you can instead say:
insert into foo (...) select ...
For the rule stuff:
- do you want it to happen on update, on delete or on insert? You should
be clear about that.
You might want to read Bruce Momjian's book "PostgreSQL - Introduction
and Concepts" (available in your book store or on the web - I leave it
up to you to google it up or to order it). It's a really fine book for
beginners and helped me a lot to learn how to write rules and do other
stuff with postgresql.
Regards,
Daniel
| From | Date | Subject | |
|---|---|---|---|
| Next Message | gnari | 2004-11-26 08:24:39 | Re: PostgreSQL slow after VACUUM |
| Previous Message | Nikola Milutinovic | 2004-11-26 06:35:54 | PostgreSQL slow after VACUUM |