A DBA is likely doing things like looping over metadata tables and running
'grant select on ' || some_table || ' to ' || some_user
While an app developer with free reign will end up doing something much more complex, and much harder to reason about/tune(The characters never actually get escaped with parameterisation - they are not part of the query text when it is parsed so can’t affect it - hence parameterising a value in sql query replaces the need to escape it with something much more robust.)
I am perfectly able to:
SELECT ACCOUNT_STATUS FROM DBA_USERS WHERE USERNAME=:var;
But I cannot: ALTER USER :var ACCOUNT UNLOCK;
I really don't understand why that capability wasn't added a decade ago, as loud as the advice is to avoid hard parsing.Dynamic SQL is used on practice to fix a lot of problems the SQL people have been refusing to touch.
Most of the OLAP / warehousing stuff I used to lean on dynamic sql for can be done more cleanly, with the benefit of easy source control.
The article could have made that much more clear.
It reminds me of the bash-completion project which is the default on Debian-based distros.
It tries to parse bash IN BASH. This is a very bad idea.
Oil Uses Its Parser For History And Completion - https://www.oilshell.org/blog/2020/01/history-and-completion...
I would also argue that parsing bash in C is not a great idea either!
Which, fundamentally, is what dynamic SQL is.
When I realized the article was going to be about that kind of dynamic SQL, I closed the tab.
Building SQL queries dynamically is fine.
Doing it within the SQL server is an abomination.