Script that exec other scripts - plsql

I want to execute this script in PL/SQL but it keeps getting error
set serveroutput on;
set echo on;
declare
v_code varchar2(250);
v_errm varchar2(250);
begin
##"1.sql";
##"2.sql";
##"II_load_438865311678_Reg.sql";
exception
when others then
v_code := sqlcode;
v_errm := substr(sqlerrm, 1, 64);
DBMS_OUTPUT.PUT_LINE('ERROR! - '||DBMS_UTILITY.FORMAT_ERROR_STACK|| DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
rollback;
end;
/
What is wrong with this.
Error: ORA-06550: line 5, colunm 3: (...) ORA-06550: line 6, colunm 3:
(...) ORA-06550: line 7, colunm 3: PLS-00103: Encountered the symbol
"#" when expecting one of the following: ( begin case declare end
exception exit for goto if loop mod null pragma raise return select
update while with... and
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

You only use the PL/SQL code to show the error. That is not necessary; SQL*Plus will already show you any SQL error. Use whenever sqlerror to trigger the rollback.
whenever sqlerror continue rollback
##"1.sql"
##"2.sql"
##"II_load_438865311678_Reg.sql"

Related

ORA-06550: line 1, column 65: PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:

My code
CREATE OR REPLACE PROCEDURE myproc IS
CurrDep Number;
Tot Number;
accm Number;
Cursor Cur_lcd is
select * from Courier_Scanner;
Cur_row Courier_Scanner%rowtype;
Begin
for Cur_row in Cur_lcd
Loop
CurrDep := (Cur_row.PURCHASE_PRICE- Cur_row.SALVAGE)/Cur_row.LIFE_SPAN;
accm:= Cur_row.TOTAL_ACC_DEP;
Tot := CurrDep + accm;
Update Courier_Scanner
set CURR_PRED_DEP = Currdep,
TOTAL_ACC_DEP = Tot,
NET_VALUE = Cur_row.PURCHASE_PRICE-Tot
ACCUMULATED_DEP = accm
where SC_NO = Cur_row.SC_NO;
end loop;
commit;
END myproc;
ERROR:
ORA-06550: line 1, column 65: PLS-00103: Encountered the symbol "CREATE"
when expecting one of the following: ( begin case declare exit for goto
if loop mod null pragma raise return select update while with <an
identifier> <a double-
Can anyone help me out by pointing out the exact error in the procedure. I have spent hours, but couldn't see any.
There is a comma(,) missing in update statement at the line
NET_VALUE= Cur_row.PURCHASE_PRICE-Tot ACCUMULATED_DEP=accm where
SC_NO =Cur_row.SC_NO;
Correct it as below:
UPDATE Courier_Scanner
SET CURR_PRED_DEP = Currdep,
TOTAL_ACC_DEP = Tot,
NET_VALUE = Cur_row.PURCHASE_PRICE - Tot,
ACCUMULATED_DEP = accm
WHERE SC_NO = Cur_row.SC_NO;
There is absolutely nothing wrong with that stored procedure. Just be sure to put a forward slash on a separate line after each PL/SQL block that you are compiling if you are using TOAD or SQL*Plus. Forward slash is the default block terminator in TOAD and SQL*Plus.

PL/SQL compilation error

What is wrong with the following statement:
DECLARE
int_exists INTEGER;
BEGIN
SELECT COUNT(ItemKey)
INTO int_exists
FROM BIR_TabsForDashboard
WHERE ItemKey = 'Position';
IF( int_exists = 0 ) THEN --doesnt exist
EXECUTE IMMEDIATE 'ALTER TABLE BIR_TabsForDashboard ADD Position int NULL';
END IF;
END;
I get this report error:
ORA-06550: line 7, column 9:
PL/SQL: ORA-00904: "ITEMKEY": invalid identifier
ORA-06550: line 4, column 3:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
What could be wrong? It seems to work when I use it on another table but for some reason it comes up with this error when I do it to this specific table?
The table BIR_TabsForDashboard does not have a column named ItemKey.
Make sure the procedure which you are using is should properly declared in the place which you are using it. For an example if it is under an another user and in an another package then it should be in that same order. The username, package and procedure name.

Oracle DBMS_SCHEDULER.DROP_JOB fails to drop a job

In Oracle 11g, I am trying to drop a job; but, it gives me the below error:
SQL> exec DBMS_SCHEDULER.DROP_JOB(job_name => "MyCaseSensitiveJobName");
BEGIN DBMS_SCHEDULER.DROP_JOB(job_name => "MyCaseSensitiveJobName"); END;
*
ERROR at line 1:
ORA-06550: line 1, column 44:
PLS-00905: object Job_Owner.MyCaseSensitiveJobName is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Please help! Thanks!
For anyone interested, I found my mistake!
The below execution was successful:
SQL> exec DBMS_SCHEDULER.DROP_JOB(job_name => '"MyCaseSensitiveJobName"');
PL/SQL procedure successfully completed.
i.e. I should have wrapped the double-quoted job name in single qoutes!

PLSQL record created with %rowtype being used as element for table gives compile/run error

I am declaring a table custom data-type of a record , the record is created by %rowtype of a table nemed : TMP_UNREGISTER_TAB , this table exists in the DB . While trying to execute the below plsql anon block i get the error specified below.
PLSQL CODE:
declare
rec_tmp_tab TMP_UNREGISTER_TAB%rowtype ;
v_rec_tmp_tab rec_tmp_tab;
TYPE tab_rec_tmp IS TABLE OF v_rec_tmp_tab%type
INDEX BY BINARY_INTEGER;
v_tab_rec_tmp tab_rec_tmp;
begin
null;
end;
/
SCRIPT OUTPUT:
Error report:
ORA-06550: line 3, column 18:
PLS-00488: 'REC_TMP_TAB' must be a type
ORA-06550: line 3, column 18:
PL/SQL: Item ignored
ORA-06550: line 4, column 33:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 4, column 4:
PL/SQL: Item ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
declare
rec_tmp_tab TMP_UNREGISTER_TAB%rowtype ;
TYPE tab_rec_tmp IS TABLE OF TMP_UNREGISTER_TAB%rowtype
INDEX BY BINARY_INTEGER;
v_tab_rec_tmp tab_rec_tmp;
begin
null;
end;
/

how to execute pl/sql procedure

Procedure:
create or replace
PROCEDURE ADDITION
(
A IN NUMBER
, B IN NUMBER
, C OUT number
) AS
BEGIN
C := A+B;
dbms_output.put_line(c);
END ADDITION;
executing:
begin
addition(4,5);
end;
Error:
PLS-00306: wrong number or types of arguments in call to 'ADDITION'
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
How to rectify this error.Let me know what is the wrong in code
Your procedure expects an out parameter which you also need to provide:
declare
add_result number;
begin
addition(4,5,add_result);
end;
/

Resources