public override int ExecuteNonQuery()
        {
            SFBaseResultSet resultSet = executeInternal(CommandText,
                                                        convertToBindList(parameterCollection.parameterList), false);

            resultSet.next();
            return(ResultSetUtil.calculateUpdateCount(resultSet));
        }
예제 #2
0
 internal SnowflakeDbDataReader(SnowflakeDbCommand command, SFBaseResultSet resultSet)
 {
     this.dbCommand   = command;
     this.resultSet   = resultSet;
     this.isClosed    = false;
     this.SchemaTable = PopulateSchemaTable(resultSet);
     RecordsAffected  = resultSet.CalculateUpdateCount();
 }
        public override object ExecuteScalar()
        {
            logger.Debug($"ExecuteScalar, command: {CommandText}");
            SFBaseResultSet resultSet = ExecuteInternal();

            resultSet.Next();
            return(resultSet.GetValue(0));
        }
        public override int ExecuteNonQuery()
        {
            logger.Debug($"ExecuteNonQuery, command: {CommandText}");
            SFBaseResultSet resultSet = ExecuteInternal();

            resultSet.Next();
            return(resultSet.CalculateUpdateCount());
        }
        public void TestSessionRenewDuringQueryExec()
        {
            Mock.MockRestSessionExpiredInQueryExec restRequester = new Mock.MockRestSessionExpiredInQueryExec();
            SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester);

            sfSession.Open();
            SFStatement     statement = new SFStatement(sfSession, restRequester);
            SFBaseResultSet resultSet = statement.Execute(0, "select 1", null, false);

            Assert.AreEqual(true, resultSet.Next());
            Assert.AreEqual("1", resultSet.GetString(0));
        }
        private SFBaseResultSet executeInternal(string sql,
                                                Dictionary <string, BindingDTO> bindings, bool describeOnly)
        {
            if (CommandTimeout != 0)
            {
                sfStatement.setQueryTimeoutBomb(CommandTimeout);
            }

            SFBaseResultSet resultSet = sfStatement.execute(sql, bindings, describeOnly);

            return(resultSet);
        }
        public void TestSessionRenew()
        {
            Mock.MockRestSessionExpired restRequester = new Mock.MockRestSessionExpired();
            SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester);

            sfSession.Open();
            SFStatement     statement = new SFStatement(sfSession, restRequester);
            SFBaseResultSet resultSet = statement.Execute(0, "select 1", null, false);

            Assert.AreEqual(true, resultSet.Next());
            Assert.AreEqual("1", resultSet.GetString(0));
            Assert.AreEqual("new_session_token", sfSession.sessionToken);
            Assert.AreEqual("new_master_token", sfSession.masterToken);
        }
        public void TestServiceName()
        {
            var       restRequester = new Mock.MockServiceName();
            SFSession sfSession     = new SFSession("account=test;user=test;password=test", null, restRequester);

            sfSession.Open();
            string expectServiceName = Mock.MockServiceName.INIT_SERVICE_NAME;

            Assert.AreEqual(expectServiceName, sfSession.ParameterMap[SFSessionParameter.SERVICE_NAME]);
            for (int i = 0; i < 5; i++)
            {
                SFStatement     statement = new SFStatement(sfSession, restRequester);
                SFBaseResultSet resultSet = statement.Execute(0, "SELECT 1", null, false);
                expectServiceName += "a";
                Assert.AreEqual(expectServiceName, sfSession.ParameterMap[SFSessionParameter.SERVICE_NAME]);
            }
        }
예제 #9
0
        private DataTable PopuldateSchemaTable(SFBaseResultSet resultSet)
        {
            var table = new DataTable("SchemaTable");

            table.Columns.Add(SchemaTableColumn.ColumnName, typeof(string));
            table.Columns.Add(SchemaTableColumn.ColumnOrdinal, typeof(int));
            table.Columns.Add(SchemaTableColumn.ColumnSize, typeof(int));
            table.Columns.Add(SchemaTableColumn.NumericPrecision, typeof(int));
            table.Columns.Add(SchemaTableColumn.NumericScale, typeof(int));
            table.Columns.Add(SchemaTableColumn.DataType, typeof(Type));
            table.Columns.Add(SchemaTableColumn.AllowDBNull, typeof(bool));
            table.Columns.Add(SchemaTableColumn.ProviderType, typeof(SFDataType));

            int columnOrdinal = 0;
            SFResultSetMetaData sfResultSetMetaData = resultSet.sfResultSetMetaData;

            foreach (ExecResponseRowType rowType in sfResultSetMetaData.rowTypes)
            {
                var row = table.NewRow();

                row[SchemaTableColumn.ColumnName]       = rowType.name;
                row[SchemaTableColumn.ColumnOrdinal]    = columnOrdinal;
                row[SchemaTableColumn.ColumnSize]       = (int)rowType.length;
                row[SchemaTableColumn.NumericPrecision] = (int)rowType.precision;
                row[SchemaTableColumn.NumericScale]     = (int)rowType.scale;
                row[SchemaTableColumn.AllowDBNull]      = rowType.nullable;

                Tuple <SFDataType, Type> types = sfResultSetMetaData.GetTypesByIndex(columnOrdinal);
                row[SchemaTableColumn.ProviderType] = types.Item1;
                row[SchemaTableColumn.DataType]     = types.Item2;

                table.Rows.Add(row);
                columnOrdinal++;
            }

            return(table);
        }
        protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            SFBaseResultSet resultSet = executeInternal(CommandText, null, false);

            return(new SnowflakeDbDataReader(this, resultSet));
        }
 internal SnowflakeDbDataReader(SnowflakeDbCommand command, SFBaseResultSet resultSet)
 {
     this.dbCommand = command;
     this.resultSet = resultSet;
     this.isClosed  = false;
 }