pgScript Scripting Language - catch exception
pgScript Scripting Language - catch exception
От:
Sergey Grinko <sergey.grinko@gmail.com>
Дата:
No exception is generated when inserting a duplicate.
Sample:CREATE DATABASE test;
CREATE TABLE test (
id serial NOT NULL,
label character varying(50),
CONSTRAINT test_pkey PRIMARY KEY (id)
);
Then run the 3 commands as one PgScript:
insert into test (id, label) values(1, '1');
insert into test (id, label) values(1, '2'); -- We have here exception: ERROR: duplicate key value violates unique constraint "test_pkey"
insert into test (id, label) values(2, '2');
What I see in the window "Output pane":
[QUERY ] insert into test (id, label) values(1, '1')
[WARNING ] insert into test (id, label) values(1, '2')
[QUERY ] insert into test (id, label) values(2, '2')
Questions:
How do I know that an error occurred?
How to stop the continuation of the script?
--
Yours faithfully, Sergey Grinko
Email: sergey.grinko@gmail.com
Email: sergey.grinko@gmail.com