Recent

Author Topic: Best practice to store long SQL files with you project  (Read 4259 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 2737
Re: Best practice to store long SQL files with you project
« Reply #15 on: September 25, 2023, 12:30:28 pm »
I was just thinking about OP's original request to manage the multiline sql into source code.

I normally keep sql in code, even if I understand that somebody prefers to store in external files, because in turn, sql in code means loaded in memory while program runs and this is kinda senseless.
With the downside, that if you HAVE to change your SQL-Statement (for whatever reason), you have to recompile/redistribute

Quote
I like using json for that or xml, having query name as key and sql text as content. That said I definitely do not split sql into separate lines, but this is just my personal way of seeing the world. All in one line (sometimes is very long!).
Yep, for me too: Once a Statement is written, it ends up in one single line, because that's what it is in the end
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Best practice to store long SQL files with you project
« Reply #16 on: September 25, 2023, 01:48:10 pm »
If you HAVE to change your SQL-Statement (for whatever reason), you have to recompile/redistribute

True 100%, although seldomly sql changes and code not.
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Okoba

  • Hero Member
  • *****
  • Posts: 555
Re: Best practice to store long SQL files with you project
« Reply #17 on: September 25, 2023, 05:32:35 pm »
@Hansvb I am sure you and many other needed to have SQL queries and especially big ones in your code. And having an ugly SQL-To-Pascal output like my first post, is not very cool.

incendio

  • Sr. Member
  • ****
  • Posts: 291
Re: Best practice to store long SQL files with you project
« Reply #18 on: October 25, 2023, 05:31:15 am »
For me, use a stored procedure for long sql queries.

 

TinyPortal © 2005-2018