Line no. of procedure
I have a doubt that whenever, there is a exception in a procedure, it shows the line no. But, how to look at the exact line no., is it by counting the line no. or in SQL Plus editor. Problem with SQL editor is that if the procedure is very long, then it does not show all the code in SQL editor.
If, the exact line no. is known, then it helps a lot in de-bugging.
I hope, my question is clear. Please help in solving the doubt.
regards.
rem file = f_demo.sql
create or replace
function f_demo return varchar2 is
l_dummy varchar2(300);
begin
select 'x'
into l_dummy
from dual
l_dummy := to_char(1/0) ;
return l_dummy;
-- exception
-- when others then
-- l_dummy := sqlerrm;
-- raise_application_error (-20001,l_dummy);
end ;
file = test_err.sql
col line format 99990
col text format a80 word_wrap
set pagesize 9999
set linesize 1000
set verify off
select
decode (line,&2,'---->',' ') x
,line
,text
from
user_source
where
name = upper('&1')
and line >= &2 - 10
and line <= &2 + 10
order by
line
SQL> start f_demo
Function created.
SQL>
SQL> select f_demo from dual;
select f_demo from dual
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "E4ALL_DRP_P.F_DEMO", line 13
ORA-06512: at line 1
SQL>
SQL> start test_err f_demo 13
X LINE TEXT
3
4
5
6 begin
7
8 select 'x'
9 into l_dummy
10 from dual
11 ;
12
----> 13 l_dummy := to_char(1/0) ;
14
15 return l_dummy;
16
17 -- exception
18 -- when others then
19 -- l_dummy := sqlerrm;
20 -- raise_application_error (-20001,l_dummy);
21
22
23 end ;
21 rows selected.
SQL>
Similar Messages
-
Counting the number of lines for each procedure in a package
Hi,
I would like to write a query on USER_SOURCE that can display the number of code lines for each procedure/function in a package.
Is it possible to write such a query? Maybe by using analytical functions?
for example in the following example i would like to count the lines between "PROCEDURE proc1 IS" and "END proc1;" and between "PROCEDURE proc2 IS" and "END proc2;"
SQL> select text from user_source where name='PKG_TEST' and type='PACKAGE BODY';
TEXT
PACKAGE BODY PKG_TEST IS
PROCEDURE proc1 IS
BEGIN
update t1 set EDITION_NAME = 'AAAAAAA';
commit;
END proc1;
PROCEDURE proc2 IS
BEGIN
update t1 set EDITION_NAME = 'AAAAAAA';
commit;
END proc2;
END PKG_TEST;thanks for helpingonedbguru wrote:
Hopefully some idiot manager isn't trying to use this sort of thing to base their decisions on developer productivity. If so, they ARE idiots. Number of code lines NEVER, EVER, EVER!!! translates into an efficient application. If I were paid by the line, my code would look like:
select
1
from
dual
Based on the idiocy of this method of determining "performance" I would get paid $5.00 at $1.00/line. And trust me, I saw this back in the 80's and 90's and saw similar idiotic code and had to clean up the mess. Most of it wasn't efficient code to start with let alone the number of lines generated.Or the other extreme, when the PHB firmly believed that execution efficiency was gained by reducing the number of lines of code. So instead of nicely formatted, easy to read code:
*GET NEXT ORDER NUMBER
EXEC SQL
SELECT (MAX(ORDER_NUM) + 1)
INTO :NEXT-NUM:IND-NULL
FROM PART_ORDER
END-EXEC.
IF IND-NULL < 0
MOVE 1 TO NEXT-NUM.
EXEC SQL
INSERT
INTO PART_ORDER
(ORDER_NUM,
ORIGIN_LOC,
ORDER_TYPE,
ORDER_STAT,
CREAT_TIME)
VALUES (:NEXT-NUM,
:LOC, 'R', 'O',
CURRENT TIMESTAMP)
END-EXEC.
MOVE NEXT-NUM TO MASK0.
PERFORM HEADER-PROC THRU HEADER-EXIT.
CREATE-ORDER-EXIT. EXIT. You got this:
*GET NEXT ORDER NUMBER
EXEC SQL SELECT (MAX(ORDER_NUM) + 1) INTO :NEXT-NUM:IND-NULL FROM
PART_ORDER END-EXEC. IF IND-NULL < 0 MOVE 1 TO NEXT-NUM. EXEC SQL INSERT
INTO PART_ORDER (ORDER_NUM, ORIGIN_LOC, ORDER_TYPE, ORDER_STAT,
CREAT_TIME) VALUES (:NEXT-NUM, :LOC, 'R', 'O', CURRENT TIMESTAMP)
END-EXEC. MOVE NEXT-NUM TO MASK0. PERFORM HEADER-PROC THRU HEADER-EXIT.
CREATE-ORDER-EXIT. EXIT. Oh, wait! See the same thing all the time in this forum ... not because someone thinks fewer lines = faster code, but simply because people are sloppy.
INSERT INTO PART_ORDER(ORDER_NUM,ORIGIN_LOC,ORDER_TYPE,ORDER_STAT,CREAT_TIME) VALUES (:NEXT-NUM,:LOC, 'R', 'O',CURRENT TIMESTAMP) ; -
How to display multi line headings in procedural alv report
Hi experts,
How to display multi line heading in alv( procedural alv report) report.
some columns single line and some columns multi line in the same report.
ex:
solvent consumed solvent recovered
fresh | recovery recovery | spent batch no storage
I am using procedural alv .pls give me idea.Hi Ram,
Check the sample report [how to display multi line headings in procedural alv report|http://sample-code-abap.blogspot.com/2008/01/printing-multiple-line-header-and.html]
Thanks,
Duy -
Financial Accounting :line item extraction Procedure
hi there,
i have a question some one help me,
after extract the data from table, where it is goes?
is it in delta queue or direct into the PSA or data target.
Thanks,
RobsFeatures of the InfoSource
As of PlugIn2002.2, it is no longer necessary to have DataSources linked. This means that you can now load 0FI_GL_4, 0FI_AR_4, 0FI_AP_4 and 0FI_TX_4 in any order. You also have the option of using DataSources 0FI_AR_4, 0FI_AP_4 and 0FI_TX_4 separately without 0FI_GL_4. The DataSources can then be used independently of one another (see note 551044).
Note
As soon as DataSource 0FI_GL_4 is loaded, it is the leading DataSource with regard to the time limits such as maximum time (CPU date) up to which data extraction is allowed.
Therefore, when the transition is made from having data requirements in Delta Init mode to having them in pure Delta operation, the data requirement in delta mode of leading DataSource (OFI_GL_4) must be processed first.
Linking of DataSources in the delta helps to ensure consistent extraction of FI data with regard to time limits. Consistency with regard to the data extracted has to be ensured via the init selection criteria.
Note
This InfoSource is delta-compatible. However, due to the Delta procedure used (after image Delta) it is not suitable for loading InfoCubes directly. An ODS object can be used as data target in order to identify the changes made to individual InfoObjects when loading Delta data. -
Financial Accounting: Line Item Extraction Procedure - Help
Hi,
We are loading ODS object 0FIAR_O03 from datasource 0FI_AR_4.
1. Full load with data selection - COMP_CODE=0101;0FISCPER=2006001-2006012;
It loaded 2668 records in the ODS.
2. Then we deleted the full load request and tried to perform init data transfer with data to the same ODS from same datasource with same data selection.
Here it loaded 1504 records.
I guess in both the cases it should have loaded same no. of records.
Can anybody help me to find me why its not giving same no. of records in both the cases.
Thanx,
PreranaHi,
This is because, whenever we load a INIT / DELTA Load system checks for the TIMESTAMP and when we load a FULL load it does not.
I had a similar problem with a particular data load where we used to load Delta's continuously and once a particular Delta load failed. And the system was not able to recognize the failed delta, thats it was not able to find whether or not the last delta was GREEN/RED. Hence we had to do a INIT without Data Transfer which was recognized by system for the next Delta and it loaded fine.
Hence I came to know that it checks for the TIMESTAMP only in case of INIT / DELTA and NOT FULL.
Hope it helps,
Pradip Parmar -
Error encountered during execution of procedure....
Hi,
Im new to Oracle..just started with working with Oracle 10g in my company.Im trying to execute a procedure in SQL Developer 1.5.1 but getting this error as shown below.It would be great if anyone could help me out in it.
Error starting at line 3 in command:
EXECUTE EMP_PROC;
Error report:
ORA-06550: line 1, column 7:
PLS-00905: object SYSTEM.EMP_PROC is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
EMP_PROC is the Procedure im trying to execute.
**I have 2 tables namely Emp_INFO(emp_name,emp_id,dept_id,salary) and DEPT_INFO(dept_name,dept_id)...Im trying to display names of employess based on the range of salaries(low,mid,high)..
The code for this procedure is given below which also contains 3 functions...
/*Procedure EMP_PROC*/
CREATE OR REPLACE PROCEDURE EMP_PROC (sal_low IN NUMBER,
sal_mid IN NUMBER,
sal_high IN NUMBER) AS
/*Declaring variables to be used inside the Procedure*/
sal_low NUMBER(10,2) := 80000;
sal_mid NUMBER(10,2) := 300000;
sal_high NUMBER(10,2) := 500000;
s_low VARCHAR2(25);
s_mid VARCHAR2(25);
s_high VARCHAR2(25);
sal_range VARCHAR2(20);
/*Declaring User Defined Exception*/
usr_excp EXCEPTION;
/*Cursor for retrieving Low Salary Employees */
CURSOR cursor_lowSal IS
SELECT Emp_Name ,Emp_ID ,Dept_ID ,Dept_Name
FROM EMP_INFO,DEPT_INFO
WHERE Salary <= 80000;
/*Cursor for retrieving Mid Salary Employees */
CURSOR cursor_midSal IS
SELECT Emp_Name ,Emp_ID ,Dept_ID ,Dept_Name
FROM EMP_INFO,DEPT_INFO
WHERE Salary > 80000 OR Salary < 500000;
/*Cursor for retrieving High Salary Employees */
CURSOR cursor_highSal IS
SELECT Emp_Name ,Emp_ID ,Dept_ID ,Dept_Name
FROM EMP_INFO,DEPT_INFO
WHERE Salary > 500000;
/*Declaring variables that will hold values*/
e_name EMP_INFO.Emp_Name%TYPE;
e_id EMP_INFO.Emp_ID%TYPE;
d_name DEPT_INFO.Dept_Name%TYPE;
d_id EMP_INFO.Dept_ID%TYPE;
BEGIN
/*Enter the Salary range*/
sal_range := &sal_range;
/*Checking for Salary Range*/
IF sal_range == sal_low THEN
OPEN cursor_lowSal;
FETCH cursor_lowSal INTO e_name ,e_id ,d_name ,d_id;
/*Calling Function Low_Sal*/
s_low := funcLow_sal();
/*Displaying Output*/
dbms_output.put_line(s_low||'::'||e_name||','||e_id||','||d_name||','||d_id);
ELSIF sal_range == mid_sal THEN
OPEN cursor_midSal;
FETCH cursor_lowSal INTO e_name ,e_id ,d_name ,d_id;
/*Calling Function Mid_Sal*/
s_mid := funcMid_sal();
/*Displaying Output*/
dbms_output.put_line(s_mid||'::'||e_name||','||e_id||','||d_name||','||d_id);
ELSIF sal_range == sal_high THEN
OPEN cursor_highSal;
FETCH cursor_lowSal INTO e_name ,e_id ,d_name ,d_id;
/*Calling Function High_Sal*/
s_high := funcHigh_sal();
/*Displaying Output*/
dbms_output.put_line(s_high||'::'||e_name||','||e_id||','||d_name||','||d_id);
ELSE
/*Calling user defined Exception*/
RAISE usr_excp;
END IF;
/*Handling Exceptions*/
EXCEPTION
WHEN usr_excp THEN
dbms_output.put_line('Not in range,please try again!!');
WHEN OTHERS THEN
dbms_output.put_line('Exception');
/*Closing the cursor_lowSal*/
CLOSE cursor_lowSal;
/*Closing the cursor_midSal*/
CLOSE cursor_midSal;
/*Closing the cursor_highSal*/
CLOSE cursor_highSal;
END;
/*Function funcLow_sal*/
CREATE OR REPLACE FUNCTION funcLow_sal RETURN VARCHAR2 AS
BEGIN
return 'Employees with salary less than 80000'
END;
/*Function funcMid_sal*/
CREATE OR REPLACE FUNCTION funcMid_sal RETURN VARCHAR2 AS
BEGIN
return 'Employees with salary within 80000 and 500000'
END;
/*Function funcHigh_sal*/
CREATE OR REPLACE FUNCTION funcHigh_sal RETURN VARCHAR2 AS
BEGIN
return 'Employees with salary more than 500000'
END;
/*Executing the Procedure*/
SET SERVEROUTPUT ON
EXECUTE EMP_PROC;
Cheers...(')
Edited by: user10553245 on Nov 7, 2008 3:49 AMThe current version of code is given below.The 2 compliation errors i mentioned above are coming in the very First line of the procedure..the whole is highlited in red..
::Error(1): PL/SQL: Compilation unit analysis terminated
::Error(2,1): PLS-00410: duplicate fields in RECORD,TABLE or argument list are not permitted
create or replace PROCEDURE EMP_PROC (sal_low IN NUMBER , sal_mid IN NUMBER , sal_high IN NUMBER) AS
/*Declaring variables to be used inside the Procedure*/
sal_low NUMBER(10,2) := 80000;
sal_mid NUMBER(10,2) := 300000;
sal_high NUMBER(10,2) := 500000;
s_low VARCHAR2(25);
s_mid VARCHAR2(25);
s_high VARCHAR2(25);
sal_range VARCHAR2(20);
/*Declaring User Defined Exception*/
usr_excp EXCEPTION;
/*Cursor for retrieving Low Salary Employees */
CURSOR cursor_lowSal IS
SELECT Emp_Name ,Emp_ID ,Dept_ID ,Dept_Name
FROM EMP_INFO,DEPT_INFO
WHERE Salary <= 80000;
/*Cursor for retrieving Mid Salary Employees */
CURSOR cursor_midSal IS
SELECT Emp_Name ,Emp_ID ,Dept_ID ,Dept_Name
FROM EMP_INFO,DEPT_INFO
WHERE Salary > 80000 OR Salary < 500000;
/*Cursor for retrieving High Salary Employees */
CURSOR cursor_highSal IS
SELECT Emp_Name ,Emp_ID ,Dept_ID ,Dept_Name
FROM EMP_INFO,DEPT_INFO
WHERE Salary > 500000;
/*Declaring variables that will hold values*/
e_name EMP_INFO.Emp_Name%TYPE;
e_id EMP_INFO.Emp_ID%TYPE;
d_name DEPT_INFO.Dept_Name%TYPE;
d_id EMP_INFO.Dept_ID%TYPE;
BEGIN
/*Enter the Salary range*/
sal_range := '&sal_range';
/*Checking for Salary Range*/
IF sal_range = sal_low THEN
OPEN cursor_lowSal;
FETCH cursor_lowSal INTO e_name ,e_id ,d_name ,d_id;
/*Calling Function Low_Sal*/
s_low := funcLow_sal();
/*Displaying Output*/
dbms_output.put_line(s_low||'::'||e_name||','||e_id||','||d_name||','||d_id);
ELSIF sal_range = mid_sal THEN
OPEN cursor_midSal;
FETCH cursor_lowSal INTO e_name ,e_id ,d_name ,d_id;
/*Calling Function Mid_Sal*/
s_mid := funcMid_sal();
dbms_output.put_line(s_mid||'::'||e_name||','||e_id||','||d_name||','||d_id);
ELSIF sal_range = sal_high THEN
OPEN cursor_highSal;
FETCH cursor_lowSal INTO e_name ,e_id ,d_name ,d_id;
/*Calling Function High_Sal*/
s_high := funcHigh_sal();
dbms_output.put_line(s_high||'::'||e_name||','||e_id||','||d_name||','||d_id);
ELSE
/*Calling user defined Exception*/
RAISE usr_excp;
END IF;
EXCEPTION
WHEN usr_excp THEN
dbms_output.put_line('Not in range,please try again!!');
/*Closing the cursor_lowSal*/
CLOSE cursor_lowSal;
/*Closing the cursor_midSal*/
CLOSE cursor_midSal;
/*Closing the cursor_highSal*/
CLOSE cursor_highSal;
END EMP_PROC;
The 3 functions are just being used to display messages...
/*Function funcLow_sal*/
CREATE OR REPLACE FUNCTION funcLow_sal RETURN VARCHAR2 AS
BEGIN
return 'Employees with salary less than 80000'
END;
/*Function funcMid_sal*/
CREATE OR REPLACE FUNCTION funcMid_sal RETURN VARCHAR2 AS
BEGIN
return 'Employees with salary within 80000 and 500000'
END;
/*Function funcHigh_sal*/
CREATE OR REPLACE FUNCTION funcHigh_sal RETURN VARCHAR2 AS
BEGIN
return 'Employees with salary more than 500000'
END;
/ -
How to print new line using DBMS_OUTPUT package
Hi,
I am trying to print a new line using DBMS_OUTPUT package. but it do not print the new line.
set serveroutput on size 200000
set feedback on
BEGIN
DBMS_OUTPUT.PUT_LINE('First Line');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('Second Line');
END;
I expect following output ...
First Line
Second Line
but i got following output....
First Line
Second Line
why DBMS_OUTPUT.PUT_LINE( '); is not printing a new line ?You can try the following:
SQL> ED
Wrote file afiedt.buf
1 BEGIN
2 DBMS_OUTPUT.PUT('ONE LINE...');
3 DBMS_OUTPUT.PUT('SECOND LINE...');
4 DBMS_OUTPUT.NEW_LINE;
5 DBMS_OUTPUT.PUT_LINE('THIRD LINE WITH NEW LINE...');
6 DBMS_OUTPUT.PUT('TEST');
7 DBMS_OUTPUT.NEW_LINE;
8 DBMS_OUTPUT.PUT_LINE('FOURTH LINE'||CHR(10)||'EXAMPLE');
9 DBMS_OUTPUT.PUT_LINE(CHR(10));
10 DBMS_OUTPUT.PUT_LINE('FIFTH LINE');
11* END;
SQL> /
ONE LINE...SECOND LINE...
THIRD LINE WITH NEW LINE...
TEST
FOURTH LINE
EXAMPLE
FIFTH LINE
PL/SQL procedure successfully completed.Documentation:
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_output.htm#i1000062 -
RANT: Please post with a meaningful subject line
This is an SQL and PL/SQL forum. Almost all posts will be people needing help with a query, or in a PL/SQL procedure, so subject lines like
Stored Procedure
Please share your valuable experience
Need help on the below query
error while running PL/SQL
Query
Help need in this query
PL/SQL
Query - Help
Help
are essentially meaningless (those just in the last few hours).
If you're getting an error, put the error in the subject line.
If your query is slow, first read When your query takes too long ... and if that doesn't help then post with something in the subject line to indicate it's a performance related question.
If it's a "how to" question, use that e.g "how to calculate a rolling average".
Oh, and if your question is how to find the second highest salary in the department, don't bother posting at all.
Just a pet peeve brought to a head by this morning's threads.Agree and disagree with your comments APC.
Yes, the clueless and unwashed will not even bother reading this posting - just as they will not be bothered by using a totally meaningless subject for their posting.
But, I do not think we should simply 'let it be' (only John/Paul made that work and in a song). The forum is what we, the members, make from it.
I think my continual rants on using "urgent" for a subject header have made a difference and many "got the point". So I do not see Dave's rant as pointless - simply addressed at the wrong audience. He should instead post a small rant to an applicable posting and "spread the message" that way.
As for what we choose to read and not read.. some of us are here because we want to help. And a poster with a meaningless subject has a lessor change of getting his/her posting read by those who want to help.. as it is simply a nameless problem amongst other nameless problems. -
Error in stored procedure while using dbms_datapump for transportable
Hi,
I'm facing following issue:
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
====================================================================================
I'm trying to do transportable tablespace through stored procedure with help of DBMS_DATAPUMP, Following is the code :
==================================================================================
create or replace
procedure sp_tts_export(v_tbs_name varchar2) as
idx NUMBER; -- Loop index
JobHandle NUMBER; -- Data Pump job handle
PctComplete NUMBER; -- Percentage of job complete
JobState VARCHAR2(30); -- To keep track of job state
LogEntry ku$_LogEntry; -- For WIP and error messages
JobStatus ku$_JobStatus; -- The job status from get_status
Status ku$_Status; -- The status object returned by get_status
dts varchar2(140):=to_char(sysdate,'YYYYMMDDHH24MISS');
exp_dump_file varchar2(500):=v_tbs_name||'_tts_export_'||dts||'.dmp';
exp_log_file varchar2(500):=v_tbs_name||'_tts_export_'||dts||'.log';
exp_job_name varchar2(500):=v_tbs_name||'_tts_export_'||dts;
dp_dir varchar2(500):='DATA_PUMP_DIR';
log_file UTL_FILE.FILE_TYPE;
log_filename varchar2(500):=exp_job_name||'_main'||'.log';
err_log_file UTL_FILE.FILE_TYPE;
v_db_name varchar2(1000);
v_username varchar2(30);
t_dir_name VARCHAR2(4000);
t_file_name VARCHAR2(4000);
t_sep_pos NUMBER;
t_dir varchar2(30):='temp_0123456789';
v_sqlerrm varchar2(4000);
stmt varchar2(4000);
FUNCTION get_file(filename VARCHAR2, dir VARCHAR2 := 'TEMP')
RETURN VARCHAR2 IS
contents VARCHAR2(32767);
file BFILE := BFILENAME(dir, filename);
BEGIN
DBMS_LOB.FILEOPEN(file, DBMS_LOB.FILE_READONLY);
contents := UTL_RAW.CAST_TO_VARCHAR2(
DBMS_LOB.SUBSTR(file));
DBMS_LOB.CLOSE(file);
RETURN contents;
END;
begin
--execute immediate ('drop tablespace test including contents and datafiles');
--execute immediate ('create tablespace test datafile ''/home/smishr02/test.dbf'' size 10m');
--execute immediate ('create table prestg.test_table (a number) tablespace test');
--execute immediate ('insert into prestg.test_table values (1)');
--commit;
--execute immediate ('alter tablespace test read only');
--dbms_output.put_line('11111111111111111111');
dbms_output.put_line(log_filename||'>>>>>>>>>>>>>>>>>>>>>>>>>>>'|| dp_dir);
log_file:=UTL_FILE.FOPEN (dp_dir, log_filename, 'w');
UTL_FILE.PUT_LINE(log_file,'#####################################################################');
UTL_FILE.PUT_LINE(log_file,'REPORT: GENERATED ON ' || SYSDATE);
UTL_FILE.PUT_LINE(log_file,'#####################################################################');
select global_name,user into v_db_name,v_username from global_name;
UTL_FILE.PUT_LINE(log_file,'Database:'||v_db_name);
UTL_FILE.PUT_LINE(log_file,'user running the job:'||v_username);
UTL_FILE.PUT_LINE(log_file,'for tablespace:'||v_tbs_name);
UTL_FILE.NEW_LINE (log_file);
stmt:='ALTER TABLESPACE '||v_tbs_name || ' read only';
dbms_output.put_line('11111111111111111111'||stmt);
execute immediate (stmt);
UTL_FILE.PUT_LINE(log_file,' '||v_tbs_name || ' altered to read only mode.');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,'#####################################################################');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Initiating the Datapump engine for TTS export..............');
UTL_FILE.NEW_LINE (log_file);
dbms_output.put_line('11111111111111111111');
JobHandle :=
DBMS_DATAPUMP.OPEN(
operation => 'EXPORT'
*,job_mode => 'TRANSPORTABLE'*
*,remote_link => NULL*
*,job_name => NULL*
--,job_name => exp_job_name
-- ,version => 'LATEST'
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Allocating dumpfile................');
DBMS_DATAPUMP.ADD_FILE(
handle => JobHandle
,filename => exp_dump_file
,directory => dp_dir
,filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE
-- ,filesize => '100M'
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Allocating logfile................');
DBMS_DATAPUMP.ADD_FILE(
handle => JobHandle
,filename => exp_log_file
,directory => dp_dir
,filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Setting attributes................');
DBMS_DATAPUMP.set_parameter(handle => JobHandle,
name=>'TTS_FULL_CHECK',
value=>1);
DBMS_DATAPUMP.METADATA_FILTER(
handle => JobHandle
,NAME => 'TABLESPACE_EXPR'
,VALUE => 'IN ('''||v_tbs_name||''')'
-- ,object_type => 'TABLE'
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Now starting datapump job................');
DBMS_DATAPUMP.START_JOB(JobHandle);
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Monitoring the job................');
--------------Monitor the job
PctComplete := 0;
JobState := 'UNDEFINED';
WHILE(JobState != 'COMPLETED') and (JobState != 'STOPPED')
LOOP
DBMS_DATAPUMP.GET_STATUS(
handle => JobHandle
,mask => 15 -- DBMS_DATAPUMP.ku$_status_job_error + DBMS_DATAPUMP.ku$_status_job_status + DBMS_DATAPUMP.ku$_status_wip
,timeout => NULL
,job_state => JobState
,status => Status
JobStatus := Status.job_status;
-- Whenever the PctComplete value has changed, display it
IF JobStatus.percent_done != PctComplete THEN
DBMS_OUTPUT.PUT_LINE('*** Job percent done = ' || TO_CHAR(JobStatus.percent_done));
PctComplete := JobStatus.percent_done;
END IF;
-- Whenever a work-in progress message or error message arises, display it
IF (BITAND(Status.mask,DBMS_DATAPUMP.ku$_status_wip) != 0) THEN
LogEntry := Status.wip;
ELSE
IF (BITAND(Status.mask,DBMS_DATAPUMP.ku$_status_job_error) != 0) THEN
LogEntry := Status.error;
ELSE
LogEntry := NULL;
END IF;
END IF;
IF LogEntry IS NOT NULL THEN
idx := LogEntry.FIRST;
WHILE idx IS NOT NULL
LOOP
DBMS_OUTPUT.PUT_LINE(LogEntry(idx).LogText);
idx := LogEntry.NEXT(idx);
END LOOP;
END IF;
END LOOP;
--copy the datafiles to data dump dir
UTL_FILE.PUT_LINE(log_file,'Done');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Copying datafiles to dump directory................');
-- grant select on dba_directories to prestg;
declare
cnt number;
begin
select count(*) into cnt from dba_directories
where directory_name=upper(t_dir);
if cnt=1 then
execute immediate('DROP DIRECTORY '||t_dir);
end if;
end;
FOR rec in (select file_name from sys.dba_data_files where tablespace_name=v_tbs_name)
LOOP
t_sep_pos:=instr(rec.file_name,'/',-1);
t_dir_name:=substr(rec.file_name,1,t_sep_pos-1);
t_file_name:=substr(rec.file_name,t_sep_pos+1,length(rec.file_name));
dbms_output.put_line(t_dir_name|| ' ' || t_dir);
dbms_output.put_line(t_file_name);
execute immediate('CREATE DIRECTORY '||t_dir||' AS '''||t_dir_name||'''');
UTL_FILE.PUT_LINE(log_file,' Copying '||rec.file_name||'................');
utl_file.fcopy(t_dir, t_file_name, dp_dir, t_file_name);
UTL_FILE.PUT(log_file,'Done');
execute immediate('DROP DIRECTORY '||t_dir);
END LOOP;
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' Altering tablespace to read write................');
execute immediate ('ALTER TABLESPACE '||v_tbs_name || ' read write');
UTL_FILE.PUT(log_file,' Done');
err_log_file:=utl_file.fopen(dp_dir, exp_log_file, 'r');
UTL_FILE.NEW_LINE (log_file);
UTL_FILE.PUT_LINE(log_file,' content of export logfile................');
loop
begin
utl_file.get_line(err_log_file,v_sqlerrm);
if v_sqlerrm is null then
exit;
end if;
UTL_FILE.PUT_LINE(log_file,v_sqlerrm);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
end loop;
utl_file.fclose(err_log_file);
utl_file.fclose(log_file);
END;
I'm getting following error when DBMS_DATAPUMP.OPEN is called in procedure:
SQL> exec sp_tts_export('TEST');
BEGIN sp_tts_export('TEST'); END;
ERROR at line 1:
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 938
ORA-06512: at "SYS.DBMS_DATAPUMP", line 4566
ORA-06512: at "PRESTG.SP_TTS_EXPORT", line 78
ORA-06512: at line 1
==============================================================================================
This procedure is part of user ABC. I'm getting the above when I'm running this under ABC schema. However I have tested the same procedure under sys schema. When I'm creating same procedure in SYS schema it is running fine. I am clueless on this. Pls help
Thanks
Shailesh
Edited by: shaileshM on Jul 28, 2010 11:15 AMPrivileges acquired via ROLE do NOT apply within named PL/SQL procedures.
Explicit GRANT is required to resolve this issue. -
Error calling a stored procedure
Hi buddies, I've the following store procedure:
PROCEDURE USP_GET_SMALL_SIZE_ROWS_DATA(tableName VARCHAR2, isSource pls_integer, since pls_integer, untilValue pls_integer, pk_Name OUT CLOB, xmlResult OUT CLOB);Inside the package REPLICATION_PACK
and then, when I run this:
DECLARE
pk_Name CLOB;
xmlResult CLOB;
BEGIN
EXEC REPLICATION_PACK.USP_GET_SMALL_SIZE_ROWS_DATA('TableName', 1, 1, 50, :pk_Name, :xmlResult);
END;It shows me this error: "SP2-0552: Bind variable "XMLRESULT" not declared." Could you help me?
Thanks you in advance.You can not do what it appears you are trying to do.
EXEC REPLICATION_PACK.USP_GET_SMALL_SIZE_ROWS_DATA('PERSON', 1, 1, 50, pk_Name, xmlResult);
requires that pk_Name and xmlResult have values: They have none. This is not code that can ever be run in SQL*Plus from the command line.
Your procedures is built on the following parameters:
(tableName VARCHAR2, isSource pls_integer, since pls_integer, untilValue pls_integer, pk_Name OUT CLOB, xmlResult OUT CLOB)So your table_name is 'PERSON' ... good so far
You r isSource and since and untilVal are integers and your have provided 1, 1 and 50 ... good so far.
But the next two parameters are OUT params ... they need to go somewhere.
So run it like this:
DECLARE
pkNameOUT CLOB;
xmlResultOUT CLOB;
BEGIN
REPLICATION_PACK.USP_GET_SMALL_SIZE_ROWS_DATA('PERSON', 1, 1, 50, pkNameOut, xmlResultOut);
END;
/Then you've got to figure out what to do with those two CLOB variables or they just evaporate. -
Error when calling a stored procedure from a SQL Script
Apologies if this is a really dumb question but I can't seem to call a procedure in package from a SQL script. I have a simple package.procedure containing a loop to populate a table. I would like to include a call to this procedure from my database install script, that also includes my CREATE and INSERT statements. I run the script using "@install_databae" and the CREATE and INSERT statements run fine. The script gives an error when it reaches the line below:
exec lazarus.PopulateGridPositions;
and gives the error.....
BEGIN lazarus.PopulateGridPositions; END;
ERROR at line 1:
ORA-04063: package body "LAZARUS.LAZARUS" has errors
ORA-06508: PL/SQL: could not find program unit being called: "LAZARUS.LAZARUS"
ORA-06512: at line 1
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.
I've obviously missed some fundamental concept with scripts and SQL. Please can anybody help me?Histon FTM wrote:
ORA-04063: package body "LAZARUS.LAZARUS" has errors Above, obviously conflicts with the statement that follows:
>
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.I suggest you take a look in the USER_ERRORS view to see, what the errors are.
And just checking:
You have schema called LAZARUS, which holds a package named LAZARUS, which holds a procedure called POPULATEGRIDPOSITIONS?
Edited by: Toon Koppelaars on Oct 1, 2009 5:55 PM -
Approval procedure if user change in the unit price at Purchase Order
Dear Experts,
I have defined purchase price list in the item master data. I want an approval if there is any devaition in the purchase price list and unit price which is defined in the purchase order. It will always go for the approval.
Regards,
RavinderaDear Ravindera,
Approval is only working on the header level. Unless you just care about the first line, no approval procedure can be built for other lines.
You can block those PO by SP_TN instead.
Thanks,
Gordon -
Calling Stored Procedure from ODBC
I call a stored procedure that contains a reference to a database link through ODBC.
I get the following errors (LOAD_PDI is the name of the procedure):
ORA-02041: Client database did not begin a transaction
ORA-06512: at "LOAD_PDI" line 16
ORA-06512: at "LOAD_PDI" line 42
ORA-06512: at line 1
The procedure works if called from SQLplus and executes a query on a remote database to insert or update tables in the local data base. In the procedure I define two CURSORS to get data from the remote Database.
Is there anything unsupported using ODBC ?
Same error messages calling from Visual Basic using ADO. I have installe dthe last versione of OLEDB driver (8.1.6.2).
I am using Oracle Enterprise 8.1.6 release 2 on Windows NT server 4.0 with service pack 6.
Thanks for collaboration.
nullThe only way I'm aware of to turn off autocommit is to issue the ODBC call
SQLSetConnectAttr( hdbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, SQL_NTS )
Note that you'll have to issue a SQLEndTran call with SQL_COMMIT or SQL_ROLLBACK to commit or rollback your changes with autocommit off.
I'm curious as to whether you saw any documentation which indicated that the way to turn off autocommit was to add the registry entry 'autocommit=F'. That's certainly not an option I'm familiar with, so I'd like to ensure that we don't have incorrect documentation laying around.
The reason you'll see different behavior using ODBC as opposed to SQL*Plus is because the two have different semantics.
In SQL*Plus, statements that you execute are not committed until you execute an explicit commit statement. This is pretty standard for database interfaces, and is generally necessary if you want to maintain state in a transaction.
When Microsoft wrote the ODBC specification, they broke with this convention and specified that ODBC would, by default, commit every statement immediately after is suceeds. This may cause problems if your procedure assumes that it is able to maintain state between uncommitted calls.
For example, in SQL*Plus, if you issue the command "select empno from emp for update", the "for update" clause places a lock on those elements. Subsequent updates generally assume that those locks are still present. If you issue a "commit", however those locks are discarded.
In ODBC, if you issue the same command without explicitly turning off autocommit, the statement succeeds, taking out the locks, but then is immediately & automatically committed, releasing those locks. If you turn off autocommit, you get the same behavior you saw with SQL*Plus.
I suspect that the stored procedure LOAD_PDI maintains some state and that the code on lines 16 & 42 are doing some form of update that relies on this state being present.
Note that, since you don't specify that you are, I'm assuming that you're not using XA or Microsoft's transaction server to do coordinated multi-machine transactions. If you are using one of these, please let me know.
Justin Cave
ODBC Development -
Catching an error on a single line
Is there a way to catch an error on a single line in a VBS script? From what I understand the "On Error Resume Next" will apply to all lines in a procedure.
GeorgeHello George,
unfortunaly there is no way in VBS like the On Error Goto xxx in VB/VBA. You have to encapsulate the crtitcal lines with a On Error Resume Next/On Error Goto 0 pair and find an error with if Err.Number <> 0 then after every line and handle it e.g. with a Exit Sub call.
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater? -
More than 1 cursor in a stored procedure
Is it possible to open more than 1 cursor in a stored procedure? I have 2 stored procedure which use the same 2 parameters, and figured I could probably combine the two. Thanks
If you used the example provided by SBH more or less as it was posted, then both cursors were closed before they got to coldfusion. If you are passing them out of you procedures for processing by another piece of code you need to leave them open. More along the lines of:
create procedure protest(p_empno number,
p_ename out varchar2,
p_sal out number,
p_dummy out varchar2) is
cursor c1 is
select ename,sal
from employee
where empid = p_empno;
cursor c2 is
select name
from stname;
begin
open c1;
open c2;
end;Just make sure to close them in your calling code once you have finished with them.
John
Maybe you are looking for
-
Try to use Headset for Skype on G5, but microphone does not work! Need help
I recently installed skype on my G5, bought a headset, can hear people talking to me, but nobody can hear me. It's not an USB or bluetooth headset, but with 2 plugins (sorry, i'm austrian...). Does anybody know what setups to change that it works? I
-
The canvas in FCP appears dark. If I move the canvas to another screen, the picture is lighter and if I play it to a TV through the camera, it is about the same quality. It is difficult to adjust the quality of the video on my Powerbook when it is da
-
DYNAMIC_CALL_FAILURE using a function module in sproxy
Hi all, We are using a standard function module in sproxy. When we call it, we get an exception for DYNAMIC_CALL_FAILURE. If i call it from a specific program, with exactly the same parameters and same data, it's correctly processed. I'm unable to un
-
MySQL Connection - Select Database - HTTP Error Code 405 Method Not Allowed?
We've set up a MySQL database with our host and can connect to that, and create, edit, delete tables using HeidiSQL, without a problem. However when we attempt to set up the connection in the Databases tab of our Applications panel in Dreamweaver we
-
ITunes New Full Screen Mode?
Has anybody noticed when you open up the new iTunes and go into fullscreen with a movie or tv show that the color density drops. It almost brings a blue shade to the whole color scheme and really takes away from the great color quality as if you were