Skip to content
March 30, 2018 / doganay

HOW TO EXECUTE SQL USING INPUT BINDS

DECLARE
v_sql    VARCHAR2 (32000);
v_sql_id VARCHAR2 (30) := 'f3yfg50ga0r8n';
v_b1     VARCHAR2(100) := 'bind1';
v_b2     VARCHAR2(100) := 'bind2';
BEGIN
BEGIN
SELECT sql_fulltext
INTO v_sql
FROM gv$sql
WHERE sql_id = v_sql_id AND ROWNUM = 1;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
SELECT sql_text
INTO v_sql
FROM dba_hist_sqltext
WHERE sql_id = v_sql_id AND ROWNUM = 1;
END;

EXECUTE IMMEDIATE v_sql
USING v_b1, v_b2;
END;
/

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: