练习本
作者:互联网
create or replace procedure up_checkUserQueryPower is ssql VarChar2(4096);
iUserNum Integer;
n Integer;
sPower VarChar2(5);
tmpRC PK_VAR.RC;
TYPE T_UserPower IS VARRAY(13) OF VarChar2(5);
V_VAR T_UserPower := T_UserPower('610,'602','603','604','611','612','613','614','615','616','617','618','619');
BEGIN
ssql := 'Insert into TBBCUSERSYSPOWER(USERNUM,SYSPOWERCODE) Values(:Variant1;:Variant2)';
open tmpRC for select distinct UserNum from tbbcuser;
loop
Fetch tmpRC Into iUserNum;
exit when tmpRC% not found;
for i in 1 .. V_VAR.Count loop
sPower := V_VAR(i);
execute immediate ssql using iUserNum,sPower;
end loop;
end loop;
colse tmpRC;
Commit;
EXCEPTION WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN --Consider logging the error and then re-raise
RAISE;
END up_checkUserQueryPower;
一些参考链接:
Oracle中数组使用方法_ITPUB博客 (上面代码的出处)
oracle中is和as的区别 - 秦先生的客栈 - 博客园 (cnblogs.com) (is和as的区别)
Oracle数据库create or replace_毛兔记录:工作小技巧、遇到的一些典型bug、问题汇总、小知识。-CSDN博客 (有关create or repeat)
Oracle LOOP循环控制语句 - 阿郎 - 博客园 (cnblogs.com) (LOOP循环)
oracle中 =: 和 := 分别是什么意思 - 莱茵河的雨季 - 博客园 (cnblogs.com)
oracle中:=与=:的区别??_百度知道 (baidu.com) (这个更详细一些)
从C#将数组传递给Oracle过程(Passing array to Oracle procedure from C#)
region 定义数组类型和过程:
CREATE or replace PACKAGE Testpackage AS
TYPE Areas_t is table of VARCHAR(100) index by BINARY_INTEGER;
PROCEDUER TESTPROCEDURE(Areas IN Areas_t);
END Testpackage;
endregion
public void InsertQuestion(IEnumerable
{
var connect = new OracleConnection("YOUR CONNECTION STRINIG");
var command = new OracleCommand("BEGIN Testpackage.Testprocedure(:Areas);END;",connect);
connect.Open();
var arry = command.Parameters.Add("Areas",OracleDbType.Varchar2);
arry.Direction = ParameterDirection.Input;
arry.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
arry.Value = area_list.ToArray();
arry.Size = area_list.Count();
arry.ArrayBindSize = area_list.Select(_ => _.Length).ToArray();
arry.ArrayBindStatus = Enumerable.Repeat(OracleParameterStatus.Success,area_list.Count()).ToArray();
command.ExecuteNonQuery();
connect.Close();
}
标签:area,list,练习本,Oracle,com,arry,Areas 来源: https://www.cnblogs.com/Jane-share/p/15481053.html