0% found this document useful (0 votes)
5 views11 pages

Dynamic SQL in Database Management

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views11 pages

Dynamic SQL in Database Management

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Programme: [Link].

Subject : Computer Science

Semester : III

Paper Code: CSC103

Paper Title : Database Management System


Unit VIII : SQL
Module Name: SQL:Dynamic SQL

Mr. Kashinath Chandelkar


Assistant Professor
Govt. College of Arts, Science & Commerce
Sanquelim - Goa.
Outline
Introduction Dynamic SQL

Need of Dynamic SQL

Static V/s Dynamic SQL

How to Use Dynamic SQL in DBMS


Learning Outcomes

The student will be able to:

 Differentiate between static and dynamic SQL

Use Dynamic SQL in DBMS.


Introduction to Dynamic SQL


Dynamic SQL refers to those SQL statements which are generated
dynamically based on user's input and run in the application.


Dynamic SQL helps to develop general and flexible applications.


Dynamic SQL may need more permissions and security handling and a
malicious user can create dangerous code as well.
Need of Dynamic SQL


To run dynamic queries on our database, mainly DML queries.


To access an object which is not in existence during the compile time.


To optimize the run-time of our queries.


To perform operations on application fed data using invoke rights.
Static V/s Dynamic SQL

Source:
Tutorialpoints
How to use Dynamic SQL

Use DataFlair;

-- Set the value of user-defined variables


SET @id = 'A01';

-- set the query you want to execute on the database


SET @query = 'SELECT * FROM DataFlair where emp_id = @id';

-- Prepare the statement to be run on the database


PREPARE stmt FROM @query;

-- Execute the prepared statement


Execute stmt;
Summary

 Differentiate between static and dynamic SQL


Need of Dynamic SQL
Use Dynamic SQL on the Server
References

• [Link]
• [Link]
amic-sql
• [Link]
ver-dynamic-sql/
• [Link]
sql
Thank you.

You might also like