Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Dynamic SQL Reality Check
>> So what was B-A-D about it?
I had come from a background of VB, ASP and PHP. Using variables in a SQL string is as easy and breathing.
Something like this seemed like ... oh no ... I'm having a flashback just looking at it...
EXECUTE IMMEDIATE 'CREATE TABLE bonus (id NUMBER, amt NUMBER)'; sql_stmt := 'INSERT INTO dept VALUES (:1, :2, :3)'; EXECUTE IMMEDIATE sql_stmt USING dept_id, dept_name, location; sql_stmt := 'SELECT * FROM emp WHERE empno = :id'; EXECUTE IMMEDIATE sql_stmt INTO emp_rec USING emp_id; plsql_block := 'BEGIN emp_pkg.raise_salary(:id, :amt); END;'; EXECUTE IMMEDIATE plsql_block USING 7788, 500; sql_stmt := 'UPDATE emp SET sal = 2000 WHERE empno = :1
RETURNING sal INTO :2';
EXECUTE IMMEDIATE sql_stmt USING emp_id RETURNING INTO salary;
EXECUTE IMMEDIATE 'DELETE FROM dept WHERE deptno = :num'
USING dept_id;
EXECUTE IMMEDIATE 'ALTER SESSION SET SQL_TRACE TRUE';
I think it is the colon digit syntax (:1) that tipped me to the point
of phantasmagoria. Maybe there was too much trihalamethane in my water
that day. I dont know. :-)
Another take would be: I just want to write code to produce solutions as quickly and duplicatably as possible. I got the impression the developers of this type syntax lost site of this common objective.
-Michael42 Received on Wed Jan 17 2007 - 21:09:37 CST
![]() |
![]() |