konst
Если еще актуально. рабочий код на Шарпе
Код:
// Получение номера супермага для документа
public static string GetDocNumber(string strConnString, string strDocType, int intLocationId)
{
string strDocNum;
using (var conOra = new OracleConnection(strConnString))
{
conOra.Open();
const string txtSql = "declare " +
"core_result pls_integer; " +
"vDocTypeID varchar2(2) := :vDocTypeID; " +
"nLocationID number(3,0) := :nLocationID; " +
"vDocID varchar2(50); " +
"begin " +
"if supermag.core.getproc is null then " +
"core_result := supermag.Core.StartSMApp(); " +
"end if; " +
"vDocID := SUPERMAG.DOCUMENTS.GENERATEDOCNO(ADOCTYPE => vDocTypeID, ALOCATION => nLocationID); " +
"SUPERMAG.DOCUMENTS.UNLOCKDOC(vDocTypeID, vDocID); " +
":vDocID := vDocID; " +
"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("nLocationID", OracleType.Int16));
cmd.Parameters["nLocationID"].Value = intLocationId;
OracleParameter parNRec = cmd.Parameters.Add("vDocID", OracleType.VarChar, 15);
parNRec.Direction = ParameterDirection.Output;
try
{
cmd.ExecuteNonQuery();
strDocNum = parNRec.Value.ToString();
}
catch (Exception)
{
strDocNum = "";
}
}
}
return strDocNum;
}