Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 我可以从函数或过程中访问和更改变量吗?_Sql_Plsql_Sql Function - Fatal编程技术网

Sql 我可以从函数或过程中访问和更改变量吗?

Sql 我可以从函数或过程中访问和更改变量吗?,sql,plsql,sql-function,Sql,Plsql,Sql Function,我想创建一个简单的过程,如下所示: create or replace PROCEDURE testprozedur (pCondition In Number) IS BEGIN If (pCondition != 0) Then test_counter := test_counter + 1; End If; END testprozedur; 并从pl/sql语句中访问此过程。此声明可能如下所示: declare my_var1 number; my_var2 num

我想创建一个简单的过程,如下所示:

create or replace PROCEDURE testprozedur (pCondition In Number) IS
BEGIN
  If (pCondition != 0) Then test_counter := test_counter + 1;
      End If;
END testprozedur;
并从pl/sql语句中访问此过程。此声明可能如下所示:

declare

my_var1 number;
my_var2 number;

begin         

select count(*) into my_var1 from table_1;
select count(*) into my_var2 from table_2;

exec testprozedur(my_var1 - my_var2);
end;

我尝试为变量“test_counter”创建一个包,但没有成功。有什么办法可以实现我在这里的目标吗?

你说的“没有成功”是什么意思?为什么您认为您需要
测试计数器
变量?它是指在一个会话中增加还是在所有会话中增加?SQL开发人员说“test_counter”不能位于等号的左侧。这个变量将一直增加,直到我再次将它定义为零。对我来说可以吗@博奈斯特:你说得对。可能是因为我没有在包中定义test_counter为零。无论如何,谢谢你!