Thread: 7.2 behavior -- inserts, rules and jdbc

7.2 behavior -- inserts, rules and jdbc

From
Richard Welty
Date:
first, the context: redhat 7.3, postgres 7.2.5, appropriate pgjdbc2.jar

i recently added a rule associated with a table insert. the rule calls a
stored pl/pgsql procedure to update another table in the database. i
couldn't find a way for the procedure to be called unless it returned a
value, so i declared it as returning int and return 1 every time.

the rule is as follows:

CREATE RULE OnPayment AS
ON INSERT TO payment
DO SELECT ApplyPayment ( new.customer_id,
                         new.against_credit_balance,
                         new.payment_type,
                         new.amount,
                         new.operator_id
                        );

so everything works now, _but_: if i use executeUpdate to issue my insert,
i get an SQL exception because a result is returned from ApplyPayment().
i ended up using executeQuery and ignoring the result set instead.

is this really the correct behavior, or have i missed something obvious?

thanks,
  richard
--
Richard Welty                                         rwelty@averillpark.net
Averill Park Networking                                         518-573-7592
              Unix, Linux, IP Network Engineering, Security