Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dynamic SQL Pertemuan 11 Matakuliah: T0413/Current Popular IT II Tahun: 2007.

Similar presentations


Presentation on theme: "Dynamic SQL Pertemuan 11 Matakuliah: T0413/Current Popular IT II Tahun: 2007."— Presentation transcript:

1 Dynamic SQL Pertemuan 11 Matakuliah: T0413/Current Popular IT II Tahun: 2007

2 Bina Nusantara Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu menciptakan aplikasi sistem basisdata menggunakan konsep dynamic SQL

3 Bina Nusantara Outline Materi How does dynamic SQL work? Generating dynamic statements Executing statements immediately

4 Bina Nusantara HOW DOES DYNAMIC SQL WORK ? The difference between Dynamic and Embedded SQL You generated SQL statements as text strings in the host languages passed through a call level interface (API) Tracking context, initializing resources and such things Depend entirely on the API you are using Be aware of some extensions beyond conventional SQL

5 Bina Nusantara GENERATING DYNAMIC STATEMENTS The capabilities that Dynamic SQL provides elegant solution to this problem by letting you assemble the entire SQL statement in program logic rather than including it in program code 2 Basic ways : – Send a statement to the DBMS for immediate execution – Prepare a statement in advance of execution, the statement may be executed repeatedly

6 Bina Nusantara EXECUTION STATEMENT IMMEDIATELY Using EXECUTE IMMEDIATE statement to define (prepare) and execute such a statement in one step Host language : JAVA, C, PASCAL,dll Example : mystatement := INSERT INTO ORDERS values (20,’10/20/2005’,2001) Execution the statement : EXEC SQL EXECUTE IMMEDIATE : mystatement ;

7 Bina Nusantara EXECUTION STATEMENT IMMEDIATELY (Cont.) Is quick without being too dirty, but it does have limitation : – It is quick to code but necessarily quick to execute – If it will executing some statement more than once, it would be better using PREPARE and EXECUTE

8 Bina Nusantara EXECUTION STATEMENT IMMEDIATELY (Cont.) – The SQL statement cannot be a query because theres no mechanism to store the result of a query – The SQL statement cannot contain dynamic parameters

9 Bina Nusantara THE ADVANTAGES OF EXECUTE IMMEDIATE Queries are possible Performance is much improved Can create multiple variations on the same statement by using dynamic parameters

10 Bina Nusantara PREPARE and EXECUTE STATEMENT PREPARE creates an object containing the SQL statement to be executed EXECUTE (not EXECUTE IMMEDIATE) is an actual operation that telling the DBMS to implement the plan which in PREPARE statement


Download ppt "Dynamic SQL Pertemuan 11 Matakuliah: T0413/Current Popular IT II Tahun: 2007."

Similar presentations


Ads by Google