Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION text_example (droptablBadWay varchar2) RETURN varchar2 AS
- BEGIN
- --EXECUTE IMMEDIATE 'DROP TABLE '||droptablBadWay;--This leads to sql injection
- EXECUTE IMMEDIATE 'DROP TABLE :example_tbl' USING droptablBadWay;
- EXCEPTION
- WHEN OTHERS THEN
- IF SQLCODE = -942 THEN
- DBMS_OUTPUT.put_line('the table did not exist!');
- ELSE
- RAISE;
- END IF;
- END;
- /
- CREATE TABLE test_example_tbl
- (
- oneCol varchar2(255)
- );
- SELECT * FROM test_example_tbl;
- SELECT text_example('test_example_tbl') FROM dual;
- SELECT * FROM text_example;
- --clean up
- DROP FUNCTION text_example;
- DROP TABLE test_example_tbl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement