Solved

ORACLE -- run multiple statements at once ?

Posted on 2010-11-23
7
841 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 32

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 37

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 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 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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Oracle data into XML document 2 65
How to free up undo space? 3 39
SQL query question 8 73
Not able to drop or recreate an Oracle stored procedure 1 26
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

815 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

12 Experts available now in Live!

Get 1:1 Help Now