//internal List<BlobInfo> BlobInfo; /// <summary> /// /// </summary> internal void CrsrInit(GatewayAdapterCursor dbCrsr, SQLiteGateway gtwyObj) { SQL3Dbd pSQL3Dbd = null; int segs = 0; PosKey = null; InUse = true; XtraPoskeyCnt = 0; XtraSortkeyCnt = 0; SQLiteGateway = gtwyObj; /* assign the gateway cursor id to the DB_CRSR structure */ SQLiteGateway.DbdTbl.TryGetValue(dbCrsr.Definition.DataSourceDefinition, out pSQL3Dbd); Logger.Instance.WriteDevToLog(string.Format("CrsrInit(): >>>>> GTWY cursor cnt = %d", SQLiteGateway.GatewayCursorTbl.Count)); Output = null; Input = null; Ranges = new Sql3Sqldata(SQLiteGateway); StartPos = new Sql3Sqldata(SQLiteGateway); SearchKey = null; Key = null; Update = null; GcurrInput = null; GcurrOutput = null; StmtRanges = null; /* for cascading startpos */ /* not direct sql */ this.PosKey = SQLiteGateway.FindPoskey(dbCrsr.Definition.DataSourceDefinition); Sql3PrepareForTimeStamp(dbCrsr); if (pSQL3Dbd != null) { /* if there is a key */ if (dbCrsr.Definition.Key != null) { segs = dbCrsr.Definition.Key.Segments.Count + 1; } /*--------------------------------------------------------------*/ /* fix bug #210900 - when no key selected - use the poskey segs */ /*--------------------------------------------------------------*/ else if (this.PosKey != null) { segs = PosKey.Segments.Count; } else { segs = 1; } Logger.Instance.WriteDevToLog(string.Format("CrsrInit(): segs in startpos = {0}", segs)); StmtStartpos = new List <string>(segs); for (int i = 0; i < segs; i++) { StmtStartpos.Add(null); } } StmtOrderBy = null; StmtOrderByRev = null; StmtInsert = null; StmtDelete = null; StmtUpdate = null; StmtWhereKey = null; StmtFields = null; StmtKeyFields = null; StmtExtraFields = null; StmtAllTables = null; JoinStmtBuiltWithInnerJoin = false; StmtAllTablesUpdLock = null; StmtAllTablesWithOtimizer = null; SourceDbh = null; DbhPrefix = null; StmtJoinCond = null; StmtJoinRanges = null; StmtSqlRng = null; /* created for optimizer hints in join tables but will be use always */ StmtAllTablesWithOtimizer = null; StmtJoinCond = null; StmtJoinRanges = null; StmtSqlRng = null; OuterJoin = false; if (dbCrsr.CursorType != CursorType.Join) { NullIndicator = new List <int>(); for (int i = 0; i < dbCrsr.Definition.DataSourceDefinition.Fields.Count; i++) { NullIndicator.Add(0); } } /* sql3_stmt structures */ /* Stmt allocation will be done on demand */ SReadA = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("ReadA", crsr_hdl); */ sReadD = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("ReadD", crsr_hdl); */ SRngA = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("RngA", crsr_hdl); */ SRngD = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("RngD", crsr_hdl); */ SStrt = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("Strt", crsr_hdl); */ SGCurr = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("Gcurr", crsr_hdl); */ SGCurrlock = SqliteConstants.NULL_STMT; SGKey = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("Gkey", crsr_hdl); */ SInsert = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("Ins", crsr_hdl); */ SUpdate = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("Upd", crsr_hdl); */ SDelete = SqliteConstants.NULL_STMT; /* sql3_stmt_alloc ("Del", crsr_hdl); */ /* indexes to SQL3_CURSOR 's */ /* Cusror allocation will also be done on demand */ CRead = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Read", crsr_hdl); */ CRange = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Range", crsr_hdl); */ CGcurr = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Gcurr", crsr_hdl); */ CGkey = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Gkey", crsr_hdl); */ CInsert = SqliteConstants.NULL_CURSOR; LastPos = new DbPos(true); CurrPos = new DbPos(true); Logger.Instance.WriteDevToLog("CrsrInit(): <<<<< "); }
/// <summary> /// SQL3LogSqlda() /// </summary> /// <param name="sqlda"></param> /// <param name="desc"></param> public static void SQL3LogSqlda(Sql3Sqldata sqlda, string desc) { int i = 0; int fldLen; string fullDate = string.Empty; string tmp; Logger.Instance.WriteToLog(string.Format("SQLDA {0}", desc), true); Logger.Instance.WriteToLog(string.Format("name = {0}", sqlda.name), true); Logger.Instance.WriteToLog(string.Format("sqln = {0}", sqlda.Sqln), true); Logger.Instance.WriteToLog(string.Format("sqld = {0}", sqlda.Sqld), true); for (i = 0; i < sqlda.Sqln; i++) { Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqlname.data = {1} ---------------------------", i, sqlda.SqlVars[i].SqlName), true); Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqltype = {1}", i, sqlda.SqlVars[i].SqlType), true); Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqllen = {1}", i, sqlda.SqlVars[i].SqlLen), true); tmp = sqlda.SqlVars[i].SqlData == null ? "null" : sqlda.SqlVars[i].SqlData.ToString(); switch (sqlda.SqlVars[i].SqlType) { case Sql3Type.SQL3TYPE_DATE: if ((sqlda.SqlVars[i].dateType != DateType.DATETIME_TO_CHAR && sqlda.SqlVars[i].dateType != DateType.DATETIME4_TO_CHAR)) { /* olga for right print of internal date 11.05.97*/ /* Bugfix - 420702 - esqlc_date_crack should be called to convert date*/ sqlda.SQLiteGateway.SQLiteLow.LibDateCrack(tmp, out fullDate, fullDate.Length, sqlda.SqlVars[i].SqlLen, null); Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = {1}", i, fullDate), true); } break; case Sql3Type.SQL3TYPE_STR: if (sqlda.SqlVars[i].SqlLen < 40) { fldLen = (int)sqlda.SqlVars[i].SqlLen; Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = {1}", i, sqlda.SqlVars[i].SqlData), true); } else { Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = {1}", i, sqlda.SqlVars[i].SqlData), true); } break; case Sql3Type.SQL3TYPE_WSTR: case Sql3Type.SQL3TYPE_BSTR: if (sqlda.SqlVars[i].SqlLen < 40) { fldLen = (int)sqlda.SqlVars[i].SqlLen; Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = {1}", i, tmp), true); } else { fldLen = sqlda.SqlVars[i].SqlLen > 40 ? 40 : sqlda.SqlVars[i].SqlLen; Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = {1} (TRUNCATED TO 40)", i, tmp), true); } break; case Sql3Type.SQL3TYPE_UI1: case Sql3Type.SQL3TYPE_I2: case Sql3Type.SQL3TYPE_I4: { switch (sqlda.SqlVars[i].SqlLen) { case 1: Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = :{1}: (integer)", i, tmp), true); break; case 2: Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = :{1}: (integer)", i, tmp), true); break; case 4: Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = :{1}: (integer)", i, tmp), true); break; } } break; case Sql3Type.SQL3TYPE_R4: case Sql3Type.SQL3TYPE_R8: { switch (sqlda.SqlVars[i].SqlLen) { case 4: Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = :{1}: (float)", i, tmp), true); break; case 8: Logger.Instance.WriteToLog(string.Format("sqlvar[{0}].sqldata = :{1}: (double)", i, tmp), true); break; } } break; } } }