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

📄 ex13.c

📁 Linux下的操作oracle数据库的连接库
💻 C
字号:
/* $Id: ex13.c,v 1.6 2004/01/03 16:48:19 kpoitschke Exp $ */#include <stdio.h>#include <stdlib.h>#include "examples.h"int insert_into_blob_table(sqlo_db_handle_t dbh, int key ){  char * stmt =     "INSERT INTO T_SQLORA_BLOB (KEY, CDATA) "    "VALUES (:b1, EMPTY_CLOB()) RETURNING CDATA INTO :b2";  char data[MAX_BLOB_BUFFER_DATA];        /* a data buffer */  sqlo_lob_desc_t loblp;                  /* the lob locator */  sqlo_stmt_handle_t sth;  int status;  int k = key;  printf("Insert CLOB\n");  /* create the test table */  create_blob_table(dbh);  /* fill the data buffer with some characters */  fillbuf(data, MAX_BLOB_BUFFER_DATA);  /* parse the statement */  if (0>(sth = sqlo_prepare(dbh, stmt)))    error_exit(dbh, "sqlo_prepare");  /* alloate the lob descriptor */  if (0 > sqlo_alloc_lob_desc(dbh, &loblp))    error_exit(dbh, "sqlo_alloc_lob_desc");  /* bind input variables. Note: we bind the lob descriptor here */  if (SQLO_SUCCESS !=       (sqlo_bind_by_pos(sth, 1, SQLOT_INT, &k, sizeof(int), NULL, 0)) ||      (sqlo_bind_by_pos(sth, 2, SQLOT_CLOB, &loblp, 0, NULL, 0))      ) {    sqlo_free_lob_desc(dbh, &loblp);    error_exit(dbh, "sqlo_bind_by_pos");  }  /* execute the statement */  status = sqlo_execute(sth, 1);  if (SQLO_SUCCESS != status) {    sqlo_free_lob_desc(dbh, &loblp);    error_exit(dbh, "sqlo_execute");  }  /* write the lob */  status = sqlo_lob_write_buffer(dbh, loblp, MAX_BLOB_BUFFER_DATA, data,                                  MAX_BLOB_BUFFER_DATA, SQLO_ONE_PIECE);  if (status < 0) {    sqlo_free_lob_desc(dbh, &loblp);    error_exit(dbh, "sqlo_log_write_buffer");  }  sqlo_free_lob_desc(dbh, &loblp);  sqlo_close(sth);    return (1);}void create_blob_table(sqlo_db_handle_t dbh){  char * stmt=    "CREATE TABLE T_SQLORA_BLOB (KEY INTEGER, CDATA CLOB, BDATA BLOB)";  if (SQLO_SUCCESS != sqlo_exec(dbh, stmt))    if (sqlo_geterrcode(dbh) != 955) /* table exists already */      error_exit(dbh, "sqlo_exec");}void drop_blob_table(sqlo_db_handle_t dbh){  char * stmt = "DROP TABLE T_SQLORA_BLOB";  if (SQLO_SUCCESS != sqlo_exec(dbh, stmt))    error_exit(dbh, "sqlo_exec");}void fillbuf(char * data, int len){  int i;  for (i = 0; i < len; ++i) {    data[i] = 'A' + i % 26;  }}/* $Id */

⌨️ 快捷键说明

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