cancel
Showing results for 
Search instead for 
Did you mean: 

Does SAP use dynamic SQL for searching DBs?

bigeye06
Explorer
0 Kudos
249

Hi all, I just started to learn about Dynamic SQL and I couldn't stop to wonder that if SAP uses it to search queries in DB Tables.

How does the system search for the data, Given that there are multiple Inputs one can give?

Thanks in advance. I am new to SAP and just curious.

View Entire Topic
lbreddemann
Active Contributor
0 Kudos

If the question is, whether SAP products typically run “EXEC” or “EXECUTE IMMEDIATE” statements with inline string replacement, then the answer is: no. That’s neither safe nor efficient.

What usually happens - say in the ABAP environment or in CAP - is that the query structure is generally defined in the application code and/or the CDS data model. During execution the filter and projection conditions are handed over to the DB interface. This DB interface either picks a matching prepared SQL statement from the cache or prepares a new statement with the required number of filter parameters/conditions and selected columns.

Once prepared, the actual filter values can be assigned to the query parameters and the statement is then executed.

So, instead of dynamic SQL, a query generator is used. Which is the case with pretty much the case any DB heavy application (think any application that uses a DB access framework, ORM framework, or that has a user configurable query interface).