/// <summary> /// Executes a SQL statement against a connection object. /// </summary> /// <returns> The number of rows affected. </returns> public override int ExecuteNonQuery() { BindParameters(); T_CCI_ERROR err = new T_CCI_ERROR(); int ret = CciInterface.cci_execute(handle, (char)CCIExecutionOption.CCI_EXEC_QUERY_ALL, 0, ref err); if (ret < 0) { throw new CUBRIDException(err.err_msg); } columnInfos = CciInterface.cci_get_result_info(conn, handle); if (this.Parameters.Count > 0) { if (this.GetOutModeParameterCount() == 0 || columnInfos == null) { CciInterface.cci_close_req_handle(handle); handle = 0; return(ret); } if ((CciInterface.cci_cursor(handle, 1, CCICursorPosition.CCI_CURSOR_FIRST, ref err)) < 0) { throw new CUBRIDException(err.err_msg); } if ((CciInterface.cci_fetch(handle, ref err)) < 0) { throw new CUBRIDException(err.err_msg); } for (int i = 1; i <= this.Parameters.Count; i++) { if (this.Parameters[i - 1].Direction == ParameterDirection.InputOutput || this.Parameters[i - 1].Direction == ParameterDirection.Output) { object value = new object(); CciInterface.cci_get_value(conn, i, Parameters[i - 1].CUBRIDDataType, ref value); Parameters[i - 1].Value = value; } } } CciInterface.cci_close_req_handle(handle); handle = 0; return(ret); }
internal CUBRIDDataReader ExecuteInternal() { T_CCI_ERROR err = new T_CCI_ERROR(); int ret = CciInterface.cci_execute(handle, (char)CCIExecutionOption.CCI_EXEC_QUERY_ALL, 0, ref err); if (ret < 0) { throw new CUBRIDException(err.err_msg); } //T_CCI_COL_INFO res; columnInfos = CciInterface.cci_get_result_info(conn, handle); dataReader = new CUBRIDDataReader(this, handle, ret, columnInfos, ret); return(dataReader); }
/// <summary> /// Advances the reader to the next result when reading the results of a batch of statements. /// </summary> /// <returns> true if there are more result sets; otherwise false. </returns> public override bool NextResult() { if (isClosed) { throw new CUBRIDException(Utils.GetStr(MsgId.InvalidAttemptToReadDataWhenReaderNotOpen)); } T_CCI_ERROR err = new T_CCI_ERROR(); bool bRet = false; resultCount = CciInterface.cci_next_result(handle, ref err); if (resultCount >= 0) { columnMetaData = CciInterface.cci_get_result_info(conn, handle); currentRow = 0; resultTuple = new ResultTuple(columnMetaData.Length); commandBehavior = CommandBehavior.Default; bRet = true; } return(bRet); }
/// <summary> /// Get the schemas of the foreign keys satisfying the foreign key filter. /// </summary> /// <param name="filters"> The foreign key filter, the value is {"table name pattern", "foreign key name pattern"}.<para/> /// If the table name pattern is null, the default "%" is used. If the foreign key name pattern is null, the default "" is used. </param> /// <returns>A <see cref="DataTable" /> that contains foreign key schema information and contains <para/> /// columns {"PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_ACTION", "DELETE_ACTION", "FK_NAME", "PK_NAME"} </returns> public DataTable GetForeignKeys(string[] filters) { if (filters == null) { throw new ArgumentNullException(Utils.GetStr(MsgId.NoFiltersSpecified)); } if (filters.Length > 2) { throw new ArgumentException(Utils.GetStr(MsgId.IncorrectNumberOfFilters)); } string tableName = filters[0]; string keyName = ""; if (filters.Length > 1) { keyName = filters[1]; } T_CCI_ERROR err = new T_CCI_ERROR(); int handle = CciInterface.cci_schema_info(conn, T_CCI_SCH_TYPE.CCI_SCH_IMPORTED_KEYS, tableName, keyName, (char)0, ref err); if (handle < 0) { throw new CUBRIDException(err.err_msg); } ColumnMetaData[] columnInfos = CciInterface.cci_get_result_info(conn, handle); CUBRIDCommand command = new CUBRIDCommand(null, conn); CUBRIDDataReader reader = new CUBRIDDataReader(command, handle, columnInfos.Length, columnInfos, columnInfos.Length); DataTable dt = new DataTable("ForeignKeys"); dt.Columns.Add("PKTABLE_NAME", typeof(string)); dt.Columns.Add("PKCOLUMN_NAME", typeof(string)); dt.Columns.Add("FKTABLE_NAME", typeof(string)); dt.Columns.Add("FKCOLUMN_NAME", typeof(string)); dt.Columns.Add("KEY_SEQ", typeof(short)); dt.Columns.Add("UPDATE_ACTION", typeof(short)); dt.Columns.Add("DELETE_ACTION", typeof(short)); dt.Columns.Add("FK_NAME", typeof(string)); dt.Columns.Add("PK_NAME", typeof(string)); while (reader.Read()) { DataRow row = dt.NewRow(); row["PKTABLE_NAME"] = reader.GetString(0); row["PKCOLUMN_NAME"] = reader.GetString(1); row["FKTABLE_NAME"] = reader.GetString(2); row["FKCOLUMN_NAME"] = reader.GetString(3); row["KEY_SEQ"] = reader.GetString(4); row["UPDATE_ACTION"] = reader.GetString(5); row["DELETE_ACTION"] = reader.GetString(6); row["FK_NAME"] = reader.GetString(7); row["PK_NAME"] = reader.GetString(8); dt.Rows.Add(row); } return(dt); }