Re: PreparedStatement and DB default values

Поиск
Список
Период
Сортировка
От Tomisław Kityński
Тема Re: PreparedStatement and DB default values
Дата
Msg-id 007101c226b7$2db2abf0$e1e163d9@xpecet
обсуждение исходный текст
Ответ на PreparedStatement and DB default values  (Tomisław Kityński <cromax@amiga.pl>)
Список pgsql-jdbc
----- Original Message -----
From: "Barry Lind" <barry@xythos.com>
To: "Tomisław Kityński" <cromax@amiga.pl>
Cc: <pgsql-jdbc@postgresql.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)





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

Предыдущее
От: "Simon Kitching"
Дата:
Сообщение: Re: Managing database with PostgreSQL
Следующее
От: Dan Brown
Дата:
Сообщение: JDBC 2.0 Datasource support?