Search
 
SCRIPT & CODE EXAMPLE
 

SQL

update trigger

/*EXAMPLE OF A UPDATE FUNCTION WITH TRIGGER PLPGSQL*/

CREATE OR REPLACE FUNCTION update_aumentarpreco ()
    RETURNS TRIGGER
    LANGUAGE PLPGSQL
    AS 
    $BODY$
BEGIN
	IF OLD.ps_availqty = 2 THEN
		RETURN NULL;
	END IF;
		
    IF NEW.ps_availqty = 2 THEN
        NEW.ps_supplycost = OLD.ps_supplycost * 0.10;
        RETURN NEW;
    END IF;
	
    RETURN NEW;
END;
    $BODY$ 

CREATE TRIGGER update_aumentarpreco
    BEFORE UPDATE OF ps_availqty ON partsupp
    FOR EACH ROW
    EXECUTE PROCEDURE update_aumentarpreco ();

/*DROP TRIGGER update_aumentarpreco ON partsupp*/
/*Testing

UPDATE
    partsupp
SET
    ps_availqty = 4
WHERE
    ps_suppkey = 2*/
Comment

PREVIOUS NEXT
Code Example
Sql :: setval max id postgresql sequence 
Sql :: mysql select count 
Sql :: mysql root permission denied lost 
Sql :: mysql min value row 
Sql :: oracle alter table add column default value 
Sql :: mysql set boolean default value 
Sql :: query to find object dependencies in oracle 
Sql :: mysql utc to local time 
Sql :: Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: run sql script from command line 
Sql :: htaccess allow index 
Sql :: ms sql database data size 
Sql :: creating table in sql 
Sql :: sql remove duplicates 
Sql :: mysql loop 
Sql :: QL HAVING Keyword 
Sql :: sqlite show columns 
Sql :: select users with same username 
Sql :: exec procedure oracle 
Sql :: oracle parameter 
Sql :: SQL Updating a View 
Sql :: ignore case in string sql 
Sql :: identify primary key in oracle table 
Sql :: sqlite select split string 
Sql :: convert html to plain text in sql server 
Sql :: temp tables in sql server 
Sql :: mysql not starting in xampp 
Sql :: select mysql limit to 2 decimal places 
Sql :: insert in sql 
Sql :: drush SQLSTATE[HY000] [2002] No such file or directory 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =