LINUX.ORG.RU

ORACLE+C


0

0

Privet vsem. Rebiata, kak mne v ORACLE 9I SQL zaprosi posilat' iz C? Esli ODBC to kakaia versia? Esli mogno kakie-nit' primeri v C. Zaranee blagodaren. Tolik.

Re: ORACLE+C

В пелотку ODBC. Юзай OCI. Или, если ты извращенец и тебя мама часто и со вкусом порола розгами (и тебе это нравилось), то юзай Pro*C. Но только не ODBC! ODBC - для некропедозоофилов, а мы ведь просто приличные, культурные садомазо.

anonymous ()

Re: ORACLE+C

У оракла есть хорошая дока на эту тему. Understanding the Oracle Programmatic Environments

SatanClaus ★★★ ()
Ответ на: Re: ORACLE+C от SatanClaus

Re: ORACLE+C

> Примеры должны быть в самом оракле

$ORACLE_HOME/rdbms/demo/ - там же лежат include'ы

no-dashi ★★★★★ ()

Re: ORACLE+C

/***************************************************************************
 *   Copyright (C) 2005 by pvsur   *
 *   pvsur@mail.ru   *
 *                                                                         *
***************************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "commondefs.h"

//#define OTL_ORA7 // Compile OTL 4.0/OCI7
//#define OTL_ORA8 // Compile OTL 4.0/OCI8
//#define OTL_ORA8I // Compile OTL 4.0/OCI8i
#define OTL_ORA9I // Compile OTL 4.0/OCI9i
//#define OTL_ORA10G // Compile OTL 4.0/OCI10g
#define OTL_STREAM_READ_ITERATOR_ON
#include <otlv4.h>

#include "dbmodule.h"
#include "requests.h"
#include "logprocess.h"
#include <assert.h>
using namespace std;
otl_connect db; // connect object
otl_stream *pi, *pi2;
char ConnectString[SUR_MAX_LINE_SIZE];


bool OpenDatabase()
{
  try
  {
    otl_connect::otl_initialize(); // initialize OCI environment
    db.rlogon(ConnectString); // connect to Oracle
    pi = new otl_stream (1, // buffer size
                         "begin "
                         " bill.PROC_TCS_ADDSUM_EPORT ( "
                         "   :cardid<int,in>, "
                         "   :summ<float,in>, "
                         "   :id<int,in>, "
                         "   :hash_param<int,in>, "
                         "   :testMode<int,in>, "
                         "	 :txtreq<char[2048],in>,"
                         "   :result_<float,out> "
                         "   ); "
                         " end; ",


                         db // connect object
                        );

    pi2 = new otl_stream (1, // buffer size
                          "select a.card_state_id "
                          " from tcs.tcs_cards a "
                          "where a.card_id = :cardid<int,in>",
                          db // connect object
                         );
    LogMessage(LOG_INFO,"%s","Database opened !");
  }
  catch(otl_exception& p)
  { // intercept OTL exceptions
    /*    cerr<<p.msg<<endl; // print out error message
        cerr<<p.stm_text<<endl; // print out SQL that caused the error
        cerr<<p.var_info<<endl; // print out the variable that caused the error*/
    LogMessage(LOG_ERR,"%s %s %s","error in execute oracle procedure AddSumm !\n", p.msg, p.stm_text);
    db.logoff(); // disconnect from Oracle
    return false;
  }
  return true;
};

bool CloseDatabase()
{
  db.logoff(); // disconnect from Oracle
  return true;
}

TWorkReqErrorCodes ExecAddSumm(int card_id, int card_kc_id, double summ, int id, int hash_param, bool testMode, char* req_txt)
{
  float result_ = -1;
  //  sleep(2);
/*    LogMessage(LOG_INFO,"id = %d",( id));
    LogMessage(LOG_INFO,"hash_param = %d",(hash_param));
    LogMessage(LOG_INFO,"card_id = %d",(card_id));*/
 
  try
  {
    *pi << (card_id) << (float)summ << ( id) << ( hash_param) << ((testMode ? 1:0))<<req_txt;

    //    i.flush();

    *pi >> result_;
    LogMessage(LOG_INFO,"retcode AddSumm1 = %d",(int)result_);

  }
  catch(otl_exception& p)
  { // intercept OTL exceptions
    /*    cerr<<p.msg<<endl; // print out error message
        cerr<<p.stm_text<<endl; // print out SQL that caused the error
        cerr<<p.var_info<<endl; // print out the variable that caused the error*/
    LogMessage(LOG_ERR,"%s %s %s","error in execute oracle procedure AddSumm !", p.msg, p.stm_text);
    result_ = -6;
  }

  LogMessage(LOG_INFO,"retcode AddSumm2 = %d",(int)result_);

  switch ( (int)result_ )
  {
  case 0: return wrSucces;  						// successfull execution
  case -1: return wrCardNotOperable;		// generic error
  case -2: return wrBadRequest;					// bad valute param
  case -3: return wrCardNotOperable;		// not exists money
  case -4: return wrAlreadyExecuted;
  case -5: return wrDublicateRequest;
  case -6: return wrServerUnavailable;
  case -7: return wrCardNotFound;

  default: assert(false);								// ??!!??
  };

};

sur02111976 ()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.