Vous êtes sur la page 1sur 3

signup

StackOverflowisaquestionandanswersiteforprofessionalandenthusiastprogrammers.It's100%free,no
registrationrequired.

login

tour

ToadforOracle..Howtoexecutemultiplestatements?StackOverflow

3/25/2015

help

stackoverflowcareers

Takethe2minutetour

ToadforOracle..Howtoexecutemultiplestatements?

Ihavesome8001200INSERTstatementsgeneratedfromanexcelsheet.IwanttoruntheseinTOAD
Oracledb.
IfIpress F9 ,itrunsonlyonelineand
missinghere?

F5

givesmesyntaxissueanddonotseemtowork?WhatamI

oracle toad

editedJan9'14at16:11

askedFeb7'12at3:55

Andrea
2,882

user1191463
10

18

31

85

10

1 Whatistheerror?Canyouaddasmallexampleofthestatementsthatfail?JonHellerFeb7'12at3:57
F5,hangsanddoesnothing,andIneedtocanceltheoperationafterafewminutes.F9ononelinewith
multiplestatementsseparatedby""givesanerrorsayingthere'saninvalidcharacterafterthefirst""
user1191463 Feb7'12at4:04
1 It'sbeenawhilesinceI'veusedTOAD,butifIremembercorrectlythereareafewcaseswhereitsparser
doesn'tworkcorrectly.Forexample,thealternativequotingmechanism,e.g. q'!...!' ,andcomments
aftersemicolons.NotsurewhyF5wouldhang,unlessitopensanothersessionandiswaitingforyour
currentsessiontocommit/rollback?Eitherway,itwouldhelpifyoucouldpostasmalltestcase.
JonHellerFeb7'12at4:24

8Answers

F9 executesonlyonestatement.BydefaultToadwilltrytoexecutethestatementwherever
yourcursorisortreatallthehighlightedtextasastatementandtrytoexecutethat.A ; isnot
necessaryinthiscase.
F5 is"ExecuteasScript"whichmeansthatToadwilltakeeitherthecompletehighlightedtext
(oreverythinginyoureditorifnothingishighlighted)containingmorethanonestatementand
executeitlikeitwasascriptinSQL*Plus.So,inthiscaseeverystatementmustbefollowedbya
; andsometimes(inPL/SQLcases)endedwitha / .

editedAug18'14at12:43
SQB
2,351

answeredFeb7'12at5:56
JohnDoyle

26

3,747

19

30

KnowwhyF5givesoutputasplaintext,whileF9givesoutputasaspreadsheetorasanewTOADwindow
forsomethinglikeadescribestatement?PeterBecichJun20'13at22:04
@PeterBecich:that'sbecauseF5isbeingexecutedinanexternalprogramTOADdoesn'tinterpretthe
resultswhichareplaintext.F9,ontheotherhand,isbeingexecutedbyTOADdirectlysoitcanformatthe
resultsinanicegridlayout.JeffreyKempAug19'14at3:11

Highlighteverythingyouwanttorunandrunasascript.Youcandothatbyclickingtheiconon
http://stackoverflow.com/questions/9170792/toadfororaclehowtoexecutemultiplestatements

1/3

3/25/2015

ToadforOracle..Howtoexecutemultiplestatements?StackOverflow

themenubarthatlookslikeatextfilewithalightningboltonit.ThatisthesameashittingF5.So
ifF5doesn'tworkyouprobablyhaveanerrorinyourscript.
Doyouhavesemicolonsaftereachstatement?
answeredFeb7'12at3:59
nolt2232
1,490

23

WrapthemultiplestatementsinaBEGINENDblocktomakethemonestatementandadda
slashaftertheENDclause.
BEGIN
insertintobooks
(id,title,author)
values
(books_seq.nextval,'TheBiteintheApple','ChrisannBrennan');
insertintobooks
(id,title,author)
values
(books_seq.nextval,'TheRestaurantattheEndoftheUniverse','DouglasAdams');
END;
/

Thatway,itisjustctrlathenctrlenteranditgoes.
editedMar12'14at21:07

answeredNov27'13at17:12
CSQ
51

IprefertheExecuteviaSQL*Plusoption.It'sinthelittledownarrowmenuunderthe"Execute
asscript"toolbarbutton.
answeredFeb7'12at6:31
JeffreyKemp
29.3k

41

85

Youcaneithergoforf5itwillexecuteallthescripsonthetab.
Or
Youcancreateasqlfileandputalltheinsertstatementsinitandthangivethefilepathinsqlplus
andexecute.
answeredAug19'13at10:48
Harshit
408

10

OpenmultipleinstancesofToadandexecute.
editedAug19'13at11:00

answeredAug19'13at10:42

Tony

skj

6,204

17

43

13

1. Justfinsihallofyourquerieswith
2. Selectallqueriesyouneed(inserts,selects,...).
3. PushorF5orF9bothWorks.
Notnecessarytoexecuteasscript
answeredDec24'13at23:41
Dave
49

http://stackoverflow.com/questions/9170792/toadfororaclehowtoexecutemultiplestatements

2/3

3/25/2015

ToadforOracle..Howtoexecutemultiplestatements?StackOverflow

begin
insertintofiscal_yearvalues(2001,'01jan2001','31dec2001');
insertintofiscal_yearvalues(2002,'01jan2002','31dec2002');
insertintofiscal_yearvalues(2003,'01jan2003','31dec2003');
insertintofiscal_yearvalues(2004,'01jan2004','31dec2004');
end;

Uselikethisandthencommit.
editedAug20'14at8:53
niemiro
583

answeredAug20'14at8:31
user3068880

23

21

http://stackoverflow.com/questions/9170792/toadfororaclehowtoexecutemultiplestatements

3/3

Vous aimerez peut-être aussi