Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is storing SQL queries in a database a bad thing?

Tags:

sql

We're thinking of storing SQL queries in a separate table. These queries are solely for reporting purposes. Different queries for different reports - moreover the queries would contain placeholders so we can either format or use prepared statements from the Winforms front end (it's a simple 2-tier reporting app) to e.g. format the date range to report on.

I'm having some mixed feelings about that - is it ok to store SQL in a table, that clients will fetch and run?

like image 587
Anonym Avatar asked Sep 12 '10 17:09

Anonym


1 Answers

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

Otherwise, ask:

What's the difference between storing them in source, XML files, SQL etc.? Storage is storage is storage... The potential damage of misuse and implementing without considering the constraints in relation to your app is what counts.

like image 119
Aiden Bell Avatar answered Nov 14 '22 21:11

Aiden Bell