Dynamic SQL and Embedded SQL
SQL queries can be of two types namely Embedded or Static SQL and Dynamic SQL. So, in this blog, we will be learning about these two types of SQL statements.
Embedded / Static SQL
Encryption of these statements in the application is not an option, so if you want to build an application that requires flexible SQL statements, you should use Dynamic SQL. In System C, the embedded SQL statement is separated from the programming language statements by previewing it with EXEC SQL keywords so that the preprocessor (or precompiler) can distinguish embedded SQL statements from the source code of the host language.
Dynamic SQL
In addition, since integration occurs during operation, the database will only be available during operation. Therefore, development and planning can not be done in advance. This will reduce system performance. Additionally, if a user is asked to enter a question during operation, then there is a chance that they will enter the wrong question, which is very dangerous as here you are dealing with a large amount of data.
When to Use Dynamic SQL
It is possible to use flexible SQL to create applications that generate flexible queries, also known as queries whose full text may not be known until the time of operation. There are many types of applications that require flexible queries, including:
●Apps where users can specify search query terms during operation or include them in a query search
● Apps that allow users to install or select upgrade strategies during operation
● Any application that asks for a website with descriptive table descriptions that are constantly changing
● Asking frequent questions to create new tables on the website
When to Use Static SQL
Consider flexible SQL only if it cannot be done in static SQL.
For example
Static SQL provides integration time integration. Dynamic SQL does not.
Suppose we are writing a PL / SQL database containing buggy SQL (eg invalid column name in SELECT)
With static SQL:
With dynamic SQL:
It is a dynamic SQL version of the same query, no error reported; process successfully integrated. Dynamic SQL has delayed error detection, which means you will get an unpleasant surprise if you run the process.
Key Differences
- Compared to flexible SQL statements, static SQL statements are faster and more efficient.
- Dynamic SQL statements are compiled during operation, and standard SQL statements are compiled during compilation.
- Static SQL is used in a uniformly distributed format and Dynamic SQL is used in a uniformly distributed format.
- Flexible Situation The fixed SQL is less flexible on the other hand Dynamic SQL is more flexible.
·
Conclusion
If you want to create a flexible application you can use flexible SQL, but make sure your users are professional and trained. If not, you should go to static or embedded SQL. This works very well compared to the powerful SQL.
References
https://www.oratable.com/static-sql-vs-dynamic-sql/
https://afteracademy.com/blog/what-is-an-embedded-and-dynamic-sql
https://www.tutorialsp
oint.com/difference-between-static-sql-and-dynamic-sql
https://www.geeksforgeeks.org/difference-static-dynamic-sql/
https://docs.oracle.com/cd/A87860_01/doc/appdev.817/a76939/adg09dyn.htm
Do
share this blog with your friends to spread the knowledge
Keep
Learning :)
Group 50 TY-C - Vishwakarma Institute of technology
Aakanksha Najardhane
Swaminath Nalwar
Navneet Sharma
Samruddhi Parate
Thank you :)
Great👍
ReplyDeleteVery informative
ReplyDeleteInteresting Read!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteNice blog
ReplyDeleteThis comment has been removed by the author.
ReplyDelete