Case Statements in Rules?

Поиск
Список
Период
Сортировка
Искать

Case Statements in Rules?

От:
"Bryan Encina" <bryan.encina@valleypres.org>
Дата:
I have a view called userinfo composed of a join from 2 tables (users,
signon) with the following rule.

CREATE RULE userinfo_ins AS ON INSERT TO userinfo
	DO INSTEAD
	(INSERT INTO users VALUES (NEW.emp_id, NEW.password, NEW.fname, NEW.mi,
NEW.lname, NEW.emp_ssa, NEW.emp_status);
	INSERT INTO signon VALUES (NEW.emp_id, NEW.signon_id); );

which works fine, however I'd like to use a case statement on the second
insert so that it only inserts if the signon_id is not null.  I was just
wondering if it's possible.

Any help would be greatly appreciated.
Thanks,
-Bryan Encina

Re: Case Statements in Rules?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Bryan Encina"  writes:
> which works fine, however I'd like to use a case statement on the second
> insert so that it only inserts if the signon_id is not null.

CASE is not the solution.  Do something like

	INSERT INTO target SELECT this, that, theother WHERE condition;

			regards, tom lane

FAQ