Home » SQL & PL/SQL » SQL & PL/SQL » Multi-step query script in Toad (Toad Ora 11.0)
Multi-step query script in Toad [message #613821] Mon, 12 May 2014 14:25 Go to next message
ipisors
Messages: 24
Registered: May 2014
Location: USA [Arizona ... Desert]
Junior Member
I want to do the following:

1. create a temp table
2. populate it with a select query
3. run a select statement from the temp table

I am using this method:

CREATE GLOBAL TEMPORARY TABLE tempSR 
ON COMMIT PRESERVE ROWS
AS
   Select ......
   From   ......
   Where  ......

Select * from tempSR


It seems like in Oracle, I must need some other wrappers to get this done. How is this done? I currently get "command not properly ended" on the last line. It works if I comment out the last line.

Sorry, I am very new to PL/SQL.
Re: Multi-step query script in Toad [message #613823 is a reply to message #613821] Mon, 12 May 2014 14:47 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Statements should be terminated by ";" or "/" alone on a new line.


[Updated on: Mon, 12 May 2014 14:48]

Report message to a moderator

Re: Multi-step query script in Toad [message #613826 is a reply to message #613823] Mon, 12 May 2014 14:53 Go to previous messageGo to next message
ipisors
Messages: 24
Registered: May 2014
Location: USA [Arizona ... Desert]
Junior Member
[insert 'shame' emoticon]

Thanks Michael. As I mentioned, I'm very new to Oracle and wasn't even sure the correct terminology enough to produce effective Google results.

It works great - thanks again.
Re: Multi-step query script in Toad [message #613839 is a reply to message #613826] Mon, 12 May 2014 16:52 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Actually, the problem here consists of two "problems": the one Michel mentioned, and another one called "Usage of TOAD". How did you run those statements? As a script? Then yes - statement(s) weren't properly ended. However, if you executed them one by one (keyboard shortcut is <Shift + F9>, when positioned in a desired statement), they would run correctly. <F9> (or "run as a script") is used when you run a PL/SQL code (while your code is 2 SQL statements). True, there are some exceptions to above explanation, but - generally speaking - I believe that it is OK.
Re: Multi-step query script in Toad [message #613841 is a reply to message #613839] Mon, 12 May 2014 17:08 Go to previous message
ipisors
Messages: 24
Registered: May 2014
Location: USA [Arizona ... Desert]
Junior Member
Thank you, again. I believe I was very confused at first (you're right) because coming from Sql Server Mgmt Studio, there are really just two main distinctions:
1) selecting code and a-pressing button to execute, b-F5, or
2) not having any code selected, in which case, your cursor position matters not, and a-pressing button to execute, or b-F5, will parse & execute ALL code.

Now I can see that the actual state of things in Toad is a little bit more comparable to a Visual Basic module (in my mind), in that: It matters a lot where your cursor is...how you are executing it...and what wrapper (script) if any, is used.

Thanks gentlemen, I will also add this to my list of things to become more knowledgeable about.
Previous Topic: String Manipulation
Next Topic: ORA-01555 snapshot too old
Goto Forum:
  


Current Time: Fri Apr 26 05:51:41 CDT 2024