Database Reference
In-Depth Information
We can retrieve values from the tab_tcl table using the SELECT command
and check whether the row was indeed inserted in the following manner:
warehouse_db=# SELECT * FROM tab_tcl;
emp_id | emp_name | emp_city
--------+----------+----------
1 | Adam | Chicago
2 | John | Miami
3 | Roger | Boston
(3 rows)
From the preceding output, we can see that the row was inserted in the
tbl_tcl table.
Creating triggers in PL/Python
The PL/Python version of the previous example will be logically the same but
syntactically different. You might have observed so far how trigger variables are
accessed differently for all procedural languages. It will be good to see a few of them
for PL/Python as well. They are as follows:
TD["name"] : This is the name of the trigger
TD["table_name"] : This is the name of the table to which the trigger is
associated
TD["event"] : This is a string that can have the value INSERT , UPDATE ,
DELETE , or TRUNCATE
TD["new"] : This is the new trigger row for a row-level trigger
TD["old"] : This is the old trigger row for a row-level trigger
We'll make use of the preceding variables in triggers ahead. Reuse the previous
example to create and populate the sample table to bind the trigger later on.
Create the tab_python table in the following manner:
warehouse_db=# CREATE TABLE tab_python
(
emp_id INT NOT NULL,
emp_name VARCHAR(10),
emp_city VARCHAR(10)
);
 
Search WWH ::




Custom Search