From: | Tomisław Kityński <cromax(at)amiga(dot)pl> |
---|---|
To: | "Barry Lind" <barry(at)xythos(dot)com>, <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: PreparedStatement and DB default values |
Date: | 2002-07-08 19:39:26 |
Message-ID: | 007101c226b7$2db2abf0$e1e163d9@xpecet |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
----- Original Message -----
From: "Barry Lind" <barry(at)xythos(dot)com>
To: "Tomisław Kityński" <cromax(at)amiga(dot)pl>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Sent: Monday, July 08, 2002 6:40 PM
Subject: Re: [JDBC] PreparedStatement and DB default values
> Do you have any triggers or rules on this table that might be causing
> the problem?
>
As stated in previous mail, I have defined two rules for the table
and few constraint triggers. The rules are:
CREATE RULE "on_delete_to_users" AS
ON DELETE TO "users"
DO
(
UPDATE "news"
SET "id_author" = -1
WHERE "id_author" = OLD."id_user";
UPDATE "comments"
SET "id_author" = -1
WHERE "id_author" = OLD."id_user"
);
CREATE RULE "on_insert_to_users" AS
ON INSERT TO "users"
DO
(
INSERT INTO "given_permissions" VALUES (1, NEW."id_user");
INSERT INTO "given_permissions" VALUES (2, NEW."id_user");
INSERT INTO "given_permissions" VALUES (3, NEW."id_user");
);
In meantime I figured out, that dropping the "on_insert_to_users"
rule allowed me to insert default value into "users" table.
However, in PSQL documentation I have found this:
"The action [defined in rule] is done instead of the original query
if INSTEAD is specified; otherwise it is done after the original
query in the case of ON INSERT, or before the original query in the
case of ON UPDATE or ON DELETE".
So, in this particular case, in NEW tuple inside of rule
"on_insert_to_users",
there should be already--as stated in documentation--default value of
id_user taken from sequence. This is obviously not true. And in fact
this is related to PSQL itself and not to JDBC drivers.
Anyway thank you for your time and help. It seems like I have to post
my problem to different mailing group 8)
From | Date | Subject | |
---|---|---|---|
Next Message | Nikola Milutinovic | 2002-07-08 20:55:00 | Some general info needed |
Previous Message | Dan Brown | 2002-07-08 17:35:16 | JDBC 2.0 Datasource support? |