Is storing SQL queries in a database bad?

We are thinking of storing SQL queries in a separate table. These requests are for reporting purposes only. Different queries for different reports - in addition, the queries will contain placeholders, so we can either format or use the prepared statements from the Winforms front panel (this is a simple report application with two levels), for example. format the date range for the report.

I have some mixed feelings about this - is it ok to store SQL in a table, what will clients get and run?

+3
source share
2 answers

I agree with Gregoire - stored procedures are a good way to move forward if your language works well with them.

Otherwise, ask:

What is the difference between storing them in the source, XML files, SQL, etc.? Storage is storage ... The potential damage from misuse and implementation without considering the limitations associated with your application matters.

+11
source

In my opinion, this looks like a quick and dirty solution. What if in the future you want to switch to another database engine with a different dialect of SQL? The best solution is to create a model of the report object (or xml model) and compare it with the corresponding database schema. It takes more time and effort.

0
source

Source: https://habr.com/ru/post/1764386/


All Articles