📄 otlv4.h
字号:
#define otl_error_msg_1 "No input variables have been defined in SQL statement"
const int otl_error_code_2=32003;
#define otl_error_msg_2 "Not all input variables have been initialized"
const int otl_error_code_3=32001;
#define otl_error_msg_3 "Row must be full for flushing output stream"
const int otl_error_code_4=32005;
#define otl_error_msg_4 "Input string value is too large to fit into the buffer"
const int otl_error_code_5=32006;
#define otl_error_msg_5 "Input otl_long_string is too large to fit into the buffer"
const int otl_error_code_6=32007;
#define otl_error_msg_6 "PL/SQL table size is too large (>32767)"
const int otl_error_code_7=32008;
#define otl_error_msg_7 "Writing CLOB/BLOB in stream mode: actual size is greater than specified"
const int otl_error_code_8=32009;
#define otl_error_msg_8 "Closing CLOB/BLOB in stream mode: actual size is not equal to specified size"
const int otl_error_code_9=32010;
#define otl_error_msg_9 "CLOB/BLOB stream is not open for writing"
const int otl_error_code_10=32011;
#define otl_error_msg_10 "CLOB/BLOB stream is not open for reading"
const int otl_error_code_11=32012;
#define otl_error_msg_11 "First session must be started with session_begin()"
const int otl_error_code_12=32013;
#define otl_error_msg_12 "Invalid bind variable declaration"
const int otl_error_code_13=32014;
#define otl_error_msg_13 "No stored procedure was found"
const int otl_error_code_14=32015;
#define otl_error_msg_14 "Unsupported data type: "
const int otl_error_code_15=32016;
#define otl_error_msg_15 "Unsupported procedure type"
const int otl_error_code_16=32017;
#define otl_error_msg_16 "Stream buffer size can't be > 1 in this case"
const int otl_error_code_17=32018;
#define otl_error_msg_17 \
"ODBC / DB2 CLI function name is not recognized. " \
"It should be one of the following: SQLTables, SQLColumns, " \
"SQLProcedures, SQLColumnPrivileges, SQLTablePrivileges, " \
"SQLPrimaryKeys, SQLProcedureColumns, SQLForeignKeys"
const int otl_error_code_18=32019;
#define otl_error_msg_18 \
"otl_stream::operator>>() should have been called " \
"before otl_stream::operator int()"
const int otl_error_code_19=32020;
#define otl_error_msg_19 \
"otl_stream_read_iterator: otl_stream is not open"
const int otl_error_code_20=32021;
#define otl_error_msg_20 \
"otl_stream_read_iterator: PL/SQL table and 'refcur' " \
"parameters are not supported"
const int otl_error_code_21=32022;
#define otl_error_msg_21 \
"otl_stream_read_iterator: otl_stream cannot be described"
const int otl_error_code_22=32023;
#define otl_error_msg_22 \
"otl_stream_read_iterator: position is out of range"
const int otl_error_code_23=32024;
#define otl_error_msg_23 \
"otl_stream_read_iterator: incompatible types in get()"
const int otl_error_code_24=32025;
#define otl_error_msg_24 \
"otl_stream::operator int() is not supported in the LOB stream mode"
const int otl_error_code_25=32026;
#define otl_error_msg_25 \
"otl_stream_read_iterator: get(otl_lob_stream*&) function " \
"can only be used if otl_stream::set_lob_stream_mode(true) had been called " \
"before the iterator was attached to the stream"
const int otl_error_code_26=32027;
#define otl_error_msg_26 \
"otl_stream_read_iterator: variable name is not recognized "
const int otl_error_code_27=32028;
#define otl_error_msg_27 "Unsupported column data type"
const int otl_oracle_date_size=7;
const int otl_explicit_select=0;
const int otl_implicit_select=1;
const int otl_input_param=0;
const int otl_output_param=1;
const int otl_inout_param=2;
const unsigned int otl_all_num2str=1;
const unsigned int otl_all_date2str=2;
const int otl_num_str_size=60;
const int otl_date_str_size=60;
class otl_select_struct_override{
public:
short int* col_ndx;
short int* col_type;
int* col_size;
int len;
unsigned int all_mask;
bool lob_stream_mode;
otl_select_struct_override()
{
container_size_=otl_var_list_size;
col_ndx=new short int[container_size_];
col_type=new short int[container_size_];
col_size=new int[container_size_];
reset();
}
void reset(void)
{
len=0;
all_mask=0;
lob_stream_mode=false;
}
~otl_select_struct_override()
{
delete[] col_ndx;
delete[] col_type;
delete[] col_size;
}
void add_override(const int andx, const int atype, const int asize=0)
{
if(len==otl_var_list_size){
int temp_container_size=container_size_;
container_size_*=2;
short int* temp_col_ndx=new short int[container_size_];
short int* temp_col_type=new short int[container_size_];
int* temp_col_size=new int[container_size_];
memcpy(temp_col_ndx,col_ndx,sizeof(short int)*temp_container_size);
memcpy(temp_col_type,col_type,sizeof(short int)*temp_container_size);
memcpy(temp_col_size,col_size,sizeof(int)*temp_container_size);
delete[] col_ndx;
delete[] col_type;
delete[] col_size;
col_ndx=temp_col_ndx;
col_type=temp_col_type;
col_size=temp_col_size;
}
++len;
col_ndx[len-1]=OTL_SCAST(short,andx);
col_type[len-1]=OTL_SCAST(short,atype);
col_size[len-1]=asize;
}
int find(const int ndx)
{
int i;
for(i=0;i<len;++i)
if(ndx==col_ndx[i])
return i;
return -1;
}
void set_all_column_types(const unsigned int amask=0)
{
all_mask=amask;
}
int getLen(void){return len;}
protected:
int container_size_;
};
inline int otl_decimal_degree(unsigned int num)
{
int n=0;
while(num!=0){
++n;
num/=10;
}
return n;
}
inline bool otl_isspace(char c)
{
return c==' '||c=='\t'||c=='\n'||
c=='\r'||c=='\f'||c=='\v';
}
inline char otl_to_upper(char c)
{
return OTL_SCAST(char,toupper(c));
}
inline unsigned int otl_to_fraction
(unsigned int fraction,int frac_prec)
{
if(fraction==0||frac_prec==0)return fraction;
int degree_diff=9-frac_prec;
for(int i=0;i<degree_diff;++i)
fraction*=10;
return fraction;
}
inline unsigned int otl_from_fraction
(unsigned int fraction,int frac_prec)
{
if(fraction==0||frac_prec==0)return fraction;
int degree_diff=9-frac_prec;
for(int i=0;i<degree_diff;++i)
fraction/=10;
return fraction;
}
#define OTL_NO_STM_TEXT "#No Stm Text available#"
class otl_datetime{
public:
int year;
int month;
int day;
int hour;
int minute;
int second;
unsigned long fraction;
int frac_precision;
#if defined(OTL_ORA_TIMESTAMP)
short int tz_hour;
short int tz_minute;
#endif
otl_datetime()
{
year=1900;
month=1;
day=1;
hour=0;
minute=0;
second=0;
fraction=0;
frac_precision=0;
#if defined(OTL_ORA_TIMESTAMP)
tz_hour=0;
tz_minute=0;
#endif
}
otl_datetime
(const int ayear,
const int amonth,
const int aday,
const int ahour,
const int aminute,
const int asecond,
const unsigned long afraction=0,
const int afrac_precision=0
#if defined(OTL_ORA_TIMESTAMP)
,
const short int atz_hour=0,
const short int atz_minute=0
#endif
)
{
year=ayear;
month=amonth;
day=aday;
hour=ahour;
minute=aminute;
second=asecond;
fraction=afraction;
frac_precision=afrac_precision;
#if defined(OTL_ORA_TIMESTAMP)
tz_hour=atz_hour;
tz_minute=atz_minute;
#endif
}
otl_datetime(const otl_datetime& dt)
{
copy(dt);
}
~otl_datetime(){}
otl_datetime& operator=(const otl_datetime& dt)
{
copy(dt);
return *this;
}
protected:
void copy(const otl_datetime& dt)
{
year=dt.year;
month=dt.month;
day=dt.day;
hour=dt.hour;
minute=dt.minute;
second=dt.second;
fraction=dt.fraction;
frac_precision=dt.frac_precision;
#if defined(OTL_ORA_TIMESTAMP)
tz_hour=dt.tz_hour;
tz_minute=dt.tz_minute;
#endif
}
};
class otl_oracle_date{
public:
unsigned char century;
unsigned char year;
unsigned char month;
unsigned char day;
unsigned char hour;
unsigned char minute;
unsigned char second;
otl_oracle_date(){}
~otl_oracle_date(){}
};
inline void convert_date(otl_datetime& t,const otl_oracle_date& s)
{
t.year=(OTL_SCAST(int, s.century-100)*100+(OTL_SCAST(int, s.year-100)));
t.month=s.month;
t.day=s.day;
t.hour=s.hour-1;
t.minute=s.minute-1;
t.second=s.second-1;
}
inline void convert_date(otl_oracle_date& t,const otl_datetime& s)
{
t.year=OTL_SCAST(unsigned char, ((s.year%100)+100));
t.century=OTL_SCAST(unsigned char, ((s.year/100)+100));
t.month=OTL_SCAST(unsigned char, s.month);
t.day=OTL_SCAST(unsigned char, s.day);
t.hour=OTL_SCAST(unsigned char, (s.hour+1));
t.minute=OTL_SCAST(unsigned char, (s.minute+1));
t.second=OTL_SCAST(unsigned char, (s.second+1));
}
class otl_null{
public:
#if (defined(_MSC_VER)&&(_MSC_VER==1200))
int dummy; // this is to fix a compiler bug in VC++ 6.0
#endif
otl_null(){}
~otl_null(){}
};
class otl_column_desc{
public:
char* name;
int dbtype;
int otl_var_dbtype;
#if defined(_WIN64)
__int64 dbsize;
#else
int dbsize;
#endif
int scale;
#if defined(_WIN64)
__int64 prec;
#else
int prec;
#endif
int nullok;
#if defined(OTL_ORA_UNICODE)
int charset_form;
int char_size;
#endif
otl_column_desc()
{
name=0;
name_len_=0;
dbtype=0;
otl_var_dbtype=0;
dbsize=0;
scale=0;
prec=0;
nullok=0;
#if defined(OTL_ORA_UNICODE)
charset_form=0;
char_size=0;
#endif
}
~otl_column_desc()
{
delete[] name;
}
otl_column_desc& operator=(const otl_column_desc& desc)
{
if(name_len_>=desc.name_len_)
strcpy(name,desc.name);
else if(name==0 && desc.name!=0){
name=new char[desc.name_len_];
name_len_=desc.name_len_;
strcpy(name,desc.name);
}else if(name_len_<desc.name_len_){
delete[] name;
name=new char[desc.name_len_];
name_len_=desc.name_len_;
strcpy(name,desc.name);
}
dbtype=desc.dbtype;
otl_var_dbtype=desc.otl_var_dbtype;
dbsize=desc.dbsize;
scale=desc.scale;
prec=desc.prec;
nullok=desc.nullok;
#if defined(OTL_ORA_UNICODE)
charset_form=desc.charset_form;
char_size=desc.char_size;
#endif
return *this;
}
void set_name(const char* aname,const int aname_len=0)
{
int len;
if(aname_len==0)
len=OTL_SCAST(int,strlen(aname))+1;
else
len=aname_len+1;
if(name_len_<len){
if(name)delete[] name;
name=new char[len];
name_len_=len;
for(int i=0;i<len-1;++i)
name[i]=aname[i];
name[len-1]=0;
}
}
protected:
int name_len_;
};
class otl_var_desc{
public:
int param_type;
int ftype;
int elem_size;
int array_size;
int pos;
int name_pos;
char name[128];
int pl_tab_flag;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -