Mimer SQL Programmer's Manual TOC PREV NEXT INDEX

Mimer Developer Site

www.mimer.com/developer


Principles of Dynamic SQL


Dynamic SQL allows 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 ALL ON HOTEL TO CHARLIE
 
 UPDATE ROOM_STATUS SET STATUS = 'KEY OUT'
 WHERE ROOMNO = 'SKY112'
 
 SELECT * FROM HOTEL
 
 SELECT RESERVATION,SUM(AMOUNT)
 FROM   BILL
 GROUP BY RESERVATION
 
 UPDATE ROOM_STATUS SET STATUS = ? WHERE ROOMNO = ?
 
 DELETE FROM BOOK_GUEST WHERE RESERVATION = ?
 
 SELECT HOTELCODE,ON_DATE,FREECOUNT*?
 FROM   FREEROOMS
 WHERE  ROOMTYPE  = ?
   AND  HOTELCODE IN (SELECT HOTELCODE
                      FROM HOTEL
                      WHERE CITY = ?)
 

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



Upright Database Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
dbtechnology@upright.se
Mimer SQL Programmer's Manual TOC PREV NEXT INDEX