RAD Studio Tip: Using resource scripts to organize project dependencies.

2 Responses

  1. Fr0sT-Brutal says:

    I came to his in one of my DB projects. Actually it is a helper project that upgrades DB to a new version. Of course it must contain lots of SQL scripts that were too big to be stored as constants. But described tech has disadvantages:
    – Works on Windows only
    – Every query needs separate file added to project and an entry in .RC. What if you have 50 of them?
    So I came to one resource file for all queries and that file must have special format allowing identification of query blocks, query batching, additional non-SQL commands (commit / reconnect) etc.
    But for another project that is DB client I found that SQL constants are still much more convenient. Lots of short queries, much of them are 1-2-lined, are too small to be put into separate files. Moreover, constants give the best and fastest access to query text which is very complex in case of resource-stored strings.

    • I realized the same limitations, which is why after this post I wrote the form resource component. Form resource stores your sql in the form it’s self (so in the .res file for Windows), but this has the advantage that it works on data modules and therefore is cross platform. I added a custom component editor to manage the scripts too (though it is a little clunky)… http://chapmanworld.com/?s=Form+resource

Leave a Reply