dear all
我用OracleDataReader 想到後端oracle資料庫執行幾個sql並在最後用select讀取資料到前端來,
請問那一串sql該如何寫..(在mssql寫過類似的很簡單,但在oracle不知道怎麼寫)
感恩!!感恩!!
程式大約如下..
using dbcoon as OracleConnection = new OracleConnection(my_oracleConstr)
using dbcommand as OracleCommand = new OracleCommand
with dbcommand
.Connection = dbcoon
.CommandType = CommandType.Text
.CommandtText = CreateSqlStr()
using dr as OracleDataReader = dbcommand.ExecuteReader()
.....
end using
end with
end using
end using
public function CreateSqlStr() AS STRING
CreateSqlStr = "declare"
CreateSqlStr &= " v_power varchar2(10):='supper';"
CreateSqlStr &= "begin"
CreateSqlStr &= "
delete tmptable where user_id='user1';"
CreateSqlStr &= "
insert into tmptable value ('user1',todate(today));"
CreateSqlStr &= "
select * from tmptable order by user_id;"
CreateSqlStr &= "end;"
end function
微軟報表產生器呼叫ORACLE 上的PROCEDURE 操作手冊
3.2 建立Oracle 上的Procedure
CREATE OR REPLACE PROCEDURE ARGOERP.sp_getemployees (
e_recordset OUT SYS_REFCURSOR)
IS
BEGIN
OPEN e_recordset FOR SELECT * FROM personnel;
END sp_getemployees;
/
其中 OUT SYS_REFCURSOR 是重點,在 Oracle 中讓你把資料集傳給前端,這樣就完成基本的procedure程式。