I am developing applications with Delphi XE. I have many long SQL queries and I don't want to store them in code like below, because this method reduces code readability:
CONST_SQL1 = 'SELECT ... FROM ..'#13#10 + 'WHERE ...';
Maybe creating a DataModule and storing the SQL queries in the Memo components can be an alternative option. This way the SQL queries will have more readability rather than the method above but in this way, I have to add many Memo components in the DataModule like Memo_SQL1, Memo_SQL2, Memo_SQL3, ...
Also I don't want to store these SQL queries in separate files or in a database.
Is there a single component that I can store all these SQL queries inside or what is your best practice for this case?
Thank you very much for all of your comments. On my project I prefer only one file and that is the program's EXE. Since I don't want any other separate files, I prefer the SQL queries to be stored in an EXE resource. Since SQL queries are changing so often and storing the SQL queries in the database needs additional insert efforts, I don't prefer to store them in the database.
I tried to develop the most basic and helpful method for my needs. In this method, all SQL queries are being stored in an EXE resource as a single XML file format. I am sharing below if this method can help any other people.
SQLQueries.rc:
SQLQueries.xml (in UTF-8):
Project1.dpr:
Compiled EXE with my resource named
SQLQueriesand its content:The program's output of
Writeln(SQLDictionary['SQL1'])verifies that the SQL query has been read successfully byXMLDocument.LoadFromStream(ResourceStream):