📄 oradate.cpp
字号:
#include "stdafx.h"
#define __OCICPP_INTERNAL_USE_
#include "OraDate.h"
#include "OraError.h"
#include <stdio.h>
#include "OraError.h"
#include <stdio.h>
/*!
\class OCICPP::OraDate
\brief Client-side representation of date cells within the Oracle server
*/
OCICPP::OraDate::OraDate(OCIEnv *envhp,OCIError *errhp,OCIParam *param,ub2 type,int rows) :
OraType(envhp,errhp,param,type,rows)
{
ReqType=SQLT_DAT;
size=10; /* DD-MM-YYYY */
date=(char *)calloc(7*nRows,sizeof(char));
}
OCICPP::OraDate::~OraDate() {
free(date);
OCIHandleFree(definehp,OCI_HTYPE_DEFINE);
}
void OCICPP::OraDate::define(OCIStmt *stmt,int col) {
CHECKERR(err, OCIDefineByPos(stmt, &definehp, err, col+1, date, 7,ReqType,
(dvoid *) null, 0, (ub2 *)0, OCI_DEFAULT));
}
void OCICPP::OraDate::getStr(std::string &str,int row) {
char buf[12];
char *month[]={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"};
unsigned char cc,yy,mm,dd,hh,mi,ss;
cc=(date+7*row)[0]; /* Century */
yy=(date+7*row)[1]; /* Year */
mm=(date+7*row)[2]; /* Month */
dd=(date+7*row)[3]; /* Day */
hh=(date+7*row)[4]-1; /* Hour */
mi=(date+7*row)[5]-1; /* Minute */
ss=(date+7*row)[6]-1; /* Seconds */
cc=(unsigned char)abs(cc-100);
yy=(unsigned char)abs(yy-100);
sprintf(buf,"%d-%s-%d",dd,month[mm-1],(unsigned int)cc*100+(unsigned int)yy);
str.assign(buf);
}
void OCICPP::OraDate::getStrMon(std::string &mon,int row) {
char *month[]={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"};
unsigned char mm=(date+7*row)[2]; /* Month */
mon.assign(month[mm]);
}
void OCICPP::OraDate::getSec(int &sec,int row) {
sec=(int) (date+7*row)[6]-1;
}
void OCICPP::OraDate::getMin(int &min,int row) {
min=(int) (date+7*row)[5]-1;
}
void OCICPP::OraDate::getHour(int &hour,int row) {
hour=(int) (date+7*row)[4]-1;
}
void OCICPP::OraDate::getDay(int &day,int row) {
day=(int) (date+7*row)[3];
}
void OCICPP::OraDate::getMonth(int &mon,int row) {
mon=(int) (date+7*row)[2];
}
void OCICPP::OraDate::getYear(int &year,int row) {
unsigned char yy,cc;
yy=(date+7*row)[1];
cc=(date+7*row)[0];
yy=(unsigned char)abs(yy-100);
cc=(unsigned char)abs(cc-100);
year=(int)cc*100+(int)yy;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -