请问在pb8下如何取得oracle8i下存储过程中的游标?

philozz 2002-10-06 09:17:34
在ORACLE中对表hlprt进行查询,需要提取的列信息很多,
想通过以DECLARE PROCEDURE语句声明存储过程来获取记录(Recorder)的传递

例如在oracle下定义了一个存储过程
create or replace procedure proc_query_hlprt(
p_code in hlprt.author_code%type) as
begin
select * from hlprt where author_code=p_code;
end proc_query_hlprt;

在pb中
string lc_p_code
lc_p_code="010100001"
DECLARE proc_query_hlprt PROCEDURE FOR proc_query_hlprt(:lc_p_code);
EXECUTE proc_query_hlprt;

FETCH proc_query_hlprt INTO ???
如何获得存储过程proc_query_hlprt中的游标???

请各位大侠指教
谢谢

...全文
41 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
philozz 2002-10-06
  • 打赏
  • 举报
回复
多谢balloonman2002关注。
因为提取的列信息比较多[大约有几十个],所以不想用这种办法。
能否直接获取oracle存储过程中的cursor?
balloonman2002 2002-10-06
  • 打赏
  • 举报
回复
PB帮助:(SYBASE)

In addition to result sets, Sybase Systems 10.x and 11.x stored procedures may return a long integer return value and output parameters of any data type. After all of the result sets have been returned, PowerScript requires you to issue one final FETCH procedure_name INTO . . . statement to obtain these values. The order in which these values are returned is:

return value, output parm1, output parm2, ...

Example 1

The following stored procedure contains one input parameter (@deptno) and returns a result set containing employee names and salaries for that department. It also returns two output parameters (@totsal and @avgsal), and a return value that is the count of employees in the department.

CREATE PROCEDURE deptroster @deptno integer,

@totsal double precision output,
@avgsal double precision output

AS

DECLARE @number_of_emps integer
SELECT emp_fname, emp_lname, salary FROM employee
WHERE dept_id = @deptno
SELECT @totsal = sum(salary),
@avgsal = avg(salary),
@number_of_emps = COUNT(*) FROM employee
WHERE dept_id = @deptno
RETURN @number_of_emps;

Example 2

The following PowerScript code fragment declares and executes the deptroster stored procedure, processes the result set, and then fetches the return value and output parameters.

integer fetchcount = 0

long lDeptno, rc
string fname, lname
double dSalary, dTotSal, dAvgSal

lDeptno = 100

DECLARE deptproc PROCEDURE FOR
@rc = dbo.deptroster
@deptno = :lDeptno,
@totsal = 0 output,
@avgsal = 0 output
USING SQLCA;

EXECUTE deptproc;

CHOOSE CASE SQLCA.sqlcode
CASE 0
// Execute successful. There is at least one
// result set. Loop to get the query result set
// from the table SELECT.
DO
FETCH deptproc INTO :fname, :lname, :dSalary;
CHOOSE CASE SQLCA.sqlcode
CASE 0
fetchcount++
CASE 100
MessageBox ("End of Result Set", &
string (fetchcount) " rows fetched")
CASE -1
MessageBox ("Fetch Failed", &
string (SQLCA.sqldbcode) " = " &

SQLCA.sqlerrtext)
END CHOOSE
LOOP WHILE SQLCA.sqlcode = 0

// Issue an extra FETCH to get the Return Value

// and Output Parameters.
FETCH deptproc INTO :rc, :dTotSal, :dAvgSal;
CHOOSE CASE SQLCA.sqlcode
CASE 0
MessageBox ("Fetch Return Value and Output" &
"Parms SUCCESSFUL", "Return Value is: " &
string (rc) &
"~r~nTotal Salary: " string (dTotSal) &
"~r~nAverage Sal: " string (dAvgSal))
CASE 100
MessageBox ("Return Value and Output Parms" &
"NOT FOUND", "")
CASE ELSE
MessageBox ("Fetch Return Value and Output" &

"Parms FAILED", "SQLDBCode is " &
string (SQLCA.sqldbcode) " = " &
SQLCA.sqlerrtext)
END CHOOSE

CLOSE deptproc;
CASE 100

// Execute successful; no result set.
// Do not try to close.
MessageBox ("Execute Successful", "No result set")

CASE ELSE

MessageBox ("Execute Failed", &
string (SQLCA.sqldbcode) " = " &
SQLCA.sqlerrtext)

END CHOOSE

1,079

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧