DBMS_OUTPUT.ENABLE(1000000);
Dear all,
my DB is 10.2.0.4
I got an error message ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes.
I saw a simmilar topic with the suggestion to put DBMS_OUTPUT.ENABLE(1000000);
A quick question - if i have a package with several procedures, do I have to place DBMS_OUTPUT.ENABLE(1000000); in each procedure, after the BEGIN?
Thank you for your assistance.
hoek wrote:
Maybe it is used as intrumentation code?
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1468572900346293780
Interesting, but it never occured to my mind to use it for instrumentation. I have used file or table to do that in the past. My personal choice would be table. Its quite helpful when we have to report.
Similar Messages
-
DBMS_OUTPUT.ENABLE(null) - does this set the serveroutput size to unlimited
Hi,
I am in 10gR2. But my SQL plus client is still with 9i.
Hence i am unable to use the 10gR2 feature of setting the serveroutput to unlimited size.
If i issue
SET SERVEROUTPUT ON SIZE UNLIMITED
I am getting this error.
Usage: SET SERVEROUTPUT { ON | OFF } [SIZE n]
[ FOR[MAT] { WRA[PPED] | WOR[D_WRAPPED] | TRU[NCATED] } ]
This could be due to my 9i client.
My end goal is: all my dbms_output lines should get printed without getting buffer overflow error.
I know i can make use of dbms_output.enable - this also takes n as argument to set whatever be the buffer size.
Question: How can i use dbms_output.enable to set Unlimited size.I don't see where it says that a null argument to DBMS_OUTPUT.ENABLE will be treated as 2000 (20000?).Look at the Usage Notes in the link oradev060708 provided.
NULL is expected to be the usual choice. The default is 20,000 for backwards compatibility with earlier database versions that did not support unlimited buffering.
« -
Where can i get online Help on DBMS_OUTPUT.ENABLE????
Plz do help me in getting to online help documentation of
DBMS_OUTPUT package...
Very urgent!!
I've to enable/disable SERVEROUTPUT dynamically
Plz send me any suggestions if any regarding this...
RegardsThis can only be done in SQL-SESSION.
Refer --> pkg dbms_output.enable(size of buffer) -> to enable
pkg dbms_output.disable -> to disable.
good luck
=dimple -
Error while printing generated XML doc using DBMS_OUTPUT
while generating XML document using XDK for PL/SQL i am getting " ORU-10027: buffer overflow, limit of 1000000 bytes " error even though i had set DBMS_OUTPUT to 1000000.
Is there any way to getrid of this problem .
i am using this code ..
CREATE OR REPLACE procedure SQLToXML1 is
queryCtx DBMS_XMLquery.ctxType;
result CLOB;
begin
DBMS_OUTPUT.ENABLE (1000000);
queryCtx := DBMS_XMLQuery.newContext ('select * from depolib_library' )
result := DBMS_XMLQuery.getXML(queryCtx);
printClobOut(result);
DBMS_XMLQuery.closeContext(queryCtx);
exception
when others then
dbms_output.put_line(sqlerrm);
end;
urgent help is needed
Thanks
nullNo, It is a PO Print only. Only for changes to PO that do not affect the value of the PO,this error occurs. When i select the entry for the PO and click on Output message, the output message fails. On clicking Display Message, it shows the message - No schedules exist for the Scheduling Agreement XXXXXX(the PO number".
So,it is not for Scheduling Agreements but for PO only. I know it is weird to see such an error on the PO output message in ME9F.
Pls help. -
DBMS_OUTPUT error with RAWTOHEX function
The PL/SQL code
declare
x LONG RAW;
y RAW(32767); -- RAW variable has higher maximum length than LONG RAW
begin
select ole_object_blob into x --ole_object_blob is declared as LONG RAW
from table;
y := x;
DBMS_OUTPUT.PUT_LINE(rawtohex(y));
end;
produces the error
"PL/SQL numeric or value error at SYS.DBMS_OUTPUT". Any idea what the problem is? Thanks.Gary:
Actually, the error message you get is misleading. DBMS_OUTPUT has a maximum line length of 255 characters. It is supposed to raise
"ORA-20000,Line length overflow, limit of 255 bytes per line." but it doesn't seem to.
This should display your data.
DECLARE
y RAW(32767);
a PLS_INTEGER;
BEGIN
dbms_output.enable(1000000);
select piece INTO y
from sys.ORA_KGLR7_IDL_UB1
where obj# = 1881 and
part = 2 and
piece# = 3;
a := 1;
WHILE a < length(rawtohex(y)) LOOP
dbms_output.put_line(substr(rawtohex(y),a,254));
a := a + 254;
END LOOP;
END;Just be aware that the RAWTOHEX function effectively doubles the length of the raw column. Each raw byte is represented by two hex characters, so the maximum length of the long raw column you can support is 16,384 bytes.
HTH
John -
DBMS_OUTPUT.PUT_LINE doesn't work in Reports
Version 1.1.2.25 Build Main 25.97
I've tried to create a Report using the PL/SQL-DBMS_OUTPUT option and it just sends out a sinle line of text without any line throws. Copy the block of code and run it as a script and it works fine.
Anybody else come across this problem?Here's the PL/SQL code for the Report....
declare
vowner VARCHAR2(30);
vindex VARCHAR2(30);
vtable VARCHAR2(30);
CURSOR cIndex
IS
select OWNER, INDEX_NAME, TABLE_NAME
from dba_indexes;
begin
dbms_output.enable(1000000);
open cIndex;
LOOP
FETCH cIndex INTO vowner, vindex, vtable;
EXIT WHEN cIndex%NOTFOUND;
if (vowner = :OWNER) and (vTable like :TABLENAME)
then
dbms_output.put_line('alter index ' || vowner || '.' || vindex || ' nomonitoring usage;');
end if;
end loop;
close cIndex;
end;
I've tested by setting the bind variables :OWNER to a schema and :TABLENAME to '%' to return all indexes owner by the schema.
As you can see, I don't use \n.
This works fine when run as a script in SQL Developer (each put_line coming out on a separate line) but not as a report. -
I need help with DBMS_OUTPUT.PUT_LINE
I am a student new to PL/SQL. I am using SQL developer 3.2.20.9. For several weeks DBMS_OUTPUT.PUT_LINE worked fine. Now I cannot see it. I have tried adding DBMS_OUTPUT.enabled(1000000); to my code to no avail. When it did work the window was on my desktop, not locked to the bottom of the PL/SQL page. I may have hit the x to close it, now I cannot get it back. Yes, I selected "view" "DBMS Output". I have had this problem for over a week. Can someone help me?
Tomuser10199456 wrote:
I am a student new to PL/SQL. I am using SQL developer 3.2.20.9. For several weeks DBMS_OUTPUT.PUT_LINE worked fine. Now I cannot see it. I have tried adding DBMS_OUTPUT.enabled(1000000); to my code to no avail. When it did work the window was on my desktop, not locked to the bottom of the PL/SQL page. I may have hit the x to close it, now I cannot get it back. Yes, I selected "view" "DBMS Output". I have had this problem for over a week. Can someone help me?
Tom
Then as new student - DO NOT USE DBMS_OUTPUT!!
It is the WRONG interface to use to display server data on a client. It does not write to a client display. The majority of times it is abused, as there is a misunderstanding of what it is and how it works.
See Re: Can't get DECLARE/BEGIN to compile
You are GROSSLY mistaken if you think that DBMS_OUTPUT plays any role in getting server data to render on the client. -
How do I enable "TRACING" of queries and connects ?
As far as I know I can somewhere enable tracing of
all incoming connect (=login session) trials and queries.
How can I turn this tracing on?
Where can I see the tracing log ?To enable trace for another session currently connected:
EXECUTE SYS.DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(<sid>, <serial#>, TRUE );
To disable trace for another session currently connected:
EXECUTE SYS.DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(<sid>, <serial#>, FALSE );
To enable trace for you own, current session:
alter session set events '10046 trace name context forever, level 12';
To disable trace for your own current session:
alter session set events '10046 trace name context off';
To see what your current session trace dump file is:
declare
spid1 VARCHAR2(9);
tracefile VARCHAR2(80);
sid_id VARCHAR2(8);
udump_loc VARCHAR2(60);
begin
SELECT spid
INTO spid1
FROM v$process a,
v$session b,
v$mystat m
WHERE a.addr = b.paddr
AND b.audsid = userenv('SESSIONID')
AND b.sid = m.sid
AND ROWNUM = 1 ;
SELECT LOWER(instance_name)
INTO sid_id
FROM v$instance ;
SELECT value
INTO udump_loc
FROM v$parameter
WHERE name = 'user_dump_dest' ;
tracefile:= udump_loc||'/'||sid_id||'_ora_' || spid1 ||'.trc';
dbms_output.enable(1000000);
dbms_output.put_line(tracefile);
end; -
Is there an alternative to DBMS_OUTPUT???
I have written a stored procedure that builds an update statement dynamically, basically I am updating a table with multiple fields, but not all fields need to be updated.
So I am building my update statement to update only the fields that need to be. BUT, I am still testing it and I want to output the completed Update statement (that is being assigned to a variable, sqlScript) so I can verify that it looks good.
But I am getting an Oracle error (ORA-20000: ORU-10028: line length overflow, limit of 255 chars per line). Obviously the update statement is violating the DBMS_OUTPUT 255 character limit, is there anyway I can avoid this error?? Are there any alternatives to the DBMS_OUTPUT?? Can I output my variable to a .txt file or anything??
Any help would be greatly appreciated!
Thanks.Hi,
>>Obviously the update statement is violating the DBMS_OUTPUT 255 character limit
Exactly. The DBMS_OUTPUT package cannot handle more than 255 characters per line
You have two workarounds:
The following recursive procedure below acts as an wrapper for the DBMS_OUTPUT.PUT_LINE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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
PL/SQL procedure successfully completed.
LEGATTI@ORACLE10> begin
2 for i in 1..10
3 loop
4 dbms_output.put_line(rpad('a',256,'a'));
5 end loop;
6 end;
7 /
begin
ERROR at line 1:
ORA-20000: ORU-10028: line length overflow, limit of 255 chars per line
ORA-06512: at "SYS.DBMS_OUTPUT", line 35
ORA-06512: at "SYS.DBMS_OUTPUT", line 115
ORA-06512: at line 4
LEGATTI@ORACLE10> CREATE OR REPLACE PROCEDURE Show_Message(pmv_Msg_in IN VARCHAR2)
2 IS
3 BEGIN
4 IF LENGTH(pmv_Msg_in) > 80 THEN
5 DBMS_OUTPUT.Put_Line(SUBSTR(pmv_Msg_in,1,79));
6 Show_Message(SUBSTR(pmv_Msg_in,80,LENGTH(pmv_Msg_in)));
7 ELSE
8 DBMS_OUTPUT.Put_Line(pmv_Msg_in);
9 END IF;
10 EXCEPTION
11 WHEN Others THEN
12 DBMS_OUTPUT.Disable;
13 DBMS_OUTPUT.Enable(1000000);
14 Show_Message(SUBSTR(pmv_Msg_in,80,LENGTH(pmv_Msg_in)));
15 END Show_Message;
16 /
Procedure created.
LEGATTI@ORACLE10> begin
2 for i in 1..10
3 loop
4 show_message(rpad('a',256,'a'));
5 end loop;
6 end;
7 /
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaa
PL/SQL procedure successfully completed.
LEGATTI@ORACLE10>
OR
Instead of using DBMS_OUTPUT to show the output:
- create a table with a LONG column;
- insert the text into this LONG column;
- query the table.
Example:
SQL> create table mytable (l long);
Then, modify your stored procedure to insert the value into this table:
INSERT INTO mytable VALUES (myvalue);
Then query the table:
SQL> set long 100000
SQL> select * from mytable;
Finally, truncate the table to empty it again.
References: Note:244094.1, Note:201162.1
Cheers -
DBMS_OUTPUT in 21.97
This script shows part of it's output in the script window, part in the DBMS_OUTPUT window. Is there a way to get all this output in a single window?
begin
dbms_output.disable;
dbms_output.enable(1000000);
for i in 1 .. 10000
loop
dbms_output.put_line('XXXXXXXX' ||i);
end loop;
end;
Running windoze XP Pro on 9.2.0.6.0Also seems to be an issue when the length of a line in DBMS_OUTPUT is too long.
The following code which builds up a DDL string to pass into EXECUTE IMMEDIATE doesn't show any output. Doesn't matter if DBMS Output is enabled or disabled in its tab.
However if you run the same code in SQLPlus it does.
DECLARE
CURSOR column_cursor(v_table_name VARCHAR2) IS
SELECT column_name
FROM dba_tab_columns
WHERE table_name = v_table_name
AND owner = 'DLS';
column_record column_cursor%ROWTYPE;
ddl VARCHAR2(4000);
the_table_name VARCHAR2(30);
BEGIN
DBMS_OUTPUT.ENABLE(100000);
the_table_name := 'USER_DETAIL';
DBMS_OUTPUT.PUT_LINE('Generating trigger for ' || the_table_name);
ddl := 'CREATE OR REPLACE TRIGGER DLS.ia_' || the_table_name || ' AFTER INSERT OR UPDATE OR DELETE ON DLS.' || the_table_name || ' ' ;
ddl := ddl || 'REFERENCING OLD AS OLDDATA NEW AS NEWDATA ';
ddl := ddl || 'FOR EACH ROW ';
ddl := ddl || 'BEGIN ';
ddl := ddl || 'IF INSERTING THEN ';
ddl := ddl || 'INSERT INTO DLS_audit.' || the_table_name || ' ';
ddl := ddl || '(';
OPEN column_cursor(the_table_name);
LOOP
FETCH column_cursor INTO column_record;
EXIT WHEN column_cursor%NOTFOUND;
ddl := ddl || column_record.column_name || ',';
END LOOP;
CLOSE column_cursor;
ddl := ddl || 'AUDIT_DATE,';
ddl := ddl || 'AUDIT_ACTION';
ddl := ddl || ') ';
ddl := ddl || 'VALUES ';
ddl := ddl || '(';
OPEN column_cursor(the_table_name);
LOOP
FETCH column_cursor INTO column_record;
EXIT WHEN column_cursor%NOTFOUND;
ddl := ddl || ':NEWDATA.' || column_record.column_name || ',';
END LOOP;
CLOSE column_cursor;
ddl := ddl || 'SYSDATE,';
ddl := ddl || '''INSERT''';
ddl := ddl || '); ';
ddl := ddl || 'ELSIF UPDATING THEN ';
ddl := ddl || 'INSERT INTO DLS_audit.' || the_table_name || ' ';
ddl := ddl || '(';
OPEN column_cursor(the_table_name);
LOOP
FETCH column_cursor INTO column_record;
EXIT WHEN column_cursor%NOTFOUND;
ddl := ddl || column_record.column_name || ',';
END LOOP;
CLOSE column_cursor;
ddl := ddl || 'AUDIT_DATE,';
ddl := ddl || 'AUDIT_ACTION';
ddl := ddl || ') ';
ddl := ddl || 'VALUES ';
ddl := ddl || '(';
OPEN column_cursor(the_table_name);
LOOP
FETCH column_cursor INTO column_record;
EXIT WHEN column_cursor%NOTFOUND;
ddl := ddl || ':NEWDATA.' || column_record.column_name || ',';
END LOOP;
CLOSE column_cursor;
ddl := ddl || 'SYSDATE,';
ddl := ddl || '''UPDATE''';
ddl := ddl || '); ';
ddl := ddl || 'ELSIF DELETING THEN ';
ddl := ddl || 'INSERT INTO DLS_audit.' || the_table_name || ' ';
ddl := ddl || '(';
OPEN column_cursor(the_table_name);
LOOP
FETCH column_cursor INTO column_record;
EXIT WHEN column_cursor%NOTFOUND;
ddl := ddl || column_record.column_name || ',';
END LOOP;
CLOSE column_cursor;
ddl := ddl || 'AUDIT_DATE,';
ddl := ddl || 'AUDIT_ACTION';
ddl := ddl || ') ';
ddl := ddl || 'VALUES ';
ddl := ddl || '(';
OPEN column_cursor(the_table_name);
LOOP
FETCH column_cursor INTO column_record;
EXIT WHEN column_cursor%NOTFOUND;
ddl := ddl || ':OLDDATA.' || column_record.column_name || ',';
END LOOP;
CLOSE column_cursor;
ddl := ddl || 'SYSDATE,';
ddl := ddl || '''DELETE''';
ddl := ddl || '); ';
ddl := ddl || 'END IF;';
ddl := ddl || 'END;';
DBMS_OUTPUT.PUT_LINE('DDL => ' || ddl);
END;
Realise you shouldn't really be using DBMS_OUTPUT in this way, but still..
I have increased the default 200000 buffer size to 20000000 and it still outputs nothing. -
Hi,
I have been tasked with writing an Oracle Function to query a set of tables to locate data that best matches what a user needs.
If data is not returned in a given query, we need the procedure to loop and run a modified query. If that query does not give data, we continue to loop and refine until we reach a point where we have expended all of our filtering levels.
I am new to writing PL SQL and have been doing a lot of googling trying to figure out how to do this, but I am stuck :(
I have not been able to figure out how to continue looping in the Procedure when there are no results in the record set.
It is probably something simple, I just haven't been able to figure it out.
HERE'S WHAT SEEMS TO BE THE PERTINENT PART OF THE CODE:
OPEN v_cursor FOR v_sql;
DBMS_OUTPUT.PUT_LINE(v_sql);
--THIS IS THE PORTION I AM HAVING PROBLEMS WITH:
--If there are results I want to set the following
--haveResultsOrAllQueriesDone := TRUE;
--Otherwise, I want to leave haveResultsOrAllQueriesDone := FALSE; and continue to loop
RETURN v_cursor;
END LOOP;
Thanks in advance for any direction any one can give me.
Thanks!
:) Anne
PS:
HERE IS THE COMPLETE FUNCTION AS I HAVE IT SO FAR:
create or replace
FUNCTION LOCATEACONSULTANT_function
p_action IN VARCHAR2,
p_first_name IN VARCHAR2,
p_last_name IN VARCHAR2,
p_exact_match IN VARCHAR2,
p_country_code IN VARCHAR2,
p_state IN VARCHAR2,
p_city IN VARCHAR2,
p_zip_or_postalcode IN VARCHAR2,
p_language_code IN VARCHAR2)
RETURN types.ref_cursor
AS
v_cursor types.ref_cursor;
v_temp_cursor types.ref_cursor;
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
DECLARE
type ref_cursor
IS
REF
CURSOR;
cursor_locateAConsultant ref_cursor;
v_select VARCHAR2(3000);
v_from VARCHAR2(2000);
v_where VARCHAR2(4000);
v_sql VARCHAR2(4000);
stateMapped ref_zip_mappings.state%type;
countyMapped ref_zip_mappings.county%type;
cityMapped ref_zip_mappings.city%type;
haveQueriedLanguage BOOLEAN := FALSE;
haveQueriedZip BOOLEAN := FALSE;
haveQueriedCity BOOLEAN := FALSE;
haveQueriedCounty BOOLEAN := FALSE;
haveQueriedState BOOLEAN := FALSE;
haveResultsOrAllQueriesDone BOOLEAN := FALSE;
haveDoneAllQueries BOOLEAN := FALSE;
tempLikeZip VARCHAR2(100);
BEGIN
v_select := 'SELECT customers.customer_id, customers.last_name, customers.first_name, ';
v_select := v_select || ' customer_contacts.email_address, addresses.state, addresses.city, ';
v_select := v_select || ' customer_contacts.web_site, customer_languages.language_code, customer_titles.pqv ';
v_from := ' FROM customers, customer_addresses, addresses, customer_contacts, customer_titles, customer_languages';
v_where := ' WHERE customers.customer_id = customer_addresses.customer_id ';
v_where := v_where || ' AND customer_addresses.address_id = addresses.address_id ';
v_where := v_where || ' AND customers.customer_id = customer_contacts.customer_id ';
v_where := v_where || ' AND customers.customer_id = customer_titles.customer_id ';
v_where := v_where || ' AND customers.preferred_language_code = customer_languages.language_code ';
v_where := v_where || ' AND UPPER(addresses.country_code) = UPPER(''' || p_country_code || ''') ';
v_where := v_where || ' AND UPPER(customers.exclude_locate) = '||''''||'N'||''''||'';
v_where := v_where || ' AND UPPER(customer_titles.customer_type) = '||''''||'CON'||''''||'';
v_where := v_where || ' AND UPPER(customer_titles.dp_id) LIKE '||''''||'CN%'||''''||'';
-- Line below assumes that 1 is the billing_address_type
v_where := v_where || ' AND customer_addresses.address_type_code = 1 ';
v_where := v_where || ' AND ';
v_where := v_where || ' ( ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MYARBONNE.COM%'||''''||' ';
v_where := v_where || ' OR ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MYARBONNE.COM.AU%'||''''||' ';
v_where := v_where || ' OR ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MYARBONNE.CA%'||''''||' ';
v_where := v_where || ' OR ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MYARBONNE.UK%'||''''||' ';
v_where := v_where || ' ) ';
IF (UPPER(p_action) =UPPER('search')) THEN
v_where := v_where || ' AND UPPER(addresses.state) = UPPER(trim(''' || p_state || ''')) ';
IF UPPER(p_exact_match) = UPPER('y') THEN
v_where := v_where || ' AND UPPER(customers.first_name) = UPPER(trim(''' || p_first_name || ''')) ';
ELSE
v_where := v_where || ' AND UPPER(SOUNDEX(customers.first_name)) = UPPER(SOUNDEX(trim(''' || p_first_name || '''))) ';
END IF;
IF UPPER(p_last_name) <> '' THEN
IF UPPER(p_exact_match) = UPPER('y') THEN
v_where := v_where || ' AND UPPER(customers.last_name) = UPPER(trim(''' || p_last_name || ''')) ';
ELSE
v_where := v_where || ' AND UPPER(SOUNDEX(customers.last_name)) = UPPER(SOUNDEX(trim(''' || p_last_name || ''')) ';
END IF;
END IF;
IF UPPER(p_city) <> '' THEN
v_where := v_where || ' AND UPPER(addresses.city) = UPPER(''' || p_city || ''') ';
END IF;
IF UPPER(p_zip_or_postalcode) <> '' THEN
v_where := v_where || ' AND UPPER(addresses.zip_or_postalcode) = UPPER(''' || p_zip_or_postalcode || ''') ';
END IF;
END IF;
WHILE (haveResultsOrAllQueriesDone = FALSE)
LOOP
IF (p_action = 'locate') THEN
IF (haveQueriedLanguage = FALSE) THEN
IF (p_language_code <> '') THEN
v_where := v_where|| ' AND UPPER(customer_languages.language_code) = UPPER(''' || p_language_code || ''') ';
haveQueriedLanguage := TRUE;
END IF;
--ELSE
-- haveQueriedLanguage := FALSE;
END IF;
IF (haveQueriedZip = FALSE) THEN
v_where := v_where|| ' AND UPPER(addresses.zip_or_postalcode) = UPPER(''' || p_zip_or_postalcode || ''') ';
IF (haveQueriedLanguage = FALSE) THEN
haveQueriedZip := TRUE;
END IF;
ELSIF (haveQueriedCity = FALSE) THEN
IF (p_city <> '') THEN
v_where := v_where|| ' AND UPPER(addresses.city) = UPPER('||''''|| p_city ||''''||') ' ;
ELSE
IF (p_country_code = 'UK') THEN
tempLikeZip := SUBSTR(p_zip_or_postalcode,( LENGTH(TRIM(p_zip_or_postalcode)) - 2 ));
v_where := v_where || ' AND UPPER(addresses.zip_or_postalcode) LIKE UPPER(TRIM('||'''%'||tempLikeZip ||''''||')) ' ;
ELSE
OPEN cursor_locateAConsultant FOR 'SELECT city FROM ref_zip_mappings where UPPER(zip_or_postalcode) = UPPER(TRIM('||''''|| p_zip_or_postalcode ||''''||')) ' ;
-- OPEN v_temp_cursor FOR 'SELECT city FROM ref_zip_mappings where UPPER(zip_or_postalcode) = UPPER(TRIM('||''''|| p_zip_or_postalcode ||''''||')) ' ;
LOOP
FETCH cursor_locateAConsultant INTO cityMapped;
EXIT
WHEN cursor_locateAConsultant%NOTFOUND;
END LOOP;
CLOSE cursor_locateAConsultant;
-- RETURN v_temp_cursor;
v_where := v_where || ' AND UPPER(addresses.city) = UPPER('||''''|| cityMapped ||''''||') ' ;
END IF;
END IF;
haveQueriedCity := TRUE;
ELSIF haveQueriedCounty = FALSE THEN
IF (p_country_code = 'UK') THEN
tempLikeZip := UPPER(SUBSTR(p_zip_or_postalcode,( LENGTH(TRIM(p_zip_or_postalcode)) - 3 )));
v_where := v_where|| ' AND UPPER(addresses.zip_or_postalcode) LIKE '||'''%'||tempLikeZip ||''''||' ' ;
ELSE
OPEN cursor_locateAConsultant FOR 'SELECT county FROM ref_zip_mappings where UPPER(zip_or_postalcode) = UPPER('||''''|| p_zip_or_postalcode ||''''||') ' ;
LOOP
FETCH cursor_locateAConsultant INTO countyMapped;
EXIT
WHEN cursor_locateAConsultant%NOTFOUND;
END LOOP;
CLOSE cursor_locateAConsultant;
v_where := v_where|| ' AND UPPER(addresses.county) = UPPER('||''''|| countyMapped ||''''||') ' ;
END IF;
haveQueriedCounty := TRUE;
END IF;
ELSIF haveQueriedState = FALSE THEN
IF (p_state <> '') THEN
v_where := v_where|| ' AND UPPER(addresses.state) = UPPER('||''''|| p_state ||''''||') ' ;
ELSE
IF (p_country_code = 'UK') THEN
tempLikeZip := UPPER(SUBSTR(p_zip_or_postalcode,( LENGTH(TRIM(p_zip_or_postalcode)) - 4 )));
v_where := v_where|| ' AND UPPER(addresses.zip_or_postalcode) LIKE '||'''%'||tempLikeZip ||''''||' ' ;
ELSE
OPEN cursor_locateAConsultant FOR 'SELECT state FROM ref_zip_mappings where UPPER(zip_or_postalcode) = UPPER('||''''|| p_zip_or_postalcode ||''''||') ' ;
LOOP
FETCH cursor_locateAConsultant INTO stateMapped;
EXIT WHEN cursor_locateAConsultant%NOTFOUND;
END LOOP;
CLOSE cursor_locateAConsultant;
v_where := v_where|| ' AND UPPER(addresses.state) = UPPER('||''''|| stateMapped ||''''||') ' ;
END IF;
haveQueriedState := TRUE;
END IF;
END IF;
v_sql := v_select || v_from || v_where;
OPEN v_cursor FOR v_sql;
DBMS_OUTPUT.PUT_LINE(v_sql);
--THIS IS THE PORTION I AM HAVING PROBLEMS WITH:
--If there are results I want to set the following
--haveResultsOrAllQueriesDone := TRUE;
--Otherwise, I want to leave haveResultsOrAllQueriesDone := FALSE; and continue to loop
RETURN v_cursor;
END LOOP;
END;
END;Thank you so very much for your kindness in answering my question.
Your suggestion helped.
We will be accessing this Procedure from a Java Class... I'm not sure how... but I know it is possible and probably not hard... If any one has suggestions, that would be helpful, but I am not concerned about that right now, as I think it should be straight forward... Hopefully I'm right :)
Thank you again!
Anne
Here's the code... which works, though may still need some more fine tuning:
create or replace
FUNCTION LOCATEACONSULTANT_function
p_action IN VARCHAR2,
p_first_name IN VARCHAR2,
p_last_name IN VARCHAR2,
p_exact_match IN VARCHAR2,
p_country_code IN VARCHAR2,
p_state IN VARCHAR2,
p_city IN VARCHAR2,
p_zip_or_postalcode IN VARCHAR2,
p_language_code IN VARCHAR2)
RETURN types.ref_cursor
AS
v_cursor types.ref_cursor;
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
DECLARE
type ref_cursor
IS
REF
CURSOR;
cursor_locateAConsultant types.ref_cursor;
v_select VARCHAR2(3000);
v_from VARCHAR2(2000);
v_where VARCHAR2(4000);
v_where_filter VARCHAR2(4000);
v_sql VARCHAR2(4000);
v_select1 VARCHAR2(4000):= 'SELECT 1 ';
v_temp VARCHAR2(1000);
stateMapped ref_zip_mappings.state%type;
countyMapped ref_zip_mappings.county%type;
cityMapped ref_zip_mappings.city%type;
v_hasRecords NUMBER := 0;
haveQueriedLanguage BOOLEAN := FALSE;
haveQueriedZip BOOLEAN := FALSE;
haveQueriedCity BOOLEAN := FALSE;
haveQueriedCounty BOOLEAN := FALSE;
haveQueriedState BOOLEAN := FALSE;
haveResultsOrAllQueriesDone BOOLEAN := FALSE;
haveDoneAllQueries BOOLEAN := FALSE;
tempLikeZip VARCHAR2(100);
BEGIN
v_select := 'SELECT customers.customer_id, customers.first_name, customers.last_name, ';
v_select := v_select || ' addresses.country_code, addresses.state, addresses.city, ';
v_select := v_select || ' addresses.zip_or_postalcode, customer_contacts.email_address, ';
v_select := v_select || ' customer_contacts.web_site, customer_languages.language_code';
v_from := ' FROM customers, customer_addresses, addresses, customer_contacts, customer_titles, customer_languages';
v_where := ' WHERE customers.customer_id = customer_addresses.customer_id ';
v_where := v_where || ' AND customer_addresses.address_id = addresses.address_id ';
v_where := v_where || ' AND customers.customer_id = customer_contacts.customer_id ';
v_where := v_where || ' AND customers.customer_id = customer_titles.customer_id ';
v_where := v_where || ' AND customers.preferred_language_code = customer_languages.language_code ';
v_where := v_where || ' AND UPPER(addresses.country_code) = UPPER(''' || p_country_code || ''') ';
v_where := v_where || ' AND UPPER(customers.exclude_locate) = '||''''||'N'||''''||'';
v_where := v_where || ' AND UPPER(customer_titles.customer_type) = '||''''||'CON'||''''||'';
v_where := v_where || ' AND UPPER(customer_titles.dp_id) LIKE '||''''||'CN%'||''''||'';
-- Line below assumes that 1 is the billing_address_type
v_where := v_where || ' AND customer_addresses.address_type_code = 1 ';
v_where := v_where || ' AND ';
v_where := v_where || ' ( ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MY%.COM%'||''''||' ';
v_where := v_where || ' OR ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MY%.COM.AU%'||''''||' ';
v_where := v_where || ' OR ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MY%.CA%'||''''||' ';
v_where := v_where || ' OR ';
v_where := v_where || ' UPPER(customer_contacts.web_site) LIKE '||''''||'%MY%.UK%'||''''||' ';
v_where := v_where || ' ) ';
WHILE (haveResultsOrAllQueriesDone = FALSE)
LOOP
CASE
WHEN (UPPER(p_action) =UPPER('search')) THEN
v_where_filter := '';
v_where_filter := v_where_filter || ' AND UPPER(addresses.state) = UPPER(trim(''' || p_state || ''')) ';
IF UPPER(p_exact_match) = UPPER('y') THEN
v_where_filter := v_where_filter || ' AND UPPER(customers.first_name) = UPPER(trim(''' || p_first_name || ''')) ';
ELSE
v_where_filter := v_where_filter || ' AND UPPER(SOUNDEX(customers.first_name)) = UPPER(SOUNDEX(trim(''' || p_first_name || '''))) ';
END IF;
IF UPPER(p_last_name) <> '' THEN
IF UPPER(p_exact_match) = UPPER('y') THEN
v_where_filter := v_where_filter || ' AND UPPER(customers.last_name) = UPPER(trim(''' || p_last_name || ''')) ';
ELSE
v_where_filter := v_where_filter || ' AND UPPER(SOUNDEX(customers.last_name)) = UPPER(SOUNDEX(trim(''' || p_last_name || ''')) ';
END IF;
END IF;
IF UPPER(p_city) <> '' THEN
v_where_filter := v_where_filter || ' AND UPPER(addresses.city) = UPPER(''' || p_city || ''') ';
END IF;
IF UPPER(p_zip_or_postalcode) <> '' THEN
v_where_filter := v_where_filter || ' AND UPPER(addresses.zip_or_postalcode) = UPPER(''' || p_zip_or_postalcode || ''') ';
END IF;
WHEN (p_action = 'locate') THEN
v_where_filter := '';
IF (haveQueriedLanguage = FALSE) THEN
IF (p_language_code <> '') THEN
v_where_filter := v_where_filter|| ' AND UPPER(customer_languages.language_code) = UPPER(''' || p_language_code || ''') ';
haveQueriedLanguage := TRUE;
END IF;
--ELSE
-- haveQueriedLanguage := FALSE;
END IF;
CASE
WHEN (haveQueriedZip = FALSE) THEN
v_where_filter := v_where_filter || ' AND UPPER(addresses.zip_or_postalcode) = UPPER(''' || p_zip_or_postalcode || ''') ';
IF (haveQueriedLanguage = FALSE) THEN
haveQueriedZip := TRUE;
END IF;
WHEN (haveQueriedCity = FALSE) THEN
IF (p_city <> '') THEN
v_where_filter := v_where_filter || ' AND UPPER(addresses.city) = UPPER('||''''|| p_city ||''''||') ' ;
ELSE
IF (p_country_code = 'UK') THEN
tempLikeZip := SUBSTR(p_zip_or_postalcode,( LENGTH(TRIM(p_zip_or_postalcode)) - 2 ));
v_where_filter := v_where_filter || ' AND UPPER(addresses.zip_or_postalcode) LIKE UPPER(TRIM('||'''%'||tempLikeZip ||''''||')) ' ;
ELSE
v_temp := 'SELECT city FROM ref_zip_mappings where UPPER(zip_or_postalcode) = UPPER(TRIM('||''''|| p_zip_or_postalcode ||''''||')) ';
OPEN cursor_locateAConsultant FOR v_temp ;
LOOP
FETCH cursor_locateAConsultant INTO cityMapped;
EXIT
WHEN cursor_locateAConsultant%NOTFOUND;
END LOOP;
CLOSE cursor_locateAConsultant;
cityMapped := TRIM(cityMapped);
v_where_filter := v_where_filter || ' AND UPPER(addresses.city) = UPPER('||''''|| cityMapped ||''''||') ' ;
END IF;
END IF;
haveQueriedCity := TRUE;
WHEN (haveQueriedCounty = FALSE) THEN
IF (p_country_code = 'UK') THEN
tempLikeZip := UPPER(SUBSTR(p_zip_or_postalcode,( LENGTH(TRIM(p_zip_or_postalcode)) - 3 )));
v_where_filter := v_where_filter || ' AND UPPER(addresses.zip_or_postalcode) LIKE '||'''%'||tempLikeZip ||''''||' ' ;
ELSE
OPEN cursor_locateAConsultant FOR 'SELECT county FROM ref_zip_mappings where UPPER(zip_or_postalcode) = UPPER('||''''|| p_zip_or_postalcode ||''''||') ' ;
LOOP
FETCH cursor_locateAConsultant INTO countyMapped;
EXIT
WHEN cursor_locateAConsultant%NOTFOUND;
END LOOP;
CLOSE cursor_locateAConsultant;
countyMapped := TRIM(countyMapped);
v_where_filter := v_where_filter || ' AND UPPER(addresses.province_county) = UPPER(TRIM('||''''|| countyMapped ||''''||')) ' ;
END IF;
haveQueriedCounty := TRUE;
WHEN (haveQueriedState = FALSE) THEN
IF (p_state <> '') THEN
v_where_filter := v_where_filter || ' AND UPPER(addresses.state) = UPPER('||''''|| p_state ||''''||') ' ;
ELSE
IF (p_country_code = 'UK') THEN
tempLikeZip := UPPER(SUBSTR(p_zip_or_postalcode,( LENGTH(TRIM(p_zip_or_postalcode)) - 4 )));
v_where_filter := v_where_filter || ' AND UPPER(addresses.zip_or_postalcode) LIKE '||'''%'||tempLikeZip ||''''||' ' ;
ELSE
OPEN cursor_locateAConsultant FOR 'SELECT state FROM ref_zip_mappings where UPPER(zip_or_postalcode) = UPPER('||''''|| p_zip_or_postalcode ||''''||') ' ;
LOOP
FETCH cursor_locateAConsultant INTO stateMapped;
EXIT
WHEN cursor_locateAConsultant%NOTFOUND;
END LOOP;
CLOSE cursor_locateAConsultant;
stateMapped := TRIM(stateMapped);
v_where_filter := v_where_filter || ' AND UPPER(addresses.state) = UPPER(TRIM('||''''|| stateMapped ||''''||')) ' ;
END IF;
haveQueriedState := TRUE;
END IF;
END CASE;
END CASE;
v_select1 := 'SELECT 1 ' || v_from || v_where || v_where_filter;
OPEN v_cursor FOR v_select1;
DBMS_OUTPUT.PUT_LINE(v_select1);
FETCH v_cursor INTO v_hasRecords;
IF (v_hasRecords = 1) THEN
haveResultsOrAllQueriesDone := TRUE;
ELSE
haveResultsOrAllQueriesDone := FALSE;
END IF;
IF ((haveResultsOrAllQueriesDone = TRUE) OR (haveQueriedState = TRUE)) THEN
v_sql := v_select || v_from || v_where || v_where_filter;
OPEN v_cursor FOR v_sql;
DBMS_OUTPUT.PUT_LINE(v_sql);
RETURN v_cursor;
END IF;
END LOOP;
END;
END; -
Update a partioned table dynamically
Hi All,
Parameters:
MANDATORY input parameters, FROM_DATE and TO_DATE.
OPTIONAL input parameter REVENUE_ID
My requirement:
To update table "ABC" based on the MANDATORY input parameters, FROM_DATE and TO_DATE. If the optional parameter, REVENUE_ID is entered, then, the column dept in ABC should get updated for the particular REVENUE_ID.
Steps Taken:
1) Since ABC has 3million rows.. A simple Update will take a long time and affect performance. So, I am updating it PARTITION wise.
2) I am fetching the PARTITION name in the cursor.(Partition is done period Wise on the table).
Code Created:
CREATE OR REPLACE PROCEDURE apps.test_dept_upd_prc (
p_from_date IN VARCHAR2,
p_to_date IN VARCHAR2,
p_revenue_id IN NUMBER
AS
CURSOR c_period (l_from_date DATE, l_to_date DATE)
IS
SELECT DISTINCT REPLACE (period_name, '-', '_') period_name,
start_date,
'ABC_'
|| REPLACE (period_name, '-', '_') partition_name
FROM gl_period_statuses
WHERE start_date BETWEEN TRUNC (TO_DATE (l_from_date), 'MM')
AND TRUNC (TO_DATE (l_to_date), 'MM')
AND set_of_books_id = 1
AND application_id = 101
ORDER BY start_date ASC;
TYPE tbl_period IS TABLE OF c_period%ROWTYPE
INDEX BY BINARY_INTEGER;
rec_period tbl_period;
l_from_date DATE;
l_to_date DATE;
l_partition VARCHAR2 (100);
BEGIN
-- DBMS_OUTPUT.ENABLE (1000000);
l_from_date := TO_DATE (fnd_date.canonical_to_date (p_from_date));
l_to_date := TO_DATE (fnd_date.canonical_to_date (p_to_date));
OPEN c_period (l_from_date, l_to_date);
LOOP
FETCH c_period
BULK COLLECT INTO rec_period LIMIT 100;
EXIT WHEN c_period%NOTFOUND;
FORALL i IN 1 .. rec_period.COUNT
UPDATE ABC PARTITION (rec_period (i).partition_name) kr
SET kr.dept =
NVL ((SELECT rt.attribute1
FROM ra_territories rt, hz_cust_site_uses_all hc
WHERE rt.territory_id = hc.territory_id
AND kr.ship_to_site_use_id = hc.site_use_id),
kr.dept
WHERE kr.dept NOT IN (SELECT attribute1
FROM ra_territories)
AND TRUNC (kr.creation_date) BETWEEN TO_DATE (l_from_date)
AND TO_DATE (l_to_date)
AND kr.revenue_id =
NVL2 (p_revenue_id, p_revenue_id, kr.revenue_id);
END LOOP;
COMMIT;
CLOSE c_period;
END test_dept_upd_prc;
Issue:
When I compile the code, it gives me an error at line
UPDATE ABC PARTITION (rec_period (i).partition_name) kr
as below:
PL/SQL: ORA-00971: missing SET keyword
This is the 1st time, I am using the BULK Binding concept. But, I have not been able to debug.
Please help me in solving this issue.
Thanks!
Regards,
ABPartitioning is a PHYSICAL database design feature. Similar to the physical storage clause for the table. The block size of the tablespace for that table. The name of the primary key constraint of that table. Etc.
Application code works with the LOGICAL database design. So the app code needs to know the name of the table, the columns, and what the relationships are (e.g. for correctly joining that table with others).
App code does this in order to satisfy business requirements. Like processing an invoice. Or processing a leave application.
Why should app code ever need to know physical features and characteristics of a table? What business requirement says that "+process the invoice+" and then "+oh yes, use index SYS_C102344 to verify the customer's id+"?
Application DOES NOT need to know ANYTHING about the physical database implementation. It does not need to know whether the table is a hash table or index organised table. It does not need to know whether or not the table is clustered.
And it does not need to know whether the table is partitioned.. nor what partitions should or should not be used.
If your application needs to know physical attributes of the table, like partition name, then your application code and design are flawed.
Oracle's CBO (Cost Based Optimiser) has all the data needed for it to make the decision of how to best use the physical features and attributes of the data objects used by your application SQL. It can perfectly well determine what partitions to use and not use.
It makes no sense at all for your application code to infringe on what the CBO does - and does very well. Your code does not have the same abilities. Your code lacks the intelligence. Your application code will never be able to compete with the CBO. -
My pl/sql procedure works; I'm just looking for someone to review it
Hi All,
I wrote the below procedure to be executed via APEX (inside the APEX_PLSQL_JOB.SUBMIT_PROCESS wrapper).
It works fine, but I'm not a programmer per se and am just curious if one of the veterans on this forum could review it
and just tell me if it looks like I followed proper standards/procedures etc. or make any suggestions on how I can be more efficient etc.
The purpose of the procedure is to update Oracle Applications translations tables with language-translated values that we have
accumulated from our global workforce. It's pretty simple - just a big find and replace exercise - replacing english values in the apps
tables with translated values. Oracle's '_TL' tables are designed for this purpose and I'm not updating any primary or foriegn keys.
I don't know the exact update statement or instance at the time of execution and hence the need for dynamic SQL and a DB link.
Again, there are no issues (yet) - everything is working fine, I'm just interested in having someone review it and offer me some feedback.
thanks in advance,
John
create or replace
procedure GSE_UPDATE_TL_TABLES (l_instance IN varchar2, l_app_job IN number)
IS
l_tname varchar2(30);
l_column_name VARCHAR2(30);
l_col_value VARCHAR2(4000);
l_eng_value VARCHAR2(4000);
l_language VARCHAR2(4);
i number;
l_query VARCHAR2(4000);
l_messages dbms_output.chararr;
l_numlines integer := 1000; -- retrieves max 1000 messages from the buffer
l_rows_updated number := 0;
l_rows_processed number;
CURSOR TABLES_CUR IS
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_VALUE, eng_value, LANGUAGE FROM GSE_LNG_STRINGS WHERE COMPLETION_STATUS = 'Y'; ---This table is our repository of translations
and includes the english value, the translated values, the language code and the table and column names that will be updated.
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
delete from gse_update_tracking; ---I'm using this table to track real-time progress and to update a progress status bar in APEX.
commit;
open tables_cur;
LOOP
fetch tables_cur into l_tname, l_column_name,l_col_value, l_eng_value, l_language;
EXIT WHEN tables_cur%NOTFOUND;
BEGIN
EXECUTE IMMEDIATE
'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']'' where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
l_rows_updated := (l_rows_updated + sql%rowcount);
insert into gse_update_tracking (counter) values (1);
commit;
exception
when dup_val_on_index then
l_query := 'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']'' where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
DBMS_OUTPUT.PUT_LINE('This query caused DUP_VAL_ON_INDEX exception: '||l_query);
when others then
l_query := 'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']'' where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
DBMS_OUTPUT.PUT_LINE('This caused an undefined exception: '||l_query);
end;
End Loop;
l_rows_processed := tables_cur%rowcount;
update gse_lng_jobs set rows_processed = l_rows_processed, rows_updated = l_rows_updated where job_id = l_app_job;
close tables_cur;
begin
dbms_output.get_lines(l_messages, l_numlines);
for i in 1..l_messages.count
loop
insert into gse_lng_update_exceptions(id, text, Job) values(i, l_messages(i), l_app_job);
commit;
end loop;
end;
END;Hoek, davidp 2, Tubby, rp0428 et al.,
I think I'm making progress. I'm researching and trying to incorporate your suggestions.
I worked through the examples of error logging here: http://www.oracle.com/technetwork/issue-archive/2006/06-mar/o26performance-096310.html. I'm not sure if this will work for me though since I'm updating many tables and not just one. So it seems I would need to run this for every table that I'm updating?
BEGIN
DBMS_ERRLOG.CREATE_ERROR_LOG('[table_name]');
END;
Otherwise, this is the current state of things:
create or replace
procedure gse_lng_test_1 (p_table varchar2, p_column varchar2) *--using proper parameter names prefixed with 'p' to distinguish from local variables*
IS
i number;
l_query VARCHAR2(4000);
l_messages dbms_output.chararr;
l_numlines integer := 1000; -- retrieves max 1000 messages from the buffer
l_rows_updated number := 0;
l_rows_processed number;
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
commit;
l_query := 'Update ' ||p_table||' set ' ||p_column|| ' = :newval where '||p_column|| ' = :engval and language = :lang' ; *--build the string once in a local variable with bind variables. Table names and column names are passed via parameters*
for c2 IN (SELECT TABLE_NAME, COLUMN_NAME, COLUMN_VALUE, eng_value, LANGUAGE FROM GSE_LNG_STRINGS WHERE COMPLETION_STATUS = 'Y' and table_name = p_table and column_name = p_column) *--using implicit cursor instead of explicit cursor*
LOOP
BEGIN
EXECUTE IMMEDIATE l_query USING c2.eng_value, c2.column_value, c2.language; *--execute immediate with bind variables*
exception
when dup_val_on_index then
dbms_output.put_line('this query caused a dup_val_on_index: '||SQLERRM||' - '||l_query); *--include SQLERRM in message*
when others then
dbms_output.put_line('this query caused an exception: '||SQLERRM||' - '||l_query); *--include SQLERRM in message*
end;
commit;
end loop;
end;Now that the table names and column names are in parameters, I am calling this from APEX as follows:
Begin
for c1 in (select distinct table_name, column_name from gse_lng_strings)
LOOP
gse_lng_test_1 (p_table=> c1.table_name, p_column=>c1.column_name);
end loop;
end;The one thing I need to do is to get a status of the number of rows processed and updated so I can report back to APEX realtime with a jquery counter plugin that I'm using. That was the reason I was inserting records into a dummy table (gse_update_tracking) before. It worked ok but I realize it was a clumsy approach. I'm not to sure how to accomplish that since I don't think I can access sql%rowcount while the loop is running. Is that correct and if so, are there any other options?
I know I still need to deal with my exception handling and I would like to use the DML error logging if at all possible.
Overall though I feel like it's much cleaner and more manageable. Hopefully it's looking better?
thanks again for the education - I really appreciate it,
John -
Pl/sql exception not caught.
This program should give me an error "table or view does not exist" caught by the pl/sql exception, as dba_data_file1 table does not exist.
However all that it returns is Input truncated to 3 characters
Q1. Why?
Q2. How can I remove this message "Input truncated to 3 characters. Where is this message comming from?
#!/bin/ksh
sqlplus -s << EOF
abc/[email protected]
set pages 0
SET SERVEROUTPUT ON BUFFER 100000000
BEGIN
dbms_output.ENABLE(1000000);
SELECT
round(sum(bytes)/1024/1024/1024),
round(sum(free_bytes)/1024/1024/1024),
TRUNC(SYSDATE)
from
(SELECT tablespace_name, BYTES, 0 FREE_BYTES FROM dba_data_files1
UNION ALL
SELECT tablespace_name, 0, BYTES FROM dba_free_space
union all
SELECT tablespace_name, BYTES, 0 FROM dba_temp_files
union all
SELECT 'REDO-LOGS', b.BYTES, 0
FROM v\\$logfile a, v\\$log b
WHERE
a.GROUP# = b.GROUP#);
dbms_output.put_line("ok ");
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line("Error "||SQLERRCODE ||":"|| SQLERRM);
exit 1
END;
exit 0
EOF
$> tstrun.ksh
Input truncated to 3 charactersEXCEPTION
WHEN OTHERS THEN
dbms_output.put_line("Error "||SQLERRCODE ||":"|| SQLERRM);
exit 1
END;
if you catch exception, process it then you must reraise it. its a general mistake found when you are using others instead of name exception, so remember whenever you use others you must reraise the exception -
DBI Reports Using PL/SQL Procedure
Hi all,
Is there anyone who worked on Creating a DBI report using a PL/SQL Procedure.
I want to customize a Report that is using Data Source as of type PL/SQL Procedure.
Please Reply to me If anyone has any Idea on this..
Thanks in Advance..Hi Blushadow
Now if i want to update say only 10 records at a time what should i put into my Proc?
Please go thru my Proc below..
CREATE OR REPLACE PROCEDURE PRTS.UPDT_ISSUE_USR_ROLE
As
Cursor cur_user_role Is
Select a.org_id,a.user_id
from prts_user a,issue_user_role b
where a.user_id=b.user_id;
upd_rec cur_user_role%rowtype;
v_rows_processed Number:=0;
Begin
Open cur_user_role;
Loop
Fetch cur_user_role into upd_rec;
If cur_user_role%NOTFOUND
Then
Exit;
Else
update Issue_user_role
set User_org_nm=(Select full_org_nm from VW_Org where org_id=upd_rec.org_id)
Where Issue_User_Role.rowid in
(select issue_user_role.rowid
FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
Where Issue_User_Role.Issue_Id=Issue.Issue_id
And Issue_User_Role.Issue_id=issue_workflow.issue_id
And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
And Issue.Issue_id=Issue_workflow.Issue_Id
And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And issue_workflow.primry_workflow_flag='Y'
And issue_user_role.user_id = upd_rec.user_id
And issue.issue_status_id in (1636,50738,275,50737,2090)
And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
If Mod (v_rows_processed,v_rows_processed)=10
then
COMMIT;
End if;END IF;
End Loop;
Commit;
dbms_output.enable(1000000);
dbms_output.put_line('There were '||v_rows_processed||' rows updated');
Close cur_user_role;
End;
I would appreciate if you can let me know any other alternative way to meet this requirment.
Cheers
Vineet
Maybe you are looking for
-
Problems with Apple Digital AV Adaptor
I have purchased an adaptor to plug my ipad into the tv with a HDMi cable and there's sound on the tv but no picture. Any ideas?
-
Hi Experts, I am new to Adobe forms. I have created a form and I dont know where to write the code for assigning values to the fields. I just want to send a internal table via interface and i want to retrive internal table values and I want to as
-
Send an escalation e-mail without reassigning a Task
Hi There, I came across this scenario recently, and I just wanted to check if it was possible, or what would the best way to achieve it. Lets say we want to notify a Supervisor or Administrator by e-mail when any User has not completed a task within
-
Issue with warehouse activity monitor LL01
In LL01 I can see some stock in interim storage with message "Interim storage stock, without movement".Pls suggest how can I clear them? Note : Many TO`s are cleared in LU02.
-
Is the GTX 660ti signed by adobe?
I have 2 x 660ti's in SLI and i'm currently thinking of selling my work machine and doing it all in one, so my question really is. Does adobe fully support the GTX 660ti? and yes i know that i can use CUDA to render, but is that all?