如何实现proc中动态调用存储过程?

wang11912 2003-08-21 11:06:13
存储过程名作为参数,例子越详细越好,谢谢帮忙!
...全文
205 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang11912 2003-09-02
  • 打赏
  • 举报
回复
还不是没有人愿意回答,不要太客气噢
wang11912 2003-09-01
  • 打赏
  • 举报
回复
没人愿意回答吗
kazy0514 2003-09-01
  • 打赏
  • 举报
回复
楼主,不好意思借用一下地方,各位知道怎么用pro*c将数据插入oracle中类型为blob的列中吗?我找了好多资料都没有结果,也在csdn上发了贴,可是没人回答,看楼主您这个帖子人多,想问一下大家,实在太急用了,抱歉!!
sun9989 2003-08-25
  • 打赏
  • 举报
回复
好像是ORACLE的DEMO
wang11912 2003-08-25
  • 打赏
  • 举报
回复
我仔细看了看,上面的例子好像没有动态调用PROCEDURE,我说的动态调用是指PROCEDURE的名称是不确定的,PROCEDURE名称是个参数,不知如何实现
wang11912 2003-08-24
  • 打赏
  • 举报
回复
有人知道吗?我需要的是unix 下proc的例子
Paul_Ni 2003-08-24
  • 打赏
  • 举报
回复
同意,上面的例子写得很好,将PROC中如何调用PROCEDURE的要点写的很清楚。
请你好好看一下。
如果有不明白的地方,请给我写信。
nirj@ideal.sh.cn
klbt 2003-08-23
  • 打赏
  • 举报
回复
超长的回复。
wang11912 2003-08-22
  • 打赏
  • 举报
回复
help
Virtuoso 2003-08-22
  • 打赏
  • 举报
回复
/*cppdemo2.pc*/

// Pro*C/C++ sample program demonstrating a simple use of Cursor Variables
// implemented within a C++ class framework. Build this program as follows
//
// 1. Execute the cppdemo2.sql script within SQL*Plus
// 2. Precompile the empclass.pc program as follows
// > proc code=cpp sqlcheck=full user=scott/tiger lines=yes empclass
// 3. Precompile the cppdemo2.pc program as follows
// > proc code=cpp lines=yes cppdemo2
// 4. Compile and Link
//
// Note that you may have to specify various include directories using the
// include option when precompiling.

#include <stdio.h>
#include <stdlib.h>
#include <sqlca.h>

static void sql_error()
{
printf("%.*s\n", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc);
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
}

// Physically include the emp class definition in this module.
EXEC SQL INCLUDE empclass.h;

int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char *uid = "scott/tiger";
EXEC SQL END DECLARE SECTION;

EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL CONNECT :uid;

emp *e = new emp(); // Invoke Constructor - ALLOCATE Cursor Variable.

e->open(); // Open the Cursor.

while (1)
{
// Fetch from the Cursor, catching the NOT FOUND condition
// thrown by the fetch() member function.
try { e->fetch(); } catch (int code)
{ if (code == 1403) break; }
printf("Employee: %s[%d]\n", e->ename, e->empno);
}

e->close(); // Close the Cursor.

delete e; // Invoke Destructor - FREE Cursor Variable.

EXEC SQL ROLLBACK WORK RELEASE;
return (0);
}


/*empclass.pc*/



#include <stdio.h>
#include <stdlib.h>

// This example uses a single (global) SQLCA that is shared by the
// emp class implementation as well as the main program for this
// application.
#define SQLCA_STORAGE_CLASS extern
#include <sqlca.h>

// Include the emp class specification in the implementation of the
// class body as well as the application program that makes use of it.
EXEC SQL INCLUDE empclass.h;

emp::emp()
{
// The scope of this WHENEVER statement spans the entire module.
// Note that the error handler function is really a member function
// of the emp class.
EXEC SQL WHENEVER SQLERROR DO emp_error();
EXEC SQL ALLOCATE :emp_cursor; // Constructor - ALLOCATE Cursor.
}

emp::~emp()
{
EXEC SQL FREE :emp_cursor; // Destructor - FREE Cursor.
}

void emp::open()
{
EXEC SQL EXECUTE
BEGIN
emp_package.open_cursor(:emp_cursor);
END;
END-EXEC;
}

void emp::close()
{
EXEC SQL CLOSE :emp_cursor;
}

void emp::fetch() throw (int)
{
EXEC SQL FETCH :emp_cursor INTO :ename, :empno;
if (sqlca.sqlcode == 1403)
throw sqlca.sqlcode; // Like a WHENEVER NOT FOUND statement.
}

void emp::emp_error()
{
printf("%.*s\n", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc);
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
}

/*cppdemo.sql*/


Rem This is the SQL script that accompanies the cppdemo2 C++ Demo
Rem Program. Run this prior to Precompiling the empclass.pc file.
/
CONNECT SCOTT/TIGER
/
CREATE OR REPLACE VIEW emp_view AS SELECT ename, empno FROM EMP
/
CREATE OR REPLACE PACKAGE emp_package AS
TYPE emp_cursor_type IS REF CURSOR RETURN emp_view%ROWTYPE;
PROCEDURE open_cursor(curs IN OUT emp_cursor_type);
END emp_package;
/
CREATE OR REPLACE PACKAGE BODY emp_package AS
PROCEDURE open_cursor(curs IN OUT emp_cursor_type) IS
BEGIN
OPEN curs FOR SELECT ename, empno FROM EMP ORDER BY ename ASC;
END;
END emp_package;
/
EXIT
/

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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