Toraclescript setting command

wftjeremy

Member
I have an oracle script with about 20
commands in it (few hundred lines of sql).

oraclescript runs this just fine, But I have had a request, the users want to be able to
run a certain command in the script and not the rest, what I want to do is have the script in a memo field the user scrolls through to the point in the memo field where the command they want to run is, press a button and then that command is ran.

The question is, how can I equate that memoline to a script line and show that current line of script... but how do I take script line and get the current command and then tell the script (or a dataset) to run that command? I can't figure out how to take line #200, and tell the script to run command #33.

I know, search up and down the memo for ; or / and parse it myself... but there has got to be an easier way.

ie.
Sample script

SELECT
*
FROM DUAL;
SELECT
SYSDATE
FROM DUAL;
SELECT
COUNT(*) FROM TAB;

SELECT COUNT(*) FROM V$SESSION;

User wants to run command #3 (select from tab).

Ideas?
 
Instead of displaying the complete text of the script, you could instead display the individual TOracleScript.Commands.Text for selection purposes. When the user selects command X for execution, you can call TOracleScript.Commands[X].Execute;

------------------
Marco Kalter
Allround Automations
 
Hmmm, nope, that wouldn't work, I need to display the SQL so they can pick what they want to run, plus they always modify the SQL.
The smart thing to do would be to build an entire new app to do it... but I'm a DBA...not a programmer, so editing is more time saving.

I still need to relate a line# in a script to the command index # for that line so I can then just execute command[x]
 
Got it to work, some of the code is below...
any body have a better way of doing it?

//clear and assign the memo to the script
script.lines.clear;
script.lines := memo1.lines;
//set the # of commands
commands := script.Commands.count;
//set the current memo line
current := memo1.CaretPos.y;
//now start looping to find the current command
i:= 0; //this will start with the first command
while i script.Commands.count-1 then stop := memo1.lines.count
else stop := script.commands.items[i+1].scriptline-1;
//showmessage(inttostr(stop));
//go to the next command
if (current >= start) and (current
 
Back
Top