scripts's People
scripts's Issues
Otimizar codigo
PL granos
CREATE OR REPLACE FUNCTION update_easel() RETURNS trigger AS
DECLARE
old_easel RECORD;
new_easel_id INTEGER;
BEGIN
IF NEW.easel_name IS NOT NULL THEN
SELECT INTO old_easel * FROM products
WHERE products.type = 'Easel'
AND products.easel_name = NEW.easel_name LIMIT 1;
IF old_easel.eid IS NOT NULL THEN
UPDATE products SET easel_id = old_easel.eid WHERE pid = NEW.pid;
ELSE
INSERT INTO products(
eid,
type,
easel_name,
material_id,
product_type_id,
quality_id,
thickness_id,
treatment_id,
user_id,
customer_id
) VALUES(
nextval('products_eid_seq'),
'Easel',
NEW.easel_name,
NEW.material_id,
NEW.product_type_id,
NEW.quality_id,
NEW.thickness_id,
NEW.treatment_id,
NEW.user_id,
NEW.customer_id
) RETURNING currval('products_eid_seq') into new_easel_id;
UPDATE products SET easel_id = new_easel_id WHERE pid = NEW.pid;
END IF;
END IF;
RETURN NULL;
END;
$update_easel_trigger$ LANGUAGE plpgsql;
CREATE TRIGGER update_easel_trigger AFTER INSERT ON products FOR EACH ROW EXECUTE PROCEDURE update_easel();
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.