Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ORACLE -- run multiple statements at once ?

Posted on 2010-11-23
7
Medium Priority
?
854 Views
Last Modified: 2013-12-18
I can run the below statements "one-at-a-time",
but get the below ERROR when when trying to
run everything at one time.

declare A1 VARCHAR2(50) := NULL; B1 VARCHAR2(50) := NULL; C1 VARCHAR2(50) := NULL; D1 VARCHAR2(50) :=

'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_C' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_C'||

CHR(30); BEGIN Output_Type_Api.New__(C1,B1,A1,D1,'DO'); END;

declare A1 VARCHAR2(50) := NULL; B1 VARCHAR2(50) := NULL; C1 VARCHAR2(50) := NULL; D1 VARCHAR2(50) :=

'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_N' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_N'||

CHR(30); BEGIN Output_Type_Api.New__(C1,B1,A1,D1,'DO'); END;

DECLARE A1 VARCHAR2(50) := NULL; B1 VARCHAR2(50) := NULL; C1 VARCHAR2(50) := NULL; D1 VARCHAR2(50) :=

'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_O' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_O'||

CHR(30); BEGIN Output_Type_Api.New__(C1,B1,A1,D1,'DO'); END;
-----------------------------------------------------------------
Error

ORA-06550: line 3, column 1:
PLS-00103: Encountered the symbol "DECLARE"
ORA-06550: line 5, column 1:
PLS-00103: Encountered the symbol "DECLARE"
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
-----------------------------------------------------------------
How can I fix and "run everything at one time" ?
0
Comment
Question by:finance_teacher
7 Comments
 
LVL 2

Accepted Solution

by:
gnosse earned 400 total points
ID: 34197541
without knowing anything about your API how about:

declare
      A1 VARCHAR2(50) := NULL;
      B1 VARCHAR2(50) := NULL;
      C1 VARCHAR2(50) := NULL;
      D1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_C' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_C'|| CHR(30);
BEGIN
      Output_Type_Api.New__(C1,B1,A1,D1,'DO');

      D1 := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_N' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_N'|| CHR(30);
      Output_Type_Api.New__(C1,B1,A1,D1,'DO');

      D1 := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_O' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_O'|| CHR(30);
      Output_Type_Api.New__(C1,B1,A1,D1,'DO');
END;
0
 
LVL 7

Assisted Solution

by:jocave
jocave earned 400 total points
ID: 34197569
If you want to have one PL/SQL block that runs each statement serially (not in parallel)

declare 
  A1 VARCHAR2(50) := NULL; 
  B1 VARCHAR2(50) := NULL; 
  C1 VARCHAR2(50) := NULL; 
  D1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_C' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_C'|| CHR(30); 
BEGIN 
  Output_Type_Api.New__(C1,B1,A1,D1,'DO'); 

  D1 := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_N' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_N'||CHR(30);

  Output_Type_Api.New__(C1,B1,A1,D1,'DO'); 

  D1 := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_O' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_O'|| CHR(30); 
  Output_Type_Api.New__(C1,B1,A1,D1,'DO'); 
END;

Open in new window


If you really want all three calls to be run in parallel (so that the third call may be made before the first call), you could potentially use the DBMS_JOB package.  But I doubt that's what you're looking for unless Output_Type_Api.New__ is a relatively long-running call.
0
 
LVL 32

Expert Comment

by:awking00
ID: 34198662
I think you need a "/" after each "end;" statement.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 400 total points
ID: 34201712
since you are on 10g, use DBMS_SCHEDULER to have jobs if you want to run them all at once ( parallely ).

Do not use DBMS_JOB
0
 
LVL 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 400 total points
ID: 34204319
as awking000 says
with sqlplus you need to separate pl/sql blocks with /

and indenting helps readability ...
 
declare 
  A1 VARCHAR2(50) := NULL; 
  B1 VARCHAR2(50) := NULL; 
  C1 VARCHAR2(50) := NULL; 
  D1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_C' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_C'|| CHR(30); 
BEGIN 
  Output_Type_Api.New__(C1,B1,A1,D1,'DO'); 
END;
/

declare 
  A1 VARCHAR2(50) := NULL; 
  B1 VARCHAR2(50) := NULL; 
  C1 VARCHAR2(50) := NULL; 
  D1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_N' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_N'|| CHR(30); 
BEGIN 
  Output_Type_Api.New__(C1,B1,A1,D1,'DO'); 
END;
/

DECLARE 
  A1 VARCHAR2(50) := NULL; 
  B1 VARCHAR2(50) := NULL; 
  C1 VARCHAR2(50) := NULL; 
  D1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_O' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_O'|| CHR(30); 
BEGIN 
  Output_Type_Api.New__(C1,B1,A1,D1,'DO'); 
END;
/

Open in new window

0
 
LVL 32

Expert Comment

by:awking00
ID: 34283536
declare
  A1 VARCHAR2(50) := NULL;
  B1 VARCHAR2(50) := NULL;
  C1 VARCHAR2(50) := NULL;
  D1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_C' || CHR(30) || 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_C'|| CHR(30);
  E1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_N' || CHR(30)
|| 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_N'|| CHR(30);
  F1 VARCHAR2(50) := 'OUTPUT_TYPE' || CHR(31) ||'.A4/TA4J_O' || CHR(30)
|| 'DESCRIPTION' || CHR(31) ||'.A-4/TA-4J_O'|| CHR(30);
BEGIN
  Output_Type_Api.New__(C1,B1,A1,D1,'DO');
  Output_Type_Api.New__(C1,B1,A1,E1,'DO');
  Output_Type_Api.New__(C1,B1,A1,F1,'DO');
END;
/

0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 400 total points
ID: 34283560
Does the attached do what you want?
comment.txt
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question