0% found this document useful (0 votes)
6 views

Advanced SQL

The document discusses advanced SQL features, focusing on Embedded SQL and Dynamic SQL. Embedded SQL allows integration of SQL statements within application code, enhancing performance, data consistency, and security, while Dynamic SQL enables the creation of SQL statements at runtime based on user input. Both methods provide flexibility and efficiency in database operations.

Uploaded by

sangeetha.b.iot
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Advanced SQL

The document discusses advanced SQL features, focusing on Embedded SQL and Dynamic SQL. Embedded SQL allows integration of SQL statements within application code, enhancing performance, data consistency, and security, while Dynamic SQL enables the creation of SQL statements at runtime based on user input. Both methods provide flexibility and efficiency in database operations.

Uploaded by

sangeetha.b.iot
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Modern Database management

system
Unit – 1 RELATIONAL DATABASES

21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 1


Advanced SQL features
• Embedded SQL

• Embedded SQL is a method that combines SQL with a high−level


programming language's features. It enables programmers to put
SQL statements right into the source code files used to set up an
application.

• Database operations may be carried out effortlessly by developers


by adding SQL statements to the application code

21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 2


• The source code files having embedded SQL statements should be preprocessed before compilation
because of the issue of interpretation of SQL statements by the high−level programming languages in
embedded SQL.

• The terms EXEC SQL and END_EXEC must be used before and after each SQL statement in the source
code file. In embedded SQL, host variables play a key role. These variables serve as an intermediary for
data transfer between the application and the database.

• There are two different kinds of host variables: input host variables that provide data to the database
and output host variables that receive that data.

• Example

• This example shows the embedded code written in C++, retrieving the customer id, and name from the
database

21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 3


• Input
• Student
• id roll_no name address
• 1 21 monu gonda

21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 4


21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 5
• Advantages of Embedded SQL
• Optimized Performance: Since embedded SQL allows developers to have control over the
SQL statements, they can optimize the queries for better performance. By analyzing the
database schema and query execution plans, developers can fine−tune the SQL
statements to ensure efficient data retrieval and manipulation.
• Tight Integration: Embedded SQL enables seamless integration of SQL operations within
the application code. This integration allows developers to leverage the full power of SQL
while using the high−level programming language for other application logic. It
eliminates the need for separate SQL scripts or external files, making the code more
manageable and maintainable.
• Data Consistency: By embedding SQL statements within the application code, developers
can ensure data consistency throughout the application. Changes made to the database
structure or table schema can be reflected in the embedded SQL code, reducing the
chances of data inconsistencies.
• Database Security: Embedded SQL allows developers to incorporate authentication and
security measures directly into the application. This integration enables the
implementation of fine−grained access controls, ensuring that only authorized users can
perform database operations
21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 6
• Dynamic SQL
• Dynamic SQL involves the creation and execution of SQL statements
at runtime. Dynamic SQL allows developers to generate SQL
statements dynamically based on runtime conditions or user input. By
combining changeable data, conditions, and dynamic database or
column names, developers may quickly construct SQL queries using
dynamic SQL.
• Because of its adaptability, dynamic SQL is a good choice when the
SQL statements need to change in response to evolving needs or user
inputs. Dynamic SQL queries are built at execution time so the system
chooses how to access the database and conduct the SQL queries.
Performance could be affected as a result of this lack of preparation
because the system must create an execution plan on the spot.
Dynamic SQL, however, provides outstanding adaptability and
versatility.

21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 7


21-02-2025 MDBMS Ms.Sangeetha Priya.B , AP/CSE IOT 8

You might also like