40 #define NCBI_USE_ERRCODE_X Dbapi_CTlib_Cmds
42 #undef NCBI_DATABASE_THROW
43 #define NCBI_DATABASE_THROW(ex_class, message, err_code, severity) \
44 NCBI_DATABASE_THROW_ANNOTATED(ex_class, message, err_code, severity, \
45 GetDbgInfo(), GetConnection(), GetLastParams())
51 # if NCBI_FTDS_VERSION > 91
52 # define NCBI_CS_BIGINT_TYPE CS_BIGINT_TYPE
54 # define NCBI_CS_BIGINT_TYPE CS_LONG_TYPE
57 namespace NCBI_NS_FTDS_CTLIB
78 "blk_alloc failed", 110004
174 value.GetBulkInsertionData(&ts);
175 #ifdef USE_STRUCT_CS_VARCHAR
178 string msg =
FORMAT(
"Value for column " << (
i + 1)
179 <<
" is too wide for [N]VARCHAR: " << ts.
size()
185 b.varchar.SetValue(ts);
186 return b.varchar.GetValue();
193 memset(¶m_fmt, 0,
sizeof(param_fmt));
259 param_fmt.
datatype = NCBI_CS_BIGINT_TYPE;
268 value.precision = 20;
419 bool need_date =
true, need_time =
true;
438 #ifdef CS_BIGTIME_TYPE
448 #ifdef CS_BIGTIME_TYPE
463 #ifdef CS_BIGTIME_TYPE
476 days =
t.DiffWholeDays(
CTime(1900, 1, 1));
479 us = (((
t.Hour() * 60 +
t.Minute()) * 60 +
t.Second())
485 memcpy(bind.
buffer, &days,
sizeof(days));
486 }
else if ( !need_date ) {
487 memcpy(bind.
buffer, &us,
sizeof(us));
489 static const Uint8 kMicrosecPerDay
491 #ifdef CS_BIGDATETIME_TYPE
496 = (days + 693961) * kMicrosecPerDay + us;
497 memcpy(bind.
buffer, &dt,
sizeof(dt));
505 if (
CTime().SetTimeDBI(dbt) ==
t) {
514 string s = (
t.GetLocalTime()
529 TStringUCS2 ws = CUtf8::AsBasicString<TCharUCS2>(s);
534 memcpy(bind.
buffer, s.c_str(), s.size() + 1);
622 string MakeUCS2LE(
const wstring&
str)
626 #if defined(WORDS_BIGENDIAN)
629 for(wstring::size_type
i = 0;
i <
str.size(); ++
i) {
630 wchar_t chracter =
str.at(
i);
632 result.at(
i * 2) = (chracter & 0x000000FF);
633 result.at(
i * 2 + 1) = (chracter & 0x0000FF00);
637 result.assign((
const char*)
str.data(),
str.size() *
sizeof(wchar_t));
659 "blk_init failed", 123001);
677 "blk_describe failed (check the number of "
703 len = par.
Read(buff,
sizeof(buff));
713 "blk_textxfer failed for the BLOB field."
719 }
while (datalen > 0);
851 #if defined(FTDS_IN_USE) && defined(blk_sethints)
864 #if defined(FTDS_IN_USE) && defined(blk_sethints)
882 bool need_value =
false;
885 str_hint =
"ROWS_PER_BATCH";
889 str_hint =
"KILOBYTES_PER_BATCH";
893 str_hint =
"TABLOCK";
896 str_hint =
"CHECK_CONSTRAINTS";
899 str_hint =
"FIRE_TRIGGERS";
912 else if (
value != 0) {
928 string str_hint =
"ORDER (";
virtual bool CommitBCPTrans(void)
Complete batch – to store all rows transferred by far in this batch into the table.
CTempString x_GetStringValue(unsigned int i)
virtual void SetHints(CTempString hints)
Set hints by one call.
AutoArray< SBcpBind > & GetBind(void)
virtual int RowCount(void) const
Get the number of rows affected by the command Special case: negative on error or if there is no way ...
virtual bool Bind(unsigned int column_num, CDB_Object *param_ptr)
CS_RETCODE CheckSentSFB(CS_RETCODE rc, const char *msg, unsigned int msg_num)
CS_BLKDESC * x_GetSybaseCmd(void) const
virtual ~CTL_BCPInCmd(void)
virtual bool Cancel(void)
Cancel the command execution.
virtual void AddOrderHint(CTempString columns)
Add "ORDER" hint.
CS_RETCODE CheckSF(CS_RETCODE rc, const char *msg, unsigned int msg_num)
CS_RETCODE CheckSFB(CS_RETCODE rc, const char *msg, unsigned int msg_num)
bool x_IsUnicodeClientAPI(void) const
CTL_BCPInCmd(CTL_Connection &con, const string &table_name)
bool x_AssignParams(void)
virtual bool EndBCP(void)
Complete the BCP and store all rows transferred in last batch into the table.
virtual bool Send(void)
Send command to the server.
virtual void AddHint(CDB_BCPInCmd::EBCP_Hints hint, unsigned int value)
Add hint with value.
void SetDead(bool flag=true)
void DropCmd(impl::CCommand &cmd)
CS_RETCODE Check(CS_RETCODE rc)
CTL_Connection & GetConnection(void)
virtual void SetHasFailed(bool flag=true)
void SetExecCntxInfo(const string &info)
const TDbgInfo & GetDbgInfo(void) const
size_t PrepareToCancel(void)
void CancelFinished(size_t was_timeout)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
const string & GetQuery(void) const
virtual bool HasFailed(void) const
const CDB_Params & GetBindParamsImpl(void) const
void DetachInterface(void)
void SetWasSent(bool flag=true)
CDB_BigDateTime::ESyntax GetDateTimeSyntax(void)
CDB_Object * GetParam(unsigned int param_no) const
bool BindParam(unsigned int param_no, const string ¶m_name, CDB_Object *param, bool is_out=false)
TStatus GetParamStatus(unsigned int param_no) const
unsigned int NofParams() const
#define NCBI_CS_STRING_TYPE
CS_RETCODE blk_init(CS_BLKDESC *blkdesc, CS_INT direction, CS_CHAR *tablename, CS_INT tnamelen)
CS_RETCODE blk_drop(CS_BLKDESC *blkdesc)
CS_RETCODE blk_rowxfer(CS_BLKDESC *blkdesc)
CS_RETCODE blk_textxfer(CS_BLKDESC *blkdesc, CS_BYTE *buffer, CS_INT buflen, CS_INT *outlen)
CS_RETCODE blk_bind(CS_BLKDESC *blkdesc, CS_INT colnum, CS_DATAFMT *datafmt, CS_VOID *buffer, CS_INT *datalen, CS_SMALLINT *indicator)
CS_RETCODE blk_done(CS_BLKDESC *blkdesc, CS_INT type, CS_INT *outrow)
CS_RETCODE blk_sethints(CS_BLKDESC *blkdesc, CS_CHAR *hints, CS_INT hintslen)
CS_RETCODE blk_describe(CS_BLKDESC *blkdesc, CS_INT colnum, CS_DATAFMT *datafmt)
CS_RETCODE blk_alloc(CS_CONNECTION *connection, CS_INT version, CS_BLKDESC **blk_pointer)
#define CS_DATETIME4_TYPE
#define CS_LONGBINARY_TYPE
#define CS_BIGDATETIME_TYPE
CS_UBIGINT CS_BIGDATETIME
struct _cs_numeric CS_NUMERIC
static CS_CONNECTION * conn
static const char table_name[]
static const char * str(char *buf, int n)
static const column_t columns[]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define DATABASE_DRIVER_ERROR(message, err_code)
#define CHECK_DRIVER_ERROR(failed, message, err_code)
EBCP_Hints
Type of hint that can be set.
static bool IsBlobType(EDB_Type db_type)
Uint2 GetMinutes(void) const
const void * Value() const
const TOffset & GetOffset(void) const
const unsigned char * RawData() const
const void * Value() const
virtual EDB_Type GetType() const =0
const CTime & GetCTime(void) const
Uint2 GetDays(void) const
ESQLType GetSQLType(void) const
static CTimeFormat GetTimeFormat(ESyntax syntax, ESQLType sql_type=eDateTime, TOffset offset=null)
virtual size_t Read(void *buff, size_t nof_bytes)
Int4 Get300Secs(void) const
void GetBulkInsertionData(CTempString *ts, bool convert_raw_bytes=false) const
virtual size_t Size() const
const void * Value() const
@ eDateTimeOffset
DATETIMEOFFSET (MS); no Sybase equivalent.
@ eDateTime
DATETIME2 (MS), BIGDATETIME (Sybase)
@ eTime
TIME (MS), (BIG)TIME (Sybase)
#define NCBI_CURRENT_FUNCTION
Get current function name.
#define NCBI_CATCH_ALL_X(err_subcode, message)
#define FORMAT(message)
Format message using iostreams library.
#define numeric_limits
Pre-declaration of the "numeric_limits<>" template Forcibly overrides (using preprocessor) the origin...
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
char16_t TCharUCS2
Type for character in UCS-2 encoding.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
const char * data(void) const
Return a pointer to the array represented.
basic_string< TCharUCS2 > TStringUCS2
Type for string in UCS-2 encoding.
size_type size(void) const
Return the length of the represented array.
Int4 days
days from 1/1/1900
Int4 time
x/300 seconds from the beginning of current day
CTime GetLocalTime(void) const
Get the time as local time.
Definition of all error codes used in dbapi libraries (dbapi_driver.lib and others).
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
#define NCBI_CONST_UINT8(v)
unsigned char * longlong_to_numeric(Int8 l_num, unsigned int prec, unsigned char *cs_num)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Database format for time where day and time is signed 32 bit.