I have a PB app that was written long ago, and one thing it does is build its (MySQL) database as needed. To do this, all of the scripts needed to build the database were added to function objects, one per database object. i.e., there's an "fn_create_mytable" that builds a table, "fn_create_myproc" that creates a procedure, etc.
Because these are functions, they are really ungainly because the create statement must be pasted into the function, and then every line wrapped like:
ls_sql = "select this,"~r~n" +&
"that~r~n" +&
"from...~r~n"
etc., until the whole script is there. Then it executes the statement at the end. So when it needs maintenance, you have to copy the script out, strip out the junk, paste it into a SQL editor, and then reverse the process to put it back.
In a C# application you can store text files in a class as embedded resources and they're not visible to the user, but can be referenced by the code. I would love to be able to do that somehow in that PB application. Is it possible?
I apologize if this is an obvious question. I can certainly deploy all the scripts as text files, but then it's all editable and visible to the user. I want it hidden in a class/NVO, or something without all the string manipulation.
Any ideas would be much appreciated.
I wonder how safe it would be to have say, 200 scripts in the data of one datawindow, where each row had a ScriptName column, and a ScriptSQL column. i.e., with all the eggs in one dw basket, I wonder if there's a risk of a crash. It would be thousands of lines of code.
If you have a LOT of scripts, I would also break up the scripts into multiple datawindows: tables in one, procedures in another - indexes in another. etc. or some other method.
for what its worth, i just have everything in text files and have a separate application run the scripts. It handles new installs as well as upgrades using alter scripts. If you went that route, you could always encrypt the text files.