Unix Technical Forum

postgres rule with where clause

This is a discussion on postgres rule with where clause within the Pgsql General forums, part of the PostgreSQL category; --> Hi all, i have a problem with rules on a view. I want to use a conditional rule that ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 12:19 AM
dennie
 
Posts: n/a
Default postgres rule with where clause

Hi all,

i have a problem with rules on a view.
I want to use a conditional rule that will access other tables, but
when i use the rule i get the following error:
ERROR: cannot insert into a view
HINT: You need an unconditional ON INSERT DO INSTEAD rule.


My rule looks something like:
CREATE RULE zxv_employees_insert AS ON INSERT TO zxv_employees
WHERE EXISTS (select * from zxt_other where 1=1)
DO INSTEAD insert into zxt_employees (a,b,c,d) values (x,x,x,x);

The postgres API tells me that the where clause cannot access another
table and can only so something with NEW/OLD.

I must do a check for inserting new data on a view. Is there some way
i can fix this?


thanx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:19 AM
dennie
 
Posts: n/a
Default Re: postgres rule with where clause

On Jan 28, 4:13 pm, dennie <dennie.gu...@gmail.com> wrote:
> Hi all,
>
> i have a problem with rules on a view.
> I want to use a conditional rule that will access other tables, but
> when i use the rule i get the following error:
> ERROR: cannot insert into a view
> HINT: You need an unconditional ON INSERT DO INSTEAD rule.
>
> My rule looks something like:
> CREATE RULE zxv_employees_insert AS ON INSERT TO zxv_employees
> WHERE EXISTS (select * from zxt_other where 1=1)
> DO INSTEAD insert into zxt_employees (a,b,c,d) values (x,x,x,x);
>
> The postgres API tells me that the where clause cannot access another
> table and can only so something with NEW/OLD.
>
> I must do a check for inserting new data on a view. Is there some way
> i can fix this?
>
> thanx


I have found the solution. I must use unconditional rule on a view.
Then i don't get any errors. It's possible to query other tables in a
conditional rule.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:17 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com