⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex9.c

📁 Linux下的操作oracle数据库的连接库
💻 C
字号:
/* $Id: ex9.c,v 1.5 2002/08/24 12:54:47 kpoitschke Exp $ */#include <stdio.h>#include <stdlib.h>#include "examples.h"static void create_sp __P((sqlo_db_handle_t dbh));int call_plsql(sqlo_db_handle_t dbh){  double ip1;  int  ip2;  char op[80];  sqlo_stmt_handle_t sth = SQLO_STH_INIT;  /* the stored procecdure call */  char * stmt =     "BEGIN\n"    "    EX9(:ip1, :ip2, :op);\n"    "END;\n";  create_sp(dbh);               /* create the test stored procedure */  ip1 = 1.5;  ip2 = 20;  /* parse the statement */  if ( 0 <= (sth = sqlo_prepare(dbh, stmt))) {    /* bind all variables */    if (SQLO_SUCCESS !=         (sqlo_bind_by_name(sth, ":ip1", SQLOT_FLT, &ip1, sizeof(ip1), 0, 0) ||         sqlo_bind_by_name(sth, ":ip2", SQLOT_INT, &ip2, sizeof(ip2), 0, 0) ||         sqlo_bind_by_name(sth, ":op", SQLOT_STR, &op, sizeof(op), 0, 0)         )) {      error_exit(dbh, "sqlo_bind_by_name");    } else {      /* execute the call */      if (SQLO_SUCCESS != sqlo_execute(sth, 1))        error_exit(dbh, "sqlo_execute");    }    /* print the result */    if (atof(op) != (ip1 + ip2))      printf("Stored procudure returned wrong result %s, expected %6.2f\n",             op, (ip1 + ip2));    if (SQLO_SUCCESS != sqlo_close(sth))      error_exit(dbh, "sqlo_execute");  } else {    error_exit(dbh, "sqlo_prepare");  }  if ( 0 > sqlo_exec(dbh, "DROP PROCEDURE EX9"))    error_exit(dbh, "sqlo_exec");  return 1;}/* creates the stored procedure used above */static voidcreate_sp(sqlo_db_handle_t dbh){  char * stmt =    "CREATE OR REPLACE PROCEDURE EX9(ipNum1 IN NUMBER, ipNum2 IN NUMBER, opStr OUT VARCHAR)\n"    "IS\n"    "BEGIN\n"    "  opStr := TO_CHAR(ipNum1 + ipNum2);\n"    "END;\n";  if (SQLO_SUCCESS != sqlo_exec(dbh, stmt))    error_exit(dbh, stmt);}/* $Id: ex9.c,v 1.5 2002/08/24 12:54:47 kpoitschke Exp $ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -