PL/SQL (MOSC)

MOSC Banner

Bind variable in PLSQL block vs bare delete using literal value

edited Jun 28, 2010 5:20AM in PL/SQL (MOSC) 7 commentsAnswered
 Hi,
Can anyone tell me the performance difference in terms of parsed calls and CPU time between the following method of deletion? It is said that using bind variable is better. However I found that using bind variable in PLSQL block does not do me any good because Oracle has to parse PLSQL block as extra for each delete call. If I set cursor_sharing to 'SIMILAR' then with Oracle generated bind variable the (DELETE FROM test WHERE a = 18) uses less time. 

CREATE TABLE test (a NUMBER, b VARCHAR2(30), CONSTRAINT testp1 PRIMARY KEY (a));

DELETE FROM test WHERE a = 18

BEGIN EXECUTE IMMEDIATE 'DELETE FROM test WHERE a = :1' USING 17; END;

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center