Solved

ORACLE -- run multiple statements at once ?

Posted on 2010-11-23
7
850 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 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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 38

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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ā€¦
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

630 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