In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Oracle's SQL and PL/SQL syntax is relatively loose, while PostgreSQL is relatively strict.
In PL/SQL, some statements can be followed without a semicolon, while PG requires that a semicolon be added.
Oracle
To create a stored procedure, loop can be created successfully, regardless of whether you add a semicolon or not.
TEST-orcl@DESKTOP-V430TU3 > CREATE OR REPLACE PROCEDURE proc_test (a NUMBER) as 2 v_id number; 3 begin 4 for i in (select 1 from dual) loop 5 select 2 into v_id from dual; 6 end loop 7 return; 8 end; 9 / Procedure created.TEST-orcl@DESKTOP-V430TU3 > TEST-orcl@DESKTOP-V430TU3 > CREATE OR REPLACE PROCEDURE proc_test (a NUMBER) as 2 v_id number; 3 begin 4 for i in (select 1 from dual) loop 5 select 2 into v_id from dual 6 end loop; 7 return; 8 end; 9 / Procedure created.TEST-orcl@DESKTOP-V430TU3 >
PostgreSQL
To create a stored procedure, you must add a semicolon after the loop before it can be created successfully.
[local:/data/run/pg12]: 5120 pg12@testdb=# CREATE OR REPLACE PROCEDURE proc_test (pi_in int) pg12@testdb-# aspg12@testdb-# $$pg12@testdb$# declarepg12@testdb$# v_id int;pg12@testdb$# I record;pg12@testdb$# begin pg12@testdb$# for i in (select 1 from dual) looppg12@testdb$# select 2 into v_id from dual; pg12@testdb$# end looppg12@testdb$# return; pg12@testdb$# end;pg12@testdb$# $$LANGUAGE 'plpgsql' T (pi_in int) as$$declare v_id int; I record;begin for i in (select 1 from dual) loop select 2 into v_id from dual; end loop; return; end;$$ LANGUAGE 'plpgsql';ERROR: end label "return" specified for unlabelled blockLINE 11: return ^ [local:/data/run/pg12]: 5120 pg12@testdb=# [local:/data/run/pg12]: 5120 pg12@testdb=# [local:/data/run/pg12]: 5120 pg12@testdb=# CREATE OR REPLACE PROCEDURE proc_test (pi_in int) pg12@testdb-# aspg12@testdb-# $$pg12@testdb$# declarepg12@testdb$# v_id int;pg12@testdb$# I record Pg12@testdb$# begin pg12@testdb$# for i in (select 1 from dual) loop pg12@testdb$# select 2 into v_id from dual; pg12@testdb$# end loop;pg12@testdb$# return; pg12@testdb$# end;pg12@testdb$# $$LANGUAGE 'plpgsql';CREATE PROCEDURE [local:/data/run/pg12]: 5120 pg12@testdb=# [local:/data/run/pg12]: 5120 pg12@testdb=#
references
N/A
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.