首页 > 数据库 > Oracle > Global Variable in PL/SQL
create or replace package test_pkg as global_var number :=1; constant_var CONSTANT NUMBER := 2; end;
create table global_value ( x int ); insert into global_value values ( 0 ); create or replace package get_global as function val return number; procedure set_val( p_x in number ); end; / create or replace package body get_global as function val return number as l_x number; begin select x into l_x from global; return l_x; end; procedure set_val( p_x in number ) as pragma autonomous_transaction; begin update global set x = p_x; commit; end; end; /
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26687597/viewspace-1204842/ ,如需转载,请注明出处,否则将追究法律责任。