inserts on views using rules - Mailing list pgsql-general

From Stuart Robinson
Subject inserts on views using rules
Date
Msg-id Pine.LNX.4.30.0111082349420.9601-100000@othello.dreamingamerica.com
Whole thread Raw
In response to Re: PSQL anc compile errors  (Tielman J de Villiers <tjdevil@bondnet.co.za>)
List pgsql-general
I've got a view that combines a couple of tables. The view is meant to
simplify interactions with a Java application, so that selects, inserts,
and updates can be made on the view as if it were a real table. So, I
figured that rules would be the way to go. For inserts, I wrote a
do-instead rule for the view which in turn calls a function. The function
is meant to take the values from the insert statement and stick them into
the appropriate tables. However, functions appear to always return a value
(except as triggers), which confuses the JDBC. So, when I do an insert on
the view, the function is called and returns a value, causing the
following error:

A result was returned by the statement, when none was expected.
        at org.postgresql.jdbc2.Statement.executeUpdate(Statement.java:80)
        at
org.postgresql.jdbc2.PreparedStatement.executeUpdate(PreparedStatement.java:122)

I take it this is the expected JDBC behavior and not a bug. If so, what
are my options given that functions always return values and triggers
operate before or after inserts, but not instead of them? Is there some
way of calling functions so that they don't return a value? (If this
posting is more appropriate for another mailing list, please let me know.)
Thanks in advance.

-Stuart Robinson


pgsql-general by date:

Previous
From: "Erol Öz"
Date:
Subject: Ynt: OID's as Primary Keys
Next
From: "Frans Thamura"
Date:
Subject: Postgre for Windows