Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ORACLE -- run multiple statements at once ?

Posted on 2010-11-23
7
Medium Priority
?
852 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

722 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