If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > can you use variables in PostgreSQL rules?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-05-04, 15:29
my_lou my_lou is offline
Registered User
 
Join Date: Oct 2003
Posts: 57
can you use variables in PostgreSQL rules?

i am currently migrating a db from Oracle to Pg and in some of my triggers i use variables, i.e. i have some thing like this:



[Oracle version]



CREATE OR REPLACE TRIGGER "USERACTION_VIEW" INSTEAD OF INSERT ON "USERACTION_VIEW" DECLARE

UserActionID INTEGER;

UserActionDataID INTEGER;

begin

SELECT USERACTION_SQ.nextval into UserActionID FROM DUAL;

SELECT USERACTIONDATA_SQ.nextval into UserActionDataID FROM DUAL;



INSERT INTO USERACTION

(

UserActionID,

LocalID,

UserActionTypeID,

ActionDate

)

VALUES

(

UserActionID,

:new.LocalID,

:new.UserActionTypeID,

SYSDATE

);



INSERT INTO USERACTIONDATA

(

UserActionDataID,

UserActionID,

AccountID,

CourseRecordID,

CourseRecordPaymentID,

StudentID,

CourseRecordTestID,

CourseRecordLessonID

)

VALUES

(

UserActionDataID,

UserActionID,

:new.AccountID,

:new.CourseRecordID,

:new.CourseRecordPaymentID,

:new.StudentID,

:new.CourseRecordTestID,

:new.CourseRecordLessonID

);



end;





so basically i have two variables here, UserActionID and UserActionDataID. so when i am porting to PostgreSQL i will need to make this a rule since Pg triggers only work for tables. The problem though is that i don't know how to use variabvles in Pg rules. Any ideas? Is it possible at all?



Thanks.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On