I have some procedure that perform INSERT statement:
CREATE OR REPLACE PROCEDURE potok_insert(
p_jfplate IN potok.jfplate%TYPE,
p_post IN potok.post%TYPE,
p_jfchan IN potok.jfchan%TYPE,
p_jfdatetime IN VARCHAR2
)
AS
t_jfdatetime TIMESTAMP:=TO_TIMESTAMP(p_jfdatetime,'DD.MM.YYYY HH24:MI:SS');
BEGIN
INSERT INTO potok (jfplate, post, jfchan, jfdate_y, jfdate_m, jfdate_d, jftime, jfdatetime,
dt_reg, ibd_arx)
VALUES (RTRIM(p_jfplate),
p_post,
RTRIM(p_jfchan),
EXTRACT(YEAR FROM t_jfdatetime),
EXTRACT(MONTH FROM t_jfdatetime),
EXTRACT(DAY FROM t_jfdatetime),
LPAD(EXTRACT(HOUR FROM t_jfdatetime),2,'0')||':'||
LPAD(EXTRACT(MINUTE FROM t_jfdatetime),2,'0')||':'||
LPAD(EXTRACT(SECOND FROM t_jfdatetime),2,'0'),
CAST(t_jfdatetime AS DATE),
SYSDATE,
1);
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END potok_insert;
Some triggers and constraints are applied to table, they can
break INSERT.
How can I check in procedure body – if INSERT was successful or not?
Of course I can call count() in head and in end of procedure, but this will be not so graceful solution.
You can use the RETURNING clause to return the rowid of the row you have just created, like this:
Taken from this link:
http://www.psoug.org/reference/insert.html