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

📄 oracle.h

📁 oracle oci 轻量级封装库,很方便和实用!适合于简单的数据库操作.绝对精品.垃圾就不上传了.
💻 H
字号:
/*
 * Header: oracle.h,v 1.0 2000/7/20 lhj  
 */

/*
   NAME
     oracle.h - header file for Oracle Call Interface Program
   MODIFIED   (MM/DD/YY)
    lhj      7/20/2000   
*/

#ifndef _ORCALE_H
#define _ORCALE_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oci.h>
#include <ocidem.h>


/* oparse flags */
#define  DEFER_PARSE			1
#define  NATIVE					1
#define  VERSION_7				2


/* Class forward declarations */
class connection;
class cursor;

/*
 * This class represents a connection to ORACLE database.
 *
 * NOTE: This connection class is just given as an example and all possible
 *       operations on a connection have not been defined.
 */
class connection
{
  friend class cursor;
  public:
    connection() 
      { state = not_connected; memset(hda,'\0', HDA_SIZE); }
    ~connection();
    sword connect(text *user, text *pass,text *service);
    sword disconnect();
    void display_error(FILE* file) const;
  private:
    Lda_Def lda;
    ub1 hda[HDA_SIZE];
    enum conn_state
    {
      not_connected,
      connected
    };
    conn_state state;
};

/*
 * This class represents an ORACLE cursor.
 *
 * NOTE: This cursor class is just given as an example and all possible
 *       operations on a cursor have not been defined.
 */
class cursor
{
  public:
    cursor() 
      {state = not_opened; conn = (connection *)0; }
    ~cursor();
    sword open(connection *conn_param);
    sword close();
    sword parse(const text *stmt)
      { return (oparse(&cda, (text *)stmt, (sb4)-1, 
		       DEFER_PARSE, (ub4) VERSION_7)); }
	/*  Describe select-list items. */
	sword describe();

    sword execute()
      { return (oexec(&cda)); }
    sword fetch()
      { return (ofetch(&cda)); }
	sword fetch_data(RecordSet* pSet);

    sword get_error_code() const
      { return (cda.rc); }
    void display_error( FILE* file) const;
	void print_header(sword ncols);
	void print_rows(sword ncols);
	sword getrows(){return cda.rpc;};
	sword getfunction(){return cda.ft;};
  private:
    Cda_Def cda;
    connection *conn;
    enum cursor_state
    {
      not_opened,
      opened
    };
    cursor_state state;

	/* Define arrays of describe and define structs. */

	struct _cs_datefmt desc[MAX_SELECT_LIST_SIZE];
	struct _column_data   def[MAX_SELECT_LIST_SIZE];
 public:
	sword sql_function;
};

sword execute_cmd(connection conn,cursor crsr,char* sql,RecordSet* pSet);
sword execute_cmd(connection conn,cursor crsr,char* sql);

/*
 * Error number macros
 */
#define CONERR_ALRCON -1 			        /* already connected */ 
#define CONERR_NOTCON -2 			            /* not connected */ 
#define CURERR_ALROPN -3 			   /* cursor is already open */
#define CURERR_NOTOPN -4 			     /* cursor is not opened */

#endif

⌨️ 快捷键说明

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