Michael Glaesemann wrote:
>
> On Jun 1, 2007, at 14:54 , Brian Hurt wrote:
>
>> This is the current solution I'm going with. The main problem I have
>> with this is stylistic- it changes the result psql displays from an
>> insert response to a select response.
>
>
> If you'd like, you could throw in a RAISE NOTICE (or other level) so
> you get some other information.
If I just do an insert into the table, I see:
bhurt_dev=# INSERT INTO test1(id, name) VALUES (1, 'foo');
INSERT 0 1
bhurt_dev=#
But if I define:
CREATE FUNCTION insert_test1(p_id INT, p_name VARCHAR) RETURNS VOID
AS $_$
BEGIN
INSERT INTO test1(id, name) VALUES(p_id, p_name);
END
$_$ LANGUAGE plpgsql;
CREATE VIEW view1 AS SELECT * FROM test1;
CREATE RULE rule1 AS ON INSERT TO view1 DO INSTEAD SELECT
insert_test1(NEW.id, NEW.name);
and then do:
bhurt_dev=# INSERT INTO view1(id, name) VALUES (2, 'bar');
insert_test1
--------------
(1 row)
bhurt_dev=#
See the difference?
It's stylistic, and doesn't actually change anything.
Brian