running script from Toad for Oracle

Dear all,

Right now I read this: http://www.oracle-base.com/articles/10g/auditing-10gr2.php

and I run this script:

COLUMN username FORMAT A10
COLUMN owner    FORMAT A10
COLUMN obj_name FORMAT A10
COLUMN extended_timestamp FORMAT A35

SELECT username,
       extended_timestamp,
       owner,
       obj_name,
       action_name
FROM   dba_audit_trail
WHERE  owner = 'AUDIT_TEST'
ORDER BY timestamp;

Open in new window


but I get an error:

ORA-00900: invalid SQL statement

Open in new window



May I know why ?

any thing should be there for the following to complete?

COLUMN username FORMAT A10
COLUMN owner    FORMAT A10
COLUMN obj_name FORMAT A10
COLUMN extended_timestamp FORMAT A35

Open in new window

LVL 1
marrowyungSenior Technical architecture (Data)Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
use F5 instead of F9

toad can run sql+ as of a certain version, i think 10.5
this script is a sql+ script
tested in 10.6
0
ThommyCommented:
Toad can definitely run sql scripts much longer before than version 10.5, probably from start versions!!!

As @Geert mentioned before:

Select "Execute as script" and not "Execute/compile statement at caret"

Toad-Screenshot: Execute as script
0
marrowyungSenior Technical architecture (Data)Author Commented:
yeah,

you guys are right !

I do Execute statement instead of execute as script.

why is it ? what is the different between 2?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

marrowyungSenior Technical architecture (Data)Author Commented:
what is F9 about ?
0
ThommyCommented:
F9 is the shortcut for Execute Statement
F5 is the shortcut for Execute as script

Execute Statement executes one single sql statement
Execute as script executes a sql script, a sequence comprised of one or more sql statements and commands
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
marrowyungSenior Technical architecture (Data)Author Commented:
"Execute as script executes a sql script, a sequence comprised of one or more sql statements and commands "

Excellent, just like I use the mouse to hightlight the script and then press F5, it just execute what I hightlighted?

I am wondering where we should only execute 1 statement only, for debug purpose ?
0
Geert GOracle dbaCommented:
just imagine having a few drop table and create table statements
and not in the correct order

create table x

drop table y

create table y

drop table x

you can put your cursor on a statement (without selecting it)
and hit Ctrl-F9
Toad will try and find the complete statement for that line and it will only execute that 1 statement
running above script completely would only give you table y
0
marrowyungSenior Technical architecture (Data)Author Commented:
"Execute as script executes a sql script, a sequence comprised of one or more sql statements and commands "

so it is not F9 but ctrl-F9 ?

"Toad will try and find the complete statement for that line and it will only execute that 1 statement"

don't understand this one. F9 (Ctrl-F9) will let Toad find the complete statement ? but once it found the whole thing it will ONLY execute the first one ? then why find the whole thing ?
0
ThommyCommented:
No, i think Geert is wrong:
Putting your cursor on a statement and pressing F9 will execute exactly the statement under the cursor (not Ctrl-F9, which is for describing a query). That's the Toad default setting.

But Toad is completely configurable and you may change the shortcuts as you like by accessing the editor options...
0
ThommyCommented:
The sense of sql scripts is to automate recurrent sql tasks.

After having loaded a sql script into the editor, Toad provides you the options to exectue the whole script (F5), a single statement under the cursor (F9) or even a snippet (shift-F9)...
0
marrowyungSenior Technical architecture (Data)Author Commented:
"After having loaded a sql script into the editor, Toad provides you the options to exectue the whole script (F5), a single statement under the cursor (F9) or even a snippet (shift-F9)... "

yeah, I like F5, exactly the same way as working with MS SQL.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.