0

I would like some assistance on the syntax on creating a rule that includes a where clause.

Here is what I have so far

CREATE RULE CodeRetrieve AS  
    ON SELECT TO RC.Code from RC WHERE RC.CODEID = FromQuery.CODEID
    DO INSTEAD  
    RCAA.Code from RCAA WHERE RCAA.CODEID = FromQuery.CODEID   

Basically, by default I want to redirect the query from one table to another and return the results from the RCAA table.

Reason? To avoid going thru the code in a gazillion places and changing the query. Just wanted to experiment with changing the code in one place, i.e. a database rule.

Thanks.

1
  • 2
    Why don't you just create a view named RC which selects from RCAA? Commented Jul 17, 2015 at 13:41

1 Answer 1

1

To redirec query from old table to new table maybe you don't need a rule but only some DDL and plane old sql. If you rename your table RC (for example in "_RC") and create view RC as select * from RCAA (eventually with a "where" filter) your gazillion lines of code need no change for the select query. in case of need of action query you can add a rule on the RC view.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.