Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I get the following error:
58/6 PLS-00103: Encountered the symbol "END" when expecting one of
the following:
begin function pragma procedure subtype type
current cursor delete
exists prior
Anyone have any idea what I am missing?
CREATE OR REPLACE PROCEDURE VALIDATE_BI_JOB_COMPLETE_PROC AS
msg SYS.XMLTYPE;
msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
msg_id RAW(16);
queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
rec_count INTEGER;
/******************************************************************************
NAME: VALIDATE_BI_JOB_COMPLETE_PROC
*******************************************************************************
BEGIN
INSERT INTO JOB_LOG
(JOB_NAME, JOB_SEQUENCE, RUN_DATE, LINE_SEQ_NO, LOG_TXT)
VALUES
($$PLSQL_UNIT, 1, SYSDATE, 1, 'Job Started at ' || to_char(sysdate, 'MM/DD/YYYY HH:MI:SS'));
COMMIT;
rec_count := 0;
SELECT COUNT(*) INTO rec_count
FROM SCHEDULED_JOBS
WHERE JOB_NAME IN ('bi_get_transactional_data', 'bi_get_reference_data') AND
CURRENTLY_PROCESSING_FLG = 'Y';
IF rec_count > 0 THEN
BEGIN
DECLARE CURSOR email IS
SELECT EMAIL_ID
FROM ERROR_EMAIL_NOTIFICATION
WHERE ACTIVE = 'Y' AND
SEVERITY_CD = 'ERROR';
vFROM VARCHAR2(30) := 'WORK_SYSTEM#XXX.COM';
vTYPE VARCHAR2(30) := 'text/plain; charset=us-ascii';
msg_body VARCHAR2(4000) := 'BI jobs are still running, please investigate.
bi_get_transactional_data, bi_get_reference_data)';
crlf CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
FOR email_rec IN email
LOOP
utl_mail.send(vFROM, email_rec.EMAIL_ID, NULL, NULL, ora_database_name || ': ' ,
msg_body, vTYPE, NULL);
END LOOP;
END;
END IF;
INSERT INTO JOB_LOG
(JOB_NAME, JOB_SEQUENCE, RUN_DATE, LINE_SEQ_NO, LOG_TXT)
VALUES
($$PLSQL_UNIT, 2, SYSDATE, 1, 'Job Ended at ' || to_char(sysdate, 'MM/DD/YYYY HH:MI:SS') ||
'. Records sent to JSSO: ' || rec_processed);
COMMIT;
-- exception processing goes here
EXCEPTION
WHEN OTHERS THEN
LOG_ERROR(
p_APP_ID => 'ORACLE',
p_SEVERITY_CD => 'ERROR',
p_ROUTINE_NAME => $$PLSQL_UNIT,
p_BACKTRACE => DBMS_UTILITY.FORMAT_ERROR_BACKTRACE,
p_SQL_CODE => SQLCODE,
p_LOG_TXT => SQLERRM,
p_HOST_ID => SYS_CONTEXT('userenv', 'host'),
p_USER_ID => SYS_CONTEXT('userenv', 'session_user'),
p_SESSION_ID => SYS_CONTEXT('userenv', 'sid'));
INSERT INTO JOB_LOG
(JOB_NAME, JOB_SEQUENCE, RUN_DATE, LINE_SEQ_NO, LOG_TXT)
VALUES
($$PLSQL_UNIT, 2, SYSDATE, 1, 'Job ABENDED at ' || to_char(sysdate, 'MM/DD/YYYY
HH:MI:SS') || '. Error condtion.');
COMMIT;
END;
/
You must move your BEGIN from the 28 line to the line 41. Instead of this:
IF rec_count > 0 THEN
BEGIN <----------------------------------------- THIS IS WRONG
DECLARE CURSOR email IS
SELECT EMAIL_ID
FROM ERROR_EMAIL_NOTIFICATION
WHERE ACTIVE = 'Y' AND
SEVERITY_CD = 'ERROR';
vFROM VARCHAR2(30) := 'WORK_SYSTEM#XXX.COM';
vTYPE VARCHAR2(30) := 'text/plain; charset=us-ascii';
msg_body VARCHAR2(4000) := 'BI jobs are still running, please investigate.
bi_get_transactional_data, bi_get_reference_data)';
crlf CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
FOR email_rec IN email
LOOP
Write this:
IF rec_count > 0 THEN
DECLARE CURSOR email IS
SELECT EMAIL_ID
FROM ERROR_EMAIL_NOTIFICATION
WHERE ACTIVE = 'Y' AND
SEVERITY_CD = 'ERROR';
vFROM VARCHAR2(30) := 'WORK_SYSTEM#XXX.COM';
vTYPE VARCHAR2(30) := 'text/plain; charset=us-ascii';
msg_body VARCHAR2(4000) := 'BI jobs are still running, please investigate.
bi_get_transactional_data, bi_get_reference_data)';
crlf CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
BEGIN <-------------------------------------------- THIS IS OK
FOR email_rec IN email
LOOP
You have an END; just before your END IF; which is causing the problem
So Oracle thinks the IF statement is not closed. Plus it will ignore all the code after the END!
IF rec_count > 0 THEN
BEGIN
DECLARE
CURSOR email IS
SELECT EMAIL_ID
FROM ERROR_EMAIL_NOTIFICATION
WHERE ACTIVE = 'Y' AND
SEVERITY_CD = 'ERROR';
vFROM VARCHAR2(30) := 'WORK_SYSTEM#XXX.COM';
vTYPE VARCHAR2(30) := 'text/plain; charset=us-ascii';
msg_body VARCHAR2(4000) := 'BI jobs are still running, please investigate.
bi_get_transactional_data, bi_get_reference_data)';
crlf CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
BEGIN
FOR email_rec IN email
LOOP
utl_mail.send(vFROM, email_rec.EMAIL_ID, NULL, NULL, ora_database_name || ': ' ,
msg_body, vTYPE, NULL);
END LOOP;
END;
END;
END IF;
--rest of the code
The problem was that, after the 'DECLARE' you need to add a 'BEGIN', and an 'END' following the 'END LOOP'. I hope you understood. Also that makes me wonder, do you need the 'BEGIN' you have added just above the 'DECLARE' there? Hope this solves it :)
Related
I am a newbie in PL/SQL
I have an PL SQL. And im getting an error shown in the title. ORA 6502 character string buffer too small.
create or replace
PROCEDURE MailSender IS
tmpVar VARCHAR2(2048);
BEGIN
FOR cur_rec IN
(SELECT * FROM dom_email1 where rownum <= 50 and eto is not null ORDER BY eid asc)
LOOP
tmpVar := ltrim(cur_rec.ETO, ' ; ');
tmpVar := rtrim(tmpVar, '; ');
tmpVar := rtrim(tmpVar, ' ');
DOMSYS_EMAIL.SEND_EMAIL(msg_from => 'noreply#gmail.com'
, msg_tos => tmpVar
, msg_subject => cur_rec.SUBJ
, msg_text => cur_rec.MSG
, mailhost => '10.63.17.38');
UPDATE DOM_EMAIL1 SET eid='1' WHERE eid= cur_rec.EID;
END LOOP;
DELETE FROM DOM_EMAIL1 WHERE eid='1';
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END MailSender;
Issue is due to the size is not satisfied for any of the below variables/cursor value you are passing in your procedure
tmpVar
cur_rec.SUBJ
cur_rec.MSG
Add the below line in your procedure before send mail (DOMSYS_EMAIL.SEND_EMAIL) to validate the size of each value you passed and check whether it satisfies the parameter size limit of the DOMSYS_EMAIL.SEND_EMAIL procedure
dbms_output.put_line('tmpVar :' || length(tmpVar) ||' - '|| 'cur_rec.SUBJ :'|| length(cur_rec.SUBJ) ||' - '|| 'cur_rec.MSG :' || length(cur_rec.MSG));
For varchar2,you can update the size limit if required after validation
I have a pl/sql query and I want it's output to be sent in email in CSV format straightaway. I have no directory to first create and save a CSV file and then pick it up to send as an attachment.
Please help with your inputs as I am not able to get away.
Regards,
Sachin
Finally figured out a solution with the help of pointers received and providing the same to further help in case someone else needs in future.
My problem was that I was mostly seeing the examples where i could either save the file on a directory or pick the file from a directory to send as an attchment but I had no provision of directory and I wanted query result to be put in CSV and sent in email dynamically. So here is the complete solution.
CREATE OR REPLACE PROCEDURE SEND_CSV_ATTACHMENT AS
v_sender VARCHAR2(130);
v_recipients VARCHAR2(4000);
v_cc VARCHAR2(4000);
v_bcc VARCHAR2(2000);
v_subj VARCHAR2(200);
v_msg CLOB;
v_mime VARCHAR2(40);
v_tbl VARCHAR2(20000);
c_cr_lf CONSTANT CHAR (2) := (CHR (13) || CHR (10)); -- Carriage Return/Line Feed characters for formatting text emails
v_loop_count PLS_INTEGER := 0;
v_attachment CLOB;
v_block_qry VARCHAR2(3000);
v_block_row VARCHAR2(6000);
TYPE bl_cur IS REF CURSOR;
v_result bl_cur;
v_rowcount NUMBER;
errMsg VARCHAR2(15000);
BEGIN
v_sender := 'somesender#xyzcommunications.com';
SELECT NVL(EMAIL_LIST, 'someone#abcd.com')
FROM
(
SELECT LISTAGG(EMAIL_ID, ',') WITHIN GROUP (ORDER BY EMAIL_ID) AS EMAIL_LIST FROM RECIPEINTS_TABLE WHERE SEND_TO = 1 AND IS_ACTIVE = 1
);
SELECT NVL(EMAIL_LIST, 'someone#abcd.com')
FROM
(
SELECT LISTAGG(EMAIL_ID, ',') WITHIN GROUP (ORDER BY EMAIL_ID) AS EMAIL_LIST FROM RECIPEINTS_TABLE WHERE SEND_CC = 1 AND IS_ACTIVE = 1
);
v_bcc := 'someone#abcd.com';
-- Generate attachment - Begin
v_attachment := '"COL1", "COL2"' || CHR(13) || CHR(10);
v_block_qry := 'SELECT ''"'' || COL1 || ''", "'' || COL2 || ''"'' AS ROWTXT
FROM MY_TABLE';
OPEN v_result FOR v_block_qry;
LOOP
v_rowcount := v_result%ROWCOUNT;
FETCH v_result INTO v_block_row;
EXIT WHEN v_result%NOTFOUND;
v_attachment := v_attachment || v_block_row || chr(13) || chr(10);
END LOOP;
CLOSE v_result;
-- Generate attachment - End
v_subj:= 'MAIL_SUBJECT ' || TO_CHAR(TRUNC(SYSDATE-1), 'YYYY-MM-DD');
UTL_MAIL.send_attach_varchar2(sender => v_sender,
recipients => v_recipients,
cc => v_cc,
bcc => v_bcc,
subject => v_subj,
message => v_msg,
mime_type => 'text/html; charset=us-ascii', -- send html e-mail
attachment => v_attachment,
att_inline => FALSE,
att_filename => 'Change_Report' || TO_CHAR(TRUNC(SYSDATE-1), 'YYYY-MM-DD') || '.csv');
EXCEPTION
WHEN OTHERS THEN
errMsg := SQLERRM;
SEND_MAIL_HTML ('someone#abcd.com', NULL, NULL, errMsg, 'SEND_MAIL ERROR: ' || errMsg);
END SEND_CSV_ATTACHMENT;
You may create such a procedure :
create or replace procedure prFileSend is
v_mail_owner varchar2(100):='myname#someComp.com';
v_url varchar2(4000);
v_rep varchar2(4000);
delimiter varchar2(1) := chr(38);
begin
for c in ( select * from myTable )
loop
begin
v_url := 'http://www.mycompany.com/einfo/default.aspx?email='||c.email || delimiter || 'p1=' || c.col1 || delimiter ||'p2='||c.col2;
v_rep := utl_http.request(utl_url.escape(v_url, false,'ISO-8859-9'));
end;
end loop;
exception
when others then
prErrorMsgSend(v_mail_owner,'Error : ' || sqlerrm); -- a function like this one which sends an error message back to you.
end;
and create a scheduler job
begin
dbms_scheduler.create_job (
job_name => 'jbFileSend ',
job_type => 'STORED_PROCEDURE',
job_action => 'prFileSend',
start_date => '22-jan-2018 09:00:00 am',
repeat_interval => 'FREQ=DAILY; INTERVAL=1',
comments => 'Sending Every day'
enabled => true);
end;
working every day as an example.
I have oracle pl/sql procedure with below:
TYPE Paycomp2 IS RECORD(
Row_Id VARCHAR2(15),
Created DATE,
Created_By VARCHAR2(15),
Last_Upd DATE,
Last_Upd_By VARCHAR2(15),
Modification_Num NUMBER(10),
Conflict_Id VARCHAR2(15),
Comp_Price NUMBER(10),
Access_Level VARCHAR2(30),
Comp_Name VARCHAR2(30),
Depends_On VARCHAR2(30),
Gold_Cat VARCHAR2(30),
Order_Type VARCHAR2(30),
Parent_Id VARCHAR2(15),
Price_Plan VARCHAR2(30),
TYPE VARCHAR2(30),
Check_Flag VARCHAR2(1),
PREPAID_INIT_PRICE number(10),
DB_LAST_UPD date,
DB_LAST_UPD_SRC varchar2(50),
Unit_Type varchar2(30),
M2M_CATEGORY varchar2(30));
TYPE Paycomp IS REF CURSOR;
C2 Paycomp;
Cursor2 Paycomp2;
when I do the below operation
FETCH C2 INTO Cursor2;
I am getting this error :
ORA-01007: variable not in select list error.
This piece of script has worked previously.
How to resolve this issue?
script
Vordertype := 'Migration Prepaid - Postpaid';
Curcomp_Sql := Curcomp_Sql || Vordertype || '''' || ' union all ' || '' || Curcomp2sql || '' ||
Vordertype || '''';
OPEN C2 FOR Curcomp_Sql;
Sadmin.Pkg_Spliter.Prcsplitchar(Ppaycompstr, ';', Arrcomplist);
Vtotalcompprc := 0;
Arrcount := Arrcomplist.Count;
BEGIN
Dbms_output.put_line('reached17');
LOOP
FETCH C2
INTO Cursor2;
Dbms_output.put_line('reached18');
EXIT WHEN C2%NOTFOUND;
-- Processing each entry from Array
Compfndflg := 0;
dbms_output.put_line('arrCount 0: reached');
FOR Counter IN 1 .. Arrcount
LOOP
Vstrcommand := Arrcomplist(Counter);
dbms_output.put_line('arrCount : reached');
Sadmin.Pkg_Spliter.Prcsplitchar(Vstrcommand, '?', Arrdisclist);
IF Arrdisclist.Count <> 0 THEN
dbms_output.put_line('arrCount : reached1');
-- Extracting the ? seperated values and putting them into variables
Vcompname := Arrdisclist(1);
--dbms_output.put_line(CURSOR2.comp_name||':- count -'||COUNTER||'--'||VCOMPNAME);
BEGIN
-- Added by Accenture
IF Vcompname IS NOT NULL THEN
--dbms_output.put_line(CURSOR2.comp_name||':- count -'||COUNTER||'--'||ARRDISCLIST(1)||'-'||ARRDISCLIST(2)||'-'||ARRDISCLIST(3));
SELECT COUNT(0)
INTO v_Count_Exist
FROM Siebel.Cx_Paycomp_Mtx a, Siebel.Cx_Paycomp_Mtx b
WHERE a.Row_Id = b.Parent_Id
AND a.Order_Type = Vordertype
AND b.Type = 'Payment Component'
AND b.Comp_Name = Vcompname;
IF (v_Count_Exist = 0) THEN
Err_Msg := 'Invalid Payment Component in String';
Result_Out := '74';
Errflg := 1;
--dbms_output.put_line('Counter 2' || counter);
--dbms_transaction.rollback;
RAISE Error_Out;
END IF;
END IF;
--dbms_output.put_line('Counter 3' || CURSOR2.comp_name);
IF Vcompname = Cursor2.Comp_Name
--and VCOMPNAME != '3'
THEN
Compfndflg := 1;
EXIT;
END IF;
END;
END IF;
END LOOP;
---DBMS_OUTPUT.PUT_LINE('VCOMPNAME, COMPFNDFLG'||VCOMPNAME||','||COMPFNDFLG);
--dbms_output.put_line('CURSOR2.comp_name :'||CURSOR2.comp_name||' - COMPFNDFLG :'||COMPFNDFLG);
IF Compfndflg != 1 THEN
IF Temp_Comp_String IS NULL THEN
Temp_Comp_String := Cursor2.Comp_Name || '?0?;';
---DBMS_OUTPUT.PUT_LINE('STRING 1'||TEMP_COMP_STRING);
ELSE
Temp_Comp_String := Temp_Comp_String || Cursor2.Comp_Name || '?0?;';
---DBMS_OUTPUT.PUT_LINE('STRING 2'||TEMP_COMP_STRING);
END IF;
--- END IF;
ELSE
IF Temp_Comp_String IS NULL THEN
Temp_Comp_String := Arrdisclist(1) || '?' || Arrdisclist(2) || '?' ||
Arrdisclist(3) || ';';
---DBMS_OUTPUT.PUT_LINE('STRING 3'||TEMP_COMP_STRING);
ELSE
Temp_Comp_String := Temp_Comp_String || Arrdisclist(1) || '?' || Arrdisclist(2) || '?' ||
Arrdisclist(3) || ';';
---DBMS_OUTPUT.PUT_LINE('STRING 4'||TEMP_COMP_STRING);
END IF;
-- end if;
--- END IF;
END IF;
END LOOP;
END;
Curcomp_Sql VARCHAR2(2000) := 'SELECT mtx2.*
FROM siebel.CX_PAYCOMP_MTX mtx1, siebel.CX_PAYCOMP_MTX mtx2
WHERE mtx2.parent_id = mtx1.row_id
AND mtx2.comp_name <> ''Security Deposit''
AND mtx2.TYPE = ''Payment Component''
AND mtx1.order_type = ''';
Curcomp2sql VARCHAR2(2000) := 'SELECT mtx2.*
FROM siebel.CX_PAYCOMP_MTX mtx1, siebel.CX_PAYCOMP_MTX mtx2
WHERE mtx2.parent_id = mtx1.row_id
AND mtx2.comp_name = ''Security Deposit''
AND mtx2.TYPE = ''Payment Component''
AND mtx2.depends_on = ''ACCESS LEVEL''
AND mtx1.order_type = ''';
A simplified version of what you're seeing, with a dummy table and simple anonymous block:
create table t42 (id number, some_value varchar2(10));
declare
type t_rec is record(id number, some_value varchar2(10));
l_rec t_rec;
l_cur sys_refcursor;
begin
open l_cur for 'select * from t42';
fetch l_cur into l_rec;
close l_cur;
end;
/
PL/SQL procedure successfully completed.
To get the error you're seeing I just need to remove one of the table columns:
alter table t42 drop column some_value;
and run exactly the same code again:
declare
type t_rec is record(id number, some_value varchar2(10));
l_rec t_rec;
l_cur sys_refcursor;
begin
open l_cur for 'select * from t42';
fetch l_cur into l_rec;
close l_cur;
end;
/
ORA-01007: variable not in select list
ORA-06512: at line 10
The field list in the record type declared in the PL/SQL block no longer matches the column type in the cursor query. The record variable you're fetching into expects two columns (in my version; 22 in yours), but the query only gets one value.
You can (some would say should) specify all the columns you're selecting explicitly, but assuming you're actually referring to them all later you would then have done the equivalent of:
open l_cur for 'select id, some_value from t42';
which would still have errored after the column removal, though a bit more helpfully perhaps:
ORA-00904: "SOME_VALUE": invalid identifier
ORA-06512: at line 9
Since you're currently intending to get all columns from a single table, you could also have used the %rowtype syntax instead of your own record type:
declare
l_rec t42%rowtype;
l_cur sys_refcursor;
begin
open l_cur for 'select * from t42';
fetch l_cur into l_rec;
close l_cur;
end;
/
which with this trivial example runs successfully. You'll still have a problem though as soon as you refer to the removed column, assuming it's still part of the record:
declare
l_rec t42%rowtype;
l_cur sys_refcursor;
begin
open l_cur for 'select * from t42';
fetch l_cur into l_rec;
dbms_output.put_line(l_rec.some_value);
close l_cur;
end;
/
ORA-06550: line 7, column 30:
PLS-00302: component 'SOME_VALUE' must be declared
ORA-06550: line 7, column 3:
PL/SQL: Statement ignored
(Using %rowtype would give you some breathing space if a column was added, as it would just be ignored, unless and until you added code to refer to that record field. But with your code you'd get ORA-00932 inconsistent data types, rather than ORA-01007, so that doesn't seem to be what's happening here.)
If you aren't referring to the removed column/field anywhere then you shouldn't be selecting it anyway. Change the record type to only include the fields you actually need, and only get the corresponding columns in the cursor query.
If you are referring to the removed column/field then you're stuck anyway - you'll have find out what was removed and why, and then either fix your code to not refer to it (if that makes sense), or get that change reverted.
I have the below script , i want to modify it such a way lets say if it is executed first time then it will create the column but lets say if it is executed second time then it will show fail message which is not correct it should show the message that column is created and also if there comes any exception lets say column i s not created due to some technical exception then it should show fail message , please advise how to achieve this
SELECT COUNT(*) INTO L_COL_EXISTS FROM USER_TAB_COLS WHERE COLUMN_NAME = 'TOR' and TABLE_NAME='AVOICE';
IF L_COL_EXISTS = 1
THEN
outcome := 'Success';
ELSE
outcome := 'Fail';
END IF;
DBMS_OUTPUT.PUT_LINE(outcome);
folks please advise
I suppose it can help you
CREATE OR REPLACE PROCEDURE add_column
(
v_table_name IN VARCHAR2,
v_column_name IN VARCHAR2,
v_column_type IN VARCHAR2
)
IS
v_column_exists pls_integer;
v_ddl_str varchar2(1024);
BEGIN
BEGIN
SELECT count(*)
INTO v_column_exists
FROM user_tab_columns
WHERE table_name = upper(v_table_name)
and column_name = upper(v_column_name);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
if v_column_exists = 0 then
v_ddl_str := 'alter table ' || v_table_name || ' add ( ' || v_column_name || ' ' || v_column_type || ')';
BEGIN
EXECUTE IMMEDIATE alter_str;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line ('something wrong');
RAISE;
END;
ELSE
dbms_output.put_line ('Column exists');
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END add_column;
/
I wrote the following Package.
When I compile it I got the following error:
PLS-00103: Encountered the symbol "("
Line 42 Column 66
Which is "PROCEDURE p_fail "
I am helpless. I searched the Internet but found nothing what helps me.
Does anyone has an idea?
Many thanks in advance.
CREATE OR REPLACE PACKAGE BODY boxi_rep.pck_jk_test AS
PROCEDURE p_main
IS
err_num NUMBER;
err_msg VARCHAR2 (200);
BEGIN
boxi_rep.pck_jk_test.p_start;
boxi_rep.pck_jk_test.p_truncate;
EXCEPTION
WHEN OTHERS
THEN
err_num := SQLCODE;
err_msg := SUBSTR (SQLERRM, 1, 200);
boxi_rep.pck_jk_test.p_fail (err_num, err_msg);
END;
PROCEDURE p_start
IS
BEGIN
/*Make start entry into Log_Jobs*/
DELETE FROM log_jobs
WHERE job_id = '1501'
AND TRUNC (datum) = TRUNC (SYSDATE)
AND end_timestamp IS NULL;
INSERT INTO log_jobs (job_id,
job_name,
datum,
start_timestamp)
VALUES ('1501',
'V$Re_Schedule TEST',
TRUNC (SYSDATE),
SYSDATE);
COMMIT;
END;
PROCEDURE p_fail (in_err_code IN NUMBER, in_err_msg IN VARCHAR2 (200))
IS
BEGIN
UPDATE log_jobs
SET end_timestamp = SYSDATE,
status = 'FAILED - ' || in_err_code || ' - ' || in_err_msg,
duration = TO_CHAR (TO_DATE ('00:00:00', 'hh24:mi:ss') + (SYSDATE - start_timestamp), 'hh24:mi:ss')
WHERE job_id = '1501'
AND end_timestamp IS NULL;
COMMIT;
END;
PROCEDURE p_truncate
IS
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE boxi_rep.jk_test';
END;
END pck_jk_test;
See http://docs.oracle.com/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#i1006401
Numerically constrained types such as NUMBER(2) or VARCHAR2(20) are not allowed in a parameter list.
Change
PROCEDURE p_fail (in_err_code IN NUMBER, in_err_msg IN VARCHAR2 (200))
to
PROCEDURE p_fail (in_err_code IN NUMBER, in_err_msg IN VARCHAR2)
Size of varchar2 is not allowed with in and out partameter
PROCEDURE p_fail (in_err_code IN NUMBER, in_err_msg IN VARCHAR2)
IS
BEGIN
UPDATE log_jobs
SET end_timestamp = SYSDATE,
status = 'FAILED - ' || in_err_code || ' - ' || in_err_msg,
duration = TO_CHAR (TO_DATE ('00:00:00', 'hh24:mi:ss') + (SYSDATE - start_timestamp), 'hh24:mi:ss')
WHERE job_id = '1501'
AND end_timestamp IS NULL;
COMMIT;
END;