[英]Making anonymous block in PL/SQL
I need to build an anonymous block to insert values in a table of configuration with this columns: config and value.我需要构建一个匿名块以在具有以下列的配置表中插入值:config 和 value。
This is what I need to insert:这是我需要插入的内容:
Config: ‘country’ Value: ‘Argentina’
Config: ‘moneysign’ Value: ‘$’
Config: ‘dateformat’ Value: ‘DD/MM/YYYY’
I have to validate that the 3 insertions are correct.我必须验证 3 次插入是否正确。 In case of failure, identify which failed and return the DB to the consistent state it was before starting the script.
如果失败,请确定哪个失败并将数据库返回到启动脚本之前的一致状态。
BEGIN
INSERT INTO CONFIG_TABLE (CONFIG, VAL) VALUES ('country', 'Argentia');
INSERT INTO CONFIG_TABLE (CONFIG, VAL) VALUES ('moneysign', '$');
INSERT INTO CONFIG_TABLE (CONFIG, VAL) VALUES ('dateformat', 'DD/MM/YYYY');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE||' -ERROR- '||SQLERRM);
ROLLBACK;
END;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.