Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL or PLSQL
Gary:
You ISSUE SQL statements via a PL/SQL procedure or function. No, your last question was the most clear... do I use SQL or do I use cursors. If you can use a single SQL statement to do what you would have done with a cursror, then use the SQL statement. It's faster. E.G. if I want to increase the salaries of 100 employees by 10%, I could cursor through them in a loop... fetch, do the math, then do the update statement for that employee. Or... I could issue ONE UPDATE statement that does it all at once: UPDATE employees set salary = salary * 1.1
Both of these can be done from within PL/SQL.
Is that what you are asking?
Tom
Gary wrote:
> Hi,
>
> I recall being told that using one of either SQL or PLSQL was preferable to
> the other, when doing simple selects, updates or deletes from tables,
> however I cant remember which.
> They also mentioned about context switches and the effect of performance
> this can have.
>
> So, if I wanted to select some rows or delete some rows from a table, and I
> was using a package or stored procedure, would it be better to user a Sql
> statement, or a plsql cursor to do that job.
>
> Or am I completely off the mark and getting myself unnecessarily confused
> here ??
>
> Thanks
Received on Thu Dec 02 1999 - 07:50:29 CST