Dynamic SQL and Ref Cursors in EBS Extensions
Explain when and how to safely use dynamic SQL and ref cursors in custom EBS reports and extensions
Dynamic SQL (via EXECUTE IMMEDIATE or the older DBMS_SQL package) allows PL/SQL to construct and execute SQL statements whose text isn't fully known at compile time — essential for scenarios like flexible reporting extensions where filter criteria vary at runtime, or generic utilities that must operate across different tables. REF CURSORs (weak or strong typed) allow a query's result set to be returned from a function or passed between programs without the caller needing to know the exact SQL in advance, which is heavily used in BI Publisher data model extensions and custom OAF/ADF pages.
Building dynamic SQL safely is like a mail-merge letter template: you build the fixed wording once (the SQL skeleton) and drop distinct recipient details into placeholder slots (bind variables) rather than manually re-typing (concatenating) each recipient's name directly into a brand new letter every time — which would be both slower and more error/injection-prone.