Page 1 of 1
ExecSql result count in case of using begin end;
Posted: Sat 28 May 2011 15:36
by ahijazi
Dear Devart;
Code: Select all
sqlCmd.SQL.Text := '';
sqlCmd.SQL.Text := 'begin update demo set oid = 202 where oid = -1;
commit; end;'
sqlCmd.Execute;
how to get the correct Rows Affected ???
always get 1
best regards ....
Posted: Mon 30 May 2011 08:58
by AlexP
Hello,
With the help of the RowsAffected property you can receive the number of rows from pure SQL. If you are using PL/SQL block, you should use variables to return the number of modified/inserted/deleted rows, for example:
Code: Select all
OraQuery1.SQL.Text:= 'begin '+#13+
'update demo set oid = 202 where oid = -1; '+#13+
':cnt := SQL%ROWCOUNT; '+#13+
'commit; '+#13+
'end;';
OraQuery1.ParamByName('cnt').ParamType:= ptOutput;
OraQuery1.ParamByName('cnt').DataType:= ftInteger;
OraQuery1.Execute;
ShowMessage(OraQuery1.ParamByName('cnt').AsString);
Posted: Tue 31 May 2011 07:26
by ahijazi
Dear Devart;
thank a lot.. but I have another question, in case of using the TOraSession.ExecSql with simple update statement (without begin end;) how can I get the RowsAffected ??? only available in TOraSQL !!
Best Regards,
Posted: Tue 31 May 2011 08:44
by AlexP
Hello,
To get the number of records that were changed using the TOraSession.ExecSQL method, you can use the following code:
Code: Select all
OraSession1.ExecSQL('update demo set oid = 202 where oid = -1',[]);
ShowMessage(IntToStr(OraSession1.SQL.RowsAffected));
Posted: Tue 31 May 2011 09:18
by ahijazi
Dear Devart;
Thanks again ....
Best Regards,
Posted: Tue 31 May 2011 10:24
by AlexP
Hello,
If you have any other questions, feel free to contact us