Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site


Principles of Dynamic SQL


Dynamic SQL enables you to execute SQL statements placed in a string variable instead of explicitly writing the statements inside a program. This allows SQL statements to be constructed within an application program. These facilities are typically used in interactive environments, where SQL statements are submitted to the application program from the terminal.

An example of when dynamic SQL is needed would be a program for interactive SQL, where any correct SQL statement may be entered at the terminal and processed by the application. Limited dynamic facilities may however be provided by relatively simple application programs.

SQL Statements and Dynamic SQL

The following classes of SQL statements may be submitted to programs using dynamic SQL. Statements excluded from dynamic applications are declarations, diagnostic statements and dynamic SQL statements themselves.

Submitting Statements

Statements may be submitted to dynamic SQL applications in two forms:

 GRANT SELECT ON mimer_store_book.details TO mimer_admin_group
 
 SELECT code, country
    FROM mimer_store.countries
 
 SELECT price
    INTO :PRICE
    FROM mimer_store.items
    WHERE item_id = :ITEM_ID
 
 UPDATE mimer_store.currencies
    SET exchange_rate = ?
    WHERE code = ?
 
 DELETE FROM countries
    WHERE code = ?
 
 SELECT currency, exchange_rate * ?
    FROM mimer_store.currencies
    WHERE code IN (SELECT currency_code
                      FROM mimer_store.countries
                      WHERE code like ? || '%')
 

Statements submitted with parameter markers are equivalent to normal embedded statements using host variables, except that the statements are defined at run-time.


Mimer
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
info@mimer.se
Mimer SQL Documentation TOC PREV NEXT INDEX