ORA-20502: Функция проверки: "Проверка на соответствие номера документа условиям его генерации" ORA-06512: на line 1ORA-20502: Функция проверки: "Проверка на соответствие номера документа условиям его генерации" ORA-06512: на line 1
private bool BlockDocument(string strOraConn, string strDocType, string strDocId) { using (var conOra = new OracleConnection(strOraConn)) { conOra.Open(); const string txtSql = "declare " + "res number; " + "curdocstate number; " + "DOCTYPE supermag.smdocuments.doctype%TYPE := :vDocTypeID; " + "DOCID supermag.smdocuments.id%TYPE := :vDocID; " + "begin " + "if supermag.core.getproc is null then " + "res := supermag.Core.StartSMApp(); " + "end if; " + "supermag.SMDOCLOCK(DOCTYPE, DOCID); " + "begin " + "supermag.SMENABLEACTUALIZEGOODS; " + "select docstate into curdocstate from smdocuments where doctype = DOCTYPE and id = DOCID; " + "if curdocstate = 2 then " + "supermag.documents.changedocstate(DOCTYPE, DOCID, 2, 1); " + "supermag.documents.changedocstate(DOCTYPE, DOCID, 1, 0); " + "else " + "supermag.documents.changedocstate(DOCTYPE, DOCID, 1, 0); " + "end if; " + "supermag.SMACTUALIZEGOODS; " + "supermag.SMDOCUNLOCK(DOCTYPE, DOCID); " + "exception when others then " + "supermag.SMDOCUNLOCK(DOCTYPE, DOCID); " + "raise; " + "end; " + "end;"; using (var cmd = new OracleCommand(txtSql, conOra)) { cmd.Parameters.Add(new OracleParameter("vDocTypeID", OracleType.VarChar)); cmd.Parameters["vDocTypeID"].Value = strDocType; cmd.Parameters.Add(new OracleParameter("vDocID", OracleType.VarChar)); cmd.Parameters["vDocID"].Value = strDocId; try { cmd.ExecuteNonQuery(); return true; } catch (Exception ex) { Console.WriteLine(ex.Message); return false; } } } }
2. Кусок когда для разбора текста заявки регулярными выражениями using (var conSql = new SqlConnection(connString)) { conSql.Open(); const string strsql = @" тут запрос который вовращает нужные нам заявки"; using (var cmdSql = new SqlCommand(strsql, conSql)) { cmdSql.Parameters.Add(new SqlParameter("@date", dtpChecksOrders.Value.Date)); using (var sqlReader = cmdSql.ExecuteReader()) { _dtOrders.Clear(); while(sqlReader.Read()) { MatchCollection matches = Regex.Matches(sqlReader["Problem_description"].ToString(), @"(\d{1}ЗП\d{7})"); foreach (Match match in matches) { _dtOrders.Rows.Add(Convert.ToInt32(sqlReader["id"]), match.Groups[1].Value, sqlReader["User_name"].ToString()); } } dgvBlockOrders.DataSource = _dtOrders; } } } где _dtOrders _dtOrders = new DataTable(); _dtOrders.Columns.Add("IDDemands", typeof(int)); _dtOrders.Columns.Add("IDOrders", typeof(string)); _dtOrders.Columns.Add("From", typeof(string));
public static bool BlockDocument(string strOraConn, string strDocType, string strDocId) { using (var conOra = new OracleConnection(strOraConn)) { conOra.Open(); const string txtSql = "declare " + "res number; " + "curdocstate number; " + "existdoc number; " + "DOCTYPE supermag.smdocuments.doctype%TYPE := :vDocTypeID; " + "DOCID supermag.smdocuments.id%TYPE := :vDocID; " + "begin " + "if supermag.core.getproc is null then " + "res := supermag.Core.StartSMApp(); " + "end if; " + "begin " + "supermag.SMDOCLOCK(DOCTYPE, DOCID); " + "select count(id) into existdoc from smdocuments where doctype = DOCTYPE and id = DOCID and DOCSTATE <> 0; " + "if existdoc > 0 then " + "supermag.SMENABLEACTUALIZEGOODS; " + "select docstate into curdocstate from smdocuments where doctype = DOCTYPE and id = DOCID; " + "if curdocstate = 2 then " + "supermag.documents.changedocstate(DOCTYPE, DOCID, 2, 1); " + "supermag.documents.changedocstate(DOCTYPE, DOCID, 1, 0); " + "else " + "supermag.documents.changedocstate(DOCTYPE, DOCID, 1, 0); " + "end if; " + "supermag.SMACTUALIZEGOODS; " + "supermag.SMDOCUNLOCK(DOCTYPE, DOCID); " + "end if; " + "exception when others then " + "supermag.SMDOCUNLOCK(DOCTYPE, DOCID); " + "raise; " + "end; " + "end;"; using (var cmd = new OracleCommand(txtSql, conOra)) { cmd.Parameters.Add(new OracleParameter("vDocTypeID", OracleType.VarChar)); cmd.Parameters["vDocTypeID"].Value = strDocType; cmd.Parameters.Add(new OracleParameter("vDocID", OracleType.VarChar)); cmd.Parameters["vDocID"].Value = strDocId; try { cmd.ExecuteNonQuery(); return true; } catch (Exception ex) { Console.WriteLine(ex.Message); return false; } } } }