QUESTIONS:
How do I resolve the exception described below?
How do I retrieve a stored procedure return code in C++? (the last 3 lines of the code snipped I attached?
inParam = new PgSqlParameter*[2];
PgSqlCommand * myCommand = new PgSqlCommand(S"sp_AddMVScan", m_connection);
myCommand->Connection->Open();
myCommand->CommandType = CommandType::StoredProcedure;
inParam[0] = new PgSqlParameter(S"name", PgSqlType::Text);
inParam[0]->Direction = System::Data::ParameterDirection::Input;
inParam[0]->Value = (String*)csScanName;
cnt++;
inParam[1] = new PgSqlParameter(S"retval", PgSqlType::Int);
inParam[1]->SourceColumn = S"nID";
inParam[1]->Direction = System::Data::ParameterDirection::ReturnValue;
cnt++;
for(int i = 0; i Parameters->Add(inParam);
myCommand->ExecuteNonQuery(); Connection->Close();
String * sResult = myCommand->Parameters->Item[S"retval"]->Value->ToString();
ScanID = System::Convert::ToInt32(sResult);
return ScanID;
Stored procedure code: (generated with SQL Manager 2005)
CREATE OR REPLACE FUNCTION "public"."sp_AddMVScan" (name text) RETURNS integer AS
$body$
DECLARE retval INTEGER;
BEGIN
INSERT INTO "IPSonarScanConfig"("sName") VALUES (name);
retval = currval('ipsonarscanconfig_nid_seq');
RETURN retval;
END
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
Thank you
Flaviu
Calling Postgres stored procedures from Visual C++ 8.0 (Visual Studio 2005)
I can not test the issue because your description does not contain all necessary DB data. So please include DDLs for 'IPSonarScanConfig' table, 'ipsonarscanconfig_nid_seq' sequence and all dependent because they are required by stored procedure. Also please provide error message and stack trace of exception caught.
Since it is a specific situation and requires a lot of data to reproduce it would be better to send it to support e-mail address.
Since it is a specific situation and requires a lot of data to reproduce it would be better to send it to support e-mail address.