SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE if not exists "Order" ( order_id int NOT NULL, office_id int NOT NULL, costumer_id int NOT NULL, employer_id int NOT NULL, order_date date NOT NULL, order_time time NOT NULL, CONSTRAINT order_pk PRIMARY KEY (order_id), CONSTRAINT order_costumer FOREIGN KEY (costumer_id) REFERENCES "Costumer" (costumer_id), CONSTRAINT order_office FOREIGN KEY (office_id) REFERENCES "Office" (office_id), CONSTRAINT order_employer FOREIGN KEY (employer_id) REFERENCES "Employer" (employer_id), CONSTRAINT chk_order CHECK (order_id > 0) ); INSERT INTO "Order" (order_id, office_id, costumer_id, employer_id, order_date, order_time) VALUES (1, 11, 2, 2, '2021-09-11', '21:21:21'); INSERT INTO "Order" (order_id, office_id, costumer_id, employer_id, order_date, order_time) VALUES (2, 13, 3, 4, '2021-09-11', '22:22:22'); INSERT INTO "Order" (order_id, office_id, costumer_id, employer_id, order_date, order_time) VALUES (3, 14, 4, 6, '2021-09-11', '23:23:23'); CREATE PROCEDURE add_message(order_id integer, text text) LANGUAGE SQL AS $$ INSERT INTO "Order"(order_id, office_id, costumer_id, employer_id, order_date, order_time) VALUES (9, 11, 2, 2, '2022-08-09', '01:25:43'); $$; CALL add_message(9, 'payment error'); SELECT * FROM public."Order" WHERE order_id = 1 ORDER BY order_date desc;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear