Solved

ORACLE -- run multiple statements at once ?

Posted on 2010-11-23
7
832 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 100 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 100 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 31

Expert Comment

by:awking00
ID: 34198662
I think you need a "/" after each "end;" statement.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 100 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 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 100 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 31

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 31

Assisted Solution

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now