- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想用存储过程“spValidateDBA”中的 refcursor 参数 UserRole 的值填充数据表,但它每次都给我这个错误:
Column 'UserRole' does not belong to table.
C# 代码:-
string sConnectionString = "Data Source=XE;User ID=sys;Password=system;DBA PRIVILEGE=sysdba";
OracleConnection myConnection = new OracleConnection(sConnectionString);
OracleCommand myCommand = new OracleCommand("spValidateDBA", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.CommandText = "spValidateDBA";
myCommand.Parameters.Add("UserId", OracleDbType.Varchar2, 50);
myCommand.Parameters["UserId"].Value = txtUsrId.Text.ToString().ToUpper();
myCommand.Parameters.Add("UserRole",OracleDbType.RefCursor, 50).Direction = ParameterDirection.Output;
myCommand.Parameters.Add("UserIdOut", OracleDbType.Varchar2, 50).Direction = ParameterDirection.Output;
var rolechk = false;
string checkrole = "DBA";
myConnection.Open();
myCommand.ExecuteReader();
// Create the OracleDataAdapter
OracleDataAdapter da = new OracleDataAdapter(myCommand);
DataTable dt = new DataTable();
da.Fill(dt); // Trying to populate a DataTable with refcursor UserRole.
if (myCommand.Parameters["UserIdOut"].Value.ToString().ToUpper() == txtUsrId.Text.ToString().ToUpper())
{
CustomMsgbox.Show("1", "DB Utilities Tool", "OK", "Cancel");
foreach (DataRow dr in dt.Rows)
{
if (dr["UserRole"].ToString().ToUpper().Equals(checkrole)==true)//getting the error "Column 'UserRole' does not belong to table." here
{
CustomMsgbox.Show("\tLogin Successful..!!\t" + Environment.NewLine + "Welcome to DB Utilities Tool", "DB Utilities Tool", "OK", "Cancel");
DBA dba = new DBA();
dba.Show();
this.Hide();
rolechk = true;
break;
}
}
if (!rolechk)
{
CustomMsgbox.Show("Insufficient privileges", "DB Utilities Tool", "OK", "Cancel");
myConnection.Close();
}
else
CustomMsgbox.Show("Please enter correct User ID/Password", "DB Utilities Tool", "OK", "Cancel");
}
存储过程 spValidateDBA
create or replace PROCEDURE spValidateDBA(
UserId IN VARCHAR2,
UserRole OUT SYS_REFCURSOR,
UserIdOut OUT VARCHAR2)
AS
BEGIN
select USERNAME into UserIdOut from DBA_USERS DU where DU.USERNAME=UserId;
OPEN UserRole FOR
select GRANTED_ROLE from DBA_USERS DU,DBA_ROLE_PRIVS DRP where DU.USERNAME=UserId AND DU.USERNAME=DRP.GRANTEE;
END spValidateDBA;
最佳答案
您在游标查询中仅检索一列 GRANTED_ROLE
:
OPEN UserRole FOR select GRANTED_ROLE from DBA_USERS DU, .......
但是您正在尝试从游标中获取 UserRole
列。
if (dr["UserRole"].ToString().ToUp.........
那里没有任何名为 UserRole
的列,您只能获取 GRANTED_ROLE
。
关于c# - 使用来自 Oracle 存储过程的 refcursor 值填充 C# 数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23179350/
我是 pl/SQL 新手,请帮我创建一个过程! 场景:我有类别和子类别,每个类别和子类别都有一个描述。我希望该过程返回一个 refcursor ,其中包含包含 level1 菜单列表的对象列表,然后是
我有一个程序可以让我得到带 refcursor 的输出,游标中的数据/结构将是动态的。每次根据输入数据类型和游标中的列数都会有所不同。那么我该如何访问这个结构并获取数据类型呢? PROCEDURE
我有一个简单的函数,在其中运行一个返回 RefCursor 的存储过程,并尝试使用该 RefCursor 将数据插入到临时表中。尝试这样做时出现以下错误: SQL 错误:ORA-00947:值不足 我
来自 calling a stored proc over a dblink 的答案如果通过远程数据库链接进行 SP 调用,似乎无法调用存储过程并取回 ResultSet/RefCursor。我们也在
我一直在调用在我的 C# 应用程序中返回 RefCursors 的 Oracle 存储过程。下面给出了示例存储过程。 CREATE OR REPLACE PROCEDURE "DOSOMETHING"
继续a previous case ,其中创建并执行了一个动态 SELECT 查询 that uses refcursor - 我想问以下问题:我们从指定过程中获得的所需输出被输出到 DataOutp
我正在使用 Postgresql 8.3 并具有以下简单函数,该函数会将 refcursor 返回给客户端 CREATE OR REPLACE FUNCTION function_1() RETURN
我有一个 oracle 存储函数,它返回 sys_refcursor 作为输出参数。它的结构类似于 对象 参数1 参数2 参数3 param4_list(光标) 我想使用 C# 将 param1-3
我使用 PostgreSQL 使用以下结构存储函数: create or replace function myfunc() returns refcursor as $$ declare rc re
我不知道如何在 PostgreSQL 上使用 Refcursor 变量的值来获取 FETCH。 查看the reffunc2() example from here ,具体如下: CREATE FUN
我在 Postgresql 中有一个基本的用户表, CREATE TABLE myuser ( userId bigserial primary key, user_name varchar(3
我正在寻找有关如何在 SQL Developer 或 Embarcardero Rapid XE2 中测试 Oracle 存储过程的良好解释。谢谢。 最佳答案 类似于 create or replac
我需要创建一个交互式报告,但我需要运行 pl/sql 语句而不是运行 sql 语句 ----------------------------------------------------------
我正在使用 Postgresql 并具有将 refcursor 返回给客户端的简单函数: CREATE OR REPLACE FUNCTION select_user(cur refcursor, m
我的函数如下 CREATE OR REPLACE FUNCTION get_history(refcursor, encounterid integer, patientid integer) RET
-- FUNCTION: public.asyncmultiplerecs() -- DROP FUNCTION public.asyncmultiplerecs(); CREATE OR REPLA
我想测试 Postgres 函数的结果(不可能更改函数)。 该函数接收一个 REFCURSOR 和其他一些东西作为参数,并返回相同的 RECURSOR。 get_function_that_retur
作为问题的后续 "Get resultset from oracle stored procedure" ,有没有办法显示返回 REFCURSOR 的存储过程的结果?在 SQL Developer 的
我有这个: Postgres /*THE PARAMETER in_test_id IS ONLY A TEST!!*/ CREATE OR REPLACE FUNCTION public.test_
我知道以下是可能的。即我可以在 Postgresql 中将引用游标作为返回值。 CREATE FUNCTION employeefunc(int) RETURNS refcursor AS ' DEC
我是一名优秀的程序员,十分优秀!