Urgent: ORA-04030 from PL/SQL code
Hi, we are running a data conversion program for Oracle Applications which works in the following logic
1. There is a loader program which uses SQLLoader to load 6.6L records from flat files to custom staging table
2. There is a Validation program which validates (for business requirements) records available in the custom staging table. Based on the validation results the program updates the Status field (a column of the table) to ERROR or SUCCESS. This program uses pl/sql table types with bulk insert and bulk update. While we run the program for less number of records it works fine, but when the volume of data is high (6.6L) we get the following exception:
ORA-04030 (out of process memory when trying to allocate ... bytes).
As an work around we have used "dbms_session.free_unused_user_memory;" statement after every plsql table.DELETE call. But still we get the issue. Can anyone suggest us whats going wrong? If we use of Global Temp Table in place of pl/sql table will it help?
Thanks /Santanu
Duplicate Thread
Urgent: ORA-04030 from Routing Conversion Validation Program
Similar Messages
-
Urgent: ORA-04030 from Routing Conversion Validation Program
Hi, we are running a data conversion program for Oracle Applications which works in the following logic
1. There is a loader program which uses SQLLoader to load 6.6L records from flat files to custom staging table
2. There is a Validation program which validates (for business requirements) records available in the custom staging table. Based on the validation results the program updates the Status field (a column of the table) to ERROR or SUCCESS. This program uses pl/sql table types with bulk insert and bulk update. While we run the program for less number of records it works fine, but when the volume of data is high (6.6L) we get the following exception:
4030ORA-04030: out of process memory when trying to allocate 64544 bytes (sort subheap,sort key)
As an work around we have used "dbms_session.free_unused_user_memory;" statement after every plsql table.DELETE call. But still we get the issue. Can anyone suggest us whats going wrong? If we use of Global Temp Table in place of pl/sql table will it help?
Thanks /SantanuHi,
Did you try the suggested solutions in (Note: 233869.1 - Diagnosing and Resolving ORA-4030 errors) and see if it helps?
Regards,
Hussein -
How to run an external application from PL/SQL code?
Hi,
I want to call an application like "Notepad" from PL/SQL code in a Windows2000 server. Is there any way to do that?
Thanks, best regards.
Paulo.declare
r varchar(4000);
begin
dbms_java.set_output(10000);
system_util.runshell('sh /ora9/runBackup.sh', r);
dbms_output.put_line(r);
end;
System_util package is
CREATE OR REPLACE PACKAGE System_Util IS
*System: Generic
*Package Name: System_util
*Description: This is an open source package which holds regular used
* methods by developers and dba's.
*Created by: Rae Smith
*Created Date: 27/06/2001
*Notes: This ia an free open source package that holds no warranty and
* therefore no-one connected to the development of this package
* can be made reasponsible for any outcomes by it's use.
MODIFICATION LOG**************************************************************
*DETAILS DATE VERS CHANGED BY
*===============================================================================
*Created 27-06-2001 1.0 Rae Smith
/********************************* Public Methhods ***************************************/
--- getDir returns the first directory value held in the init.ora file
FUNCTION getDir RETURN VARCHAR2;
--- getPrev.. returns the prevoise day from a gievn date
FUNCTION getPrevSat(pDate IN DATE) RETURN DATE;
FUNCTION getPrevSun(pDate IN DATE) RETURN DATE;
FUNCTION getPrevMon(pDate IN DATE) RETURN DATE;
FUNCTION getPrevTue(pDate IN DATE) RETURN DATE;
FUNCTION getPrevWed(pDate IN DATE) RETURN DATE;
FUNCTION getPrevThu(pDate IN DATE) RETURN DATE;
FUNCTION getPrevFri(pDate IN DATE) RETURN DATE;
--- isNumber returns TRUE or FALSE depending on a datatype passed
FUNCTION isNumber(pnumber IN VARCHAR2) RETURN BOOLEAN;
FUNCTION isNumber(pnumber IN NUMBER) RETURN BOOLEAN;
FUNCTION isNumber(pnumber IN DATE) RETURN BOOLEAN;
--- The writeFile allow you to write data to a file
--- writeFile has 2 Versions
--- v1 pass in the file name and the text to write to a file.
--- v2 pass in the file name, dbms_sql.varhar2s object
--- and the amount of rows to procces at a time
--- This enables you to write to afile in batch mode
PROCEDURE writeFile(pName IN VARCHAR2, pText IN VARCHAR2);
PROCEDURE writeFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER);
--- The appendFile methods allow you to append data to a file
--- This also has the inteligents to create the file if ts does not exist.
--- appendFile has 2 Versions
--- v1 pass in the file name and the text to write to a file.
--- v2 pass in the file name, dbms_sql.varhar2s object
--- and the amount of rows to procces at a time
--- This enables you to write to afile in batch mode
PROCEDURE appendFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER);
PROCEDURE appendFile(pName IN VARCHAR2, pText IN VARCHAR2);
--- The clearFile clears the data from a file.
PROCEDURE clearFile(pName IN VARCHAR2);
--- checkSyntax is a quick syntax checker for sql statements the is a limit to
--- the size used in the statement. If you have a error with
--- a statement then pass in the statement watch as it displays
--- the point where the error arose.
PROCEDURE checkSyntax(pSql IN VARCHAR2);
--- isEmpty this returns TRUE or FALSE
FUNCTION isEmpty(pValue IN VARCHAR2) RETURN BOOLEAN;
--- getTimeInMins returns the time in minutes for a specified date
FUNCTION getTimeInMins (pDate IN DATE) RETURN NUMBER;
--PROCEDURE get_time_in_mins (pDate IN DATE);
--- incDate returns a specified date incremented by value
FUNCTION incDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE;
--- decDate returns a specified date decremented by value
FUNCTION decDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE;
--- getTime returns the time in milliseconds
FUNCTION getTime RETURN NUMBER;
--- daysDiff returns the amount of days between two values
FUNCTION daysDiff(pHigh IN DATE, pLow IN DATE) RETURN NUMBER;
--- difference returns the diffeence between two numbers always
--- taking the lowest away from the highest
FUNCTION difference(pAnum IN NUMBER,pBnum IN NUMBER)RETURN NUMBER;
--- total returns the value of two numbers added together
FUNCTION total(pAnum IN NUMBER, pBnum IN NUMBER)RETURN NUMBER;
--- numberToWords returns the string for a number passed in
FUNCTION numberToWords(pNumb IN NUMBER) RETURN VARCHAR2;
--- runShell allows you to run operating commands from pl/sql
--- Only available with 8i
--- PROCEDURE runShell(pCmnd IN VARCHAR2, pErrMsg IN OUT VARCHAR2);
/**************************** Public Vaiables *******************************/
--- Public variable that holds the operating system directory
--- that the can be written to from withing the database.
vDir VARCHAR2(50);
END;
CREATE OR REPLACE PACKAGE BODY System_Util IS
FUNCTION getDir RETURN VARCHAR2
IS
BEGIN
RETURN vDir;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('ERROR...ERROR...System_Util.getDir');
RAISE;
END getDir;
/**** Private module to get the first directory for utl_file to use ****/
PROCEDURE getDir
IS
CURSOR cDir(p1 IN VARCHAR2)
IS
SELECT DECODE(INSTR(value, ','), 0, value, SUBSTR(value, 1, INSTR(value, ',')-1)) dir
FROM v$parameter
WHERE name = p1;
BEGIN
FOR rDir IN cDir('utl_file_dir') LOOP
vDir := rDir.dir;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('ERROR...ERROR...System_Util.getDir');
RAISE;
END getDir;
FUNCTION getPrevDate(pDate IN DATE, pDay IN VARCHAR2) RETURN DATE
IS
BEGIN
RETURN NEXT_DAY(pDate - 7, pDay);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevDate;
FUNCTION getPrevSat(pDate IN DATE) RETURN DATE
IS
BEGIN
RETURN getPrevDate(pDate, 'saturday');
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevSat;
FUNCTION getPrevSun(pDate IN DATE) RETURN DATE
IS
BEGIN
RETURN getPrevDate(pDate, 'sunday');
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevSun;
FUNCTION getPrevMon(pDate IN DATE) RETURN DATE
IS
BEGIN
RETURN getPrevDate(pDate, 'monday');
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevMon;
FUNCTION getPrevTue(pDate IN DATE) RETURN DATE
IS
BEGIN
RETURN getPrevDate(pDate, 'tuesday');
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevTue;
FUNCTION getPrevWed(pDate IN DATE) RETURN DATE
IS
BEGIN
RETURN getPrevDate(pDate, 'wednesday');
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevWed;
FUNCTION getPrevThu(pDate IN DATE) RETURN DATE
IS
BEGIN
RETURN getPrevDate(pDate, 'thursday');
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevThu;
FUNCTION getPrevFri(pDate IN DATE) RETURN DATE
IS
BEGIN
RETURN getPrevDate(pDate, 'friday');
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getPrevFri;
FUNCTION isNumber(pNumber IN VARCHAR2) RETURN BOOLEAN
IS
BEGIN
IF TO_NUMBER(pNumber)> 0 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN FALSE;
END isNumber;
FUNCTION isNumber(pNumber IN NUMBER) RETURN BOOLEAN
IS
BEGIN
IF TO_NUMBER(pNumber) > 0 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN FALSE;
END isNumber;
FUNCTION isNumber(pNumber IN DATE) RETURN BOOLEAN
IS
BEGIN
IF TO_NUMBER(TO_CHAR(pNumber, 'YYYYMMDD')) > 0 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN FALSE;
END isNumber;
PROCEDURE writeFile(pName IN VARCHAR2, pText IN VARCHAR2)
IS
vFtype utl_file.file_type;
BEGIN
vFtype := UTL_FILE.FOPEN(vDir, pName,'w');
UTL_FILE.PUT_LINE(vFtype,pText);
UTL_FILE.FCLOSE(vFtype);
EXCEPTION
WHEN OTHERS THEN
UTL_FILE.FCLOSE(vFtype);
RAISE;
END writeFile;
PROCEDURE writeFile(pName IN VARCHAR2, pText IN VARCHAR2, pFtyp IN OUT utl_file.file_type)
IS
vFtype utl_file.file_type;
BEGIN
vFtype := UTL_FILE.FOPEN(vDir, pName,'w');
UTL_FILE.PUT_LINE(vFtype,pText);
UTL_FILE.FCLOSE(vFtype);
EXCEPTION
WHEN OTHERS THEN
UTL_FILE.FCLOSE(vFtype);
RAISE;
END writeFile;
PROCEDURE writeFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER)
IS
vFtype utl_file.file_type;
vText VARCHAR2(2000);
vCnt BINARY_INTEGER;
vRem BINARY_INTEGER;
vRowcnt PLS_INTEGER := 0;
BEGIN
vRem := MOD(pText.COUNT, pRows);
vFtype := UTL_FILE.FOPEN(vDir, pName, 'w');
vCnt := pText.FIRST;
LOOP
EXIT WHEN vCnt IS NULL;
vRowcnt := vRowcnt + 1;
IF vCnt = pText.LAST THEN
vText := vText||pText(vCnt);
UTL_FILE.PUTF(vFtype,vText);
UTL_FILE.FFLUSH(vFtype);
vText := '';
ELSIF MOD(vCnt, pRows) = 0 THEN
vText := vText||pText(vCnt)||'\n';
UTL_FILE.PUTF(vFtype,vText);
UTL_FILE.FFLUSH(vFtype);
vText := '';
ELSIF vRowcnt = vRem THEN
vText := vText||pText(vCnt)||'\n';
UTL_FILE.PUTF(vFtype,vText);
UTL_FILE.FFLUSH(vFtype);
ELSE
vText := vText||pText(vCnt)||'\n';
END IF;
vCnt := pText.NEXT(vCnt);
END LOOP;
UTL_FILE.FCLOSE(vFtype);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('ERROR...ERROR...SYSTEM_UTIL.WRITE_FILE');
UTL_FILE.FCLOSE(vFtype);
RAISE;
END writeFile;
PROCEDURE appendFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER)
IS
vFtype utl_file.file_type;
vText VARCHAR2(2000);
vCnt BINARY_INTEGER;
vRem BINARY_INTEGER;
vMode VARCHAR2(2) := 'a';
vRowcnt PLS_INTEGER := 0;
BEGIN
vRem := MOD(pText.COUNT, pRows);
vFtype := UTL_FILE.FOPEN(vDir, pName, vMode);
vCnt := pText.FIRST;
LOOP
EXIT WHEN vCnt IS NULL;
vRowcnt := vRowcnt + 1;
IF vCnt = pText.LAST THEN
vText := vText||pText(vCnt);
UTL_FILE.PUTF(vFtype,vText);
UTL_FILE.FFLUSH(vFtype);
vText := '';
ELSIF MOD(vCnt, pRows) = 0 THEN
vText := vText||pText(vCnt)||'\n';
UTL_FILE.PUTF(vFtype,vText);
UTL_FILE.FFLUSH(vFtype);
vText := '';
ELSIF vRowcnt = vRem THEN
vText := vText||pText(vCnt)||'\n';
UTL_FILE.PUTF(vFtype,vText);
UTL_FILE.FFLUSH(vFtype);
ELSE
vText := vText||pText(vCnt)||'\n';
END IF;
vCnt := pText.NEXT(vCnt);
END LOOP;
UTL_FILE.FCLOSE(vFtype);
EXCEPTION
WHEN UTL_FILE.INVALID_OPERATION THEN
IF vMode = 'a' THEN
writeFile(pName, pText, pRows);
ELSE
RAISE;
END IF;
WHEN OTHERS THEN
dbms_output.put_line('ERROR...ERROR...SYSTEM_UTIL.APPENDFILE');
UTL_FILE.FCLOSE(vFtype);
RAISE;
END appendFile;
PROCEDURE appendFile(pName IN VARCHAR2, pText IN VARCHAR2)
IS
vFtype utl_file.file_type;
vMode VARCHAR2(2) := 'a';
BEGIN
vFtype := UTL_FILE.FOPEN(vDir, pName, vMode);
UTL_FILE.PUTF(vFtype, pText);
UTL_FILE.FFLUSH(vFtype);
UTL_FILE.FCLOSE(vFtype);
EXCEPTION
WHEN UTL_FILE.INVALID_OPERATION THEN
IF vMode = 'a' THEN
writeFile(pName, pText);
ELSE
RAISE;
END IF;
WHEN OTHERS THEN
dbms_output.put_line('ERROR...ERROR...SYSTEM_UTIL.APPENDFILE');
UTL_FILE.FCLOSE(vftype);
RAISE;
END appendFile;
PROCEDURE clearFile(pName IN VARCHAR2)
IS
vFtype utl_file.file_type;
vText VARCHAR2(2000);
vCnt BINARY_INTEGER;
vRem BINARY_INTEGER;
vRowcnt PLS_INTEGER := 0;
BEGIN
vFtype := UTL_FILE.FOPEN(vDir, pName, 'w');
UTL_FILE.PUTF(vFtype,'');
UTL_FILE.FFLUSH(vFtype);
UTL_FILE.FCLOSE(vFtype);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('ERROR...ERROR...System_Util.CLEARFILE');
UTL_FILE.FCLOSE(vFtype);
RAISE;
END clearFile;
PROCEDURE checkSyntax(pSql IN VARCHAR2)
IS
sqlCur PLS_INTEGER := DBMS_SQL.OPEN_CURSOR;
errPos PLS_INTEGER;
sqlStmt VARCHAR2(2000);
BEGIN
sqlStmt := pSql;
DBMS_SQL.PARSE(sqlCur, sqlStmt, DBMS_SQL.NATIVE);
EXCEPTION
WHEN OTHERS THEN
errPos := DBMS_SQL.LAST_ERROR_POSITION;
DBMS_OUTPUT.PUT_LINE(SQLERRM);
DBMS_OUTPUT.PUT_LINE(sqlStmt);
DBMS_OUTPUT.PUT_LINE(' ');
DBMS_OUTPUT.PUT_LINE(LPAD('^', errPos, '-'));
DBMS_SQL.CLOSE_CURSOR(sqlCur);
END checkSyntax;
FUNCTION isEmpty(pValue IN VARCHAR2) RETURN BOOLEAN
IS
BEGIN
IF pValue IS NULL OR pValue = '' OR pValue = ' ' THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END isEmpty;
FUNCTION getTimeInMins (pDate IN DATE) RETURN NUMBER
IS
vHours NUMBER;
vMins NUMBER;
vRetval PLS_INTEGER;
BEGIN
vHours := TO_NUMBER(TO_CHAR(pDate,'HH24'));
vMins := TO_NUMBER(TO_CHAR(pDate,'MI'));
vRetval := ((60 * vHours) + vMins);
RETURN vRetval;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getTimeInMins;
PROCEDURE getTimeInMins (pDate IN DATE)
IS
vHours NUMBER;
vMins NUMBER;
vRetval PLS_INTEGER;
BEGIN
vHours := TO_NUMBER(TO_CHAR(pDate,'HH24'));
vMins := TO_NUMBER(TO_CHAR(pDate,'MI'));
vRetval := ((60 * vHours) + vMins);
DBMS_OUTPUT.PUT_LINE('The time IN minutes IS: '||vRetval);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END getTimeInMins;
FUNCTION incDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE
IS
BEGIN
RETURN (TO_DATE(TO_CHAR(pDate + pInc, 'DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YYYY HH24:MI:SS'));
EXCEPTION
WHEN OTHERS THEN
RAISE;
END incDate;
FUNCTION decDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE
IS
BEGIN
RETURN (TO_DATE(TO_CHAR(pDate - pInc, 'DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YYYY HH24:MI:SS'));
EXCEPTION
WHEN OTHERS THEN
RAISE;
END decDate;
FUNCTION getTime RETURN NUMBER
IS
BEGIN
RETURN dbms_utility.get_time;
END getTime;
FUNCTION daysDiff(pHigh IN DATE, pLow IN DATE) RETURN NUMBER
IS
vHighdate DATE;
vLowdate DATE;
BEGIN
IF pHigh > pLow THEN
vHighdate := TO_DATE(TO_CHAR(pHigh, 'YYYYMMDD'), 'YYYYMMDD');
vLowdate := TO_DATE(TO_CHAR(pLow, 'YYYYMMDD'), 'YYYYMMDD');
ELSIF pLow > pHigh THEN
vHighdate := TO_DATE(TO_CHAR(pLow, 'YYYYMMDD'), 'YYYYMMDD');
vLowdate := TO_DATE(TO_CHAR(pHigh, 'YYYYMMDD'), 'YYYYMMDD');
END IF;
RETURN (vHighdate - vLowdate);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END daysDiff;
PROCEDURE dateCheck(pDateFrom IN OUT DATE, pDateTo IN OUT DATE)
IS
/* Declare the variable to hold the "from" date */
vDateFrom DATE;
BEGIN
/* If either date_from or date_to is null then set to todays date **
** using the sysdate **
** today's DATE AND IN the correct format */
pDateFrom := NVL(pDateFrom, SYSDATE);
pDateTo := NVL(pDateTo, SYSDATE);
/* Check that the from date is not greater than the to date if so **
** use the system_util.incDate to Increment the date by 1 day */
IF (pDateFrom > pDateTo) THEN
vDateFrom := pDateFrom;
pDateTo := System_Util.incDate(1, vDateFrom);
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
/* calculates the difference of two numbers always taken the high from the low*/
FUNCTION difference(pAnum IN NUMBER, pBnum IN NUMBER)RETURN NUMBER
IS
vTotal NUMBER;
BEGIN
IF (pAnum > pBnum )OR (pAnum = pBnum)THEN
vTotal := (pAnum - pBnum);
ELSIF (pAnum < pBnum) THEN
vTotal := (pBnum - pAnum);
END IF;
RETURN (vTotal);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END difference;
/* calculates the Total of two numbers*/
FUNCTION total(pAnum IN NUMBER, pBnum IN NUMBER)RETURN NUMBER
IS
vTotal NUMBER;
BEGIN
vTotal := (pAnum + pBnum);
RETURN (vTotal);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END total;
FUNCTION numberToWords(pNumb IN NUMBER) RETURN VARCHAR2
IS
vRetval VARCHAR2(255);
vNumb PLS_INTEGER;
BEGIN
vNumb := pNumb;
vRetval := REPLACE(TO_CHAR(TO_DATE(vNumb,'j'),'jsp'),'-',' ');
RETURN (vRetval);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
/*************** Only Available on 8i ********************************\
FUNCTION Catcherr(pStr IN VARCHAR2) RETURN VARCHAR2
IS
LANGUAGE JAVA
NAME 'catchErr.run(java.lang.String) return String';
PROCEDURE runShell(pCmnd IN VARCHAR2, pErrMsg IN OUT VARCHAR2)
IS
BEGIN
pErrMsg := Catcherr(pCmnd);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END runShell;
BEGIN
getDir;
END; -
Accessing html field value from pl/sql code, in the same package
hi friends,
my pl/sql web application is working fine. but now i need a small requirment.
ie, basicaly i need to access the user entered value of an element in html based form from pl/sql code, which is developed using pl/sql toolkit.
Here is the scenario:-
User entered a value in field1, then navigate to field2, and click a button for list of values,
when he clicks the button, internaly it is opening a cursor, where i want to pass field1's value to my cursor as a parameter. So in my pls/sql code , i want to access the value of field1. If you know, please help.
see the snippet of code.
htp.p('
function f1()
if (parseInt(learnIdx) ==1 )
for i in dev_Need('1')/*here i want to pass html form element value as a parameter */
loop
htp.p('content += "<option value='''||a.version_name||'''>'||a.version_name
||'</option>''"; ');
end loop;
thanks in advance.
Zameer.N.AHi,
Here's my suggestion
If you wanna access the dll check out "external procedures", you can search it everywhere in OTN.
However it's easier to use Heterogenous Services to connect database with other sources.
Check out http://asktom.oracle.com/pls/ask/f?p=4950:8:13454621522426176943::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:4406709207206,
Tak Tang answer on May, 25, 2004 rules! -
Calling java program from PL/SQL code
Dear,
How to develop and call a java program from PL/SQL code?
What about if this program will call other java programs?Perhaps the Java Developer's Guide would be a good place to start
http://download.oracle.com/docs/cd/B19306_01/java.102/b14187/toc.htm
Justin -
ORA-06502 in pl/sql code after converting from 9i to 10g
Code worked in 9i, fails in 10g (v10.1.2.0.3) with "character buffer too small":
v_period varchar2(6);
select max(period) into v_period from fiscal_periods;
PERIOD in the table is CHAR(6), representing yyyymm.
I've discovered two workarounds:
1) Declare v_period as varchar2(4000), nothing smaller works
or
2) select TRIM(max(period)) into v_period from fiscal_periods;
The code worked okay in 9i, so is there a 10g change in variable handling I've missed? Or possibly bad programming form? Database vars NLS_SORT (blank), NLS_COMP (blank), and NLS_LANGUAGE (American) are set the same in 9i and 10g, all defaults.Thanks for your speedy response. The version is 10.2.0.1.0 according to Grid Control, so I assume 10.2.0.2 trumps it. (The previous version number I provided was the result of "select owa_util.get_version from dual;" in SQL Developer so it might be the SQL Worksheet version?) I'll get this info to the dba and we'll see what happens.
Thanks! -
Execute .Bat file from pl/sql code
Hi,
Can you please let me know that how can I execute the .Bat file from pl/sql procedure? Does anybody have a sample code??
Thanks.Hi
This may help you
http://www.dba-oracle.com/t_running_windows_bat_file_dbms_scheduler.htm
br,Jari -
(oracle 10.2) Access to v$session from pl/sql code
Hello,
I wonder if anybody can help me with the following problem as I have read some previous posts on similar topics but could not come to a solution so far.
The problem is simple: I need to select some columns form v$session from within a PL/SQL body in oracle 10.2.
Now, the "Application Developer's Guide - Fundamentals" reads:
"The owner of the procedure or package must be explicitly granted
the necessary object privileges for all objects referenced within the
body of the code."
However, if I connect sys as sysdba and run "grant select on v$session to <proc owner>" I will get "ORA-02030: can only select from fixed tables/views".
Any hint about this?
Thank you in advance.There is nothing wrong with your instance, v$session is a public synonym for the "real" view v_$session. You cannot grant on a synonym, only on the underlying real object.
HTH
John -
Calling Unix shell script from PL/sql code
Hi
I need to call a shell script from a procdeure which i need to run in toad. Let me kno whow can i do that and connect to unix box with an example.Thanks Avinash,
That on was very useful.
When I try to execute I got the following error.
Could you let me now What privileges are required?
SQL> BEGIN
dbms_scheduler.create_job(job_name => 'myjob',
job_type => 'executable',
job_action => '/home/rananto/a.sh',
enabled => TRUE,
auto_drop => TRUE);
END;
/ 2 3 4 5 6 7 8
BEGIN
ERROR at line 1:
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 99
ORA-06512: at "SYS.DBMS_SCHEDULER", line 262
ORA-06512: at line 2
SQL> exec dbms_scheduler.run_job('myjob');
BEGIN dbms_scheduler.run_job('myjob'); END;
ERROR at line 1:
ORA-27475: "CRDM.MYJOB" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at line 1 -
OS command from PL/SQL code
Is there any way of running on OS (Operating System) command from SQL or PL/SQL. i.e. calling an executable from a trigger.
Is there any way of running on OS (Operating System) command from >SQL or PL/SQL. i.e. calling an executable from a trigger. Ashis,
Here's an example of a simple piece of Java you can create using SQL*Plus:
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "RuntimeExample" AS public class RuntimeExample {
public static String runNotepad() {
String returnValue = null;
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec("notepad.exe");
returnValue = p.toString();
} catch (Exception e) {
System.out.println("Exception calling Runtime.exec()->" + e);
/* You can get creative here and
1) Use p.waitFor() to block while the process is running,
2) Send the command to be executed as a parameter to the method, etc. */
return returnValue;
CREATE OR REPLACE FUNCTION runNotepad RETURN VARCHAR2 IS
LANGUAGE JAVA NAME 'RuntimeExample.runNotepad() return java.lang.String';
DECLARE
my_varchar2 VARCHAR2(64);
BEGIN
my_varchar2 := runnotepad;
DBMS_OUTPUT.PUT_LINE(my_varchar2);
END;
Hope this helps,
-Dan
http://www.compuware.com/products/numega/dbpartner/dbpordebug.htm
Debug Java in the Oracle Database -
How can I go to another page from PL/SQL code
Hi
I have a code like this:
DECLARE
BEGIN
SELECT N INTO n_n FROM D WHERE ID=n_id;
INSERT INTO D (NUM,ID,NAME) VALUES(n_n,n_id,n_name);
EXCEPTION
WHEN NO_DATA_FOUND THEN
END;
In exception section I want to go to another page. How can I do this?
(I now it is stupid question, but I am newbie).
Thanks,
DagHello Dag,
you can use something like:
owa_util.redirect_url(f?p=&APP_ID.:14:&SESSION.)Just replace "14" with the target page id.
Hope this help,
Arie. -
URGENT - Call java from pl/sql
Hi,
How Can I call external java class in a pl/Sql ??
Regards
GiordanoHi
a way to do that, is to load the external java class in your database, like that (ORACLE_SID is setting):
loadjava -user myuser/mypassword /mypathname/myPackage.class
Then, you must declare this external procedure like that,
(for example)
CREATE OR REPLACE PROCEDURE p_jMyProcedure (Param in varchar2) AS LANGUAGE JAVA NAME 'myPackage.myProcedure(java.lang.String)';
you can call your procedure as a pl/sql procedure
so long; -
Explain plans for PL/SQL code?
Hi!
I am pulling SQL statements (select, insert, update, delete, etc.) from PL/SQL code and producing explain plans. Some of the delete statements have "WHERE CURRENT OF" in them which produces an ORA-3001 error (feature not implemented) error. How can I do an explain plan of these statements? Can I replace "WHERE CURRENT OF" with "=" to get a plan? How far off will the plan be? Any suggestions, ideas, etc. greatfully appreciated!
This is Oracle 9.2.0.4/5 on AIX if it makes a difference.
Thanks!
Dave VenusWHERE CURRENT OF shouldn't be a problem. Here above an example on 9.2.0.4 on AIX5.2 :
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> create table TBL_USER_PROFILE_CATEGORY
2 as
3 select 654 id_category, 1103 id_user from dual union all
4 select 654 id_category, 1104 id_user from dual union all
5 select 18 id_category, 1103 id_user from dual union all
6 select 629 id_category, 1103 id_user from dual union all
7 select 110 id_category, 1103 id_user from dual union all
8 select 110 id_category, 1104 id_user from dual union all
9 select 18 id_category, 1104 id_user from dual union all
10 select 37 id_category, 1103 id_user from dual union all
11 select 24 id_category, 1103 id_user from dual union all
12 select 7 id_category, 104 id_user from dual union all
13 select 37 id_category, 1104 id_user from dual union all
14 select 22 id_category, 1103 id_user from dual union all
15 select 22 id_category, 1104 id_user from dual union all
16 select 25 id_category, 1104 id_user from dual union all
17 select 25 id_category, 1103 id_user from dual ;
Table created.
SQL>
SQL> alter table TBL_USER_PROFILE_CATEGORY add primary key (id_category, id_use
Table altered.
SQL>
SQL> CREATE OR REPLACE
2 PROCEDURE P$UPDATE_TBL_USER_PROFILE_CAT(p_id_cat_old IN NUMBER) AS
3 p_id_category number;
4 p_id_user number;
5 cursor mycur is select id_category, id_user
6 from TBL_USER_PROFILE_CATEGORY
7 where id_category = p_id_cat_old
8 for update of id_category;
9 BEGIN
10 open mycur;
11 LOOP
12 FETCH mycur INTO p_id_category, p_id_user;
13 EXIT WHEN mycur%NOTFOUND;
14 BEGIN
15 DELETE FROM TBL_USER_PROFILE_CATEGORY
16 WHERE CURRENT OF mycur;
17 END;
18 END LOOP;
19 CLOSE mycur;
20 COMMIT;
21 EXCEPTION WHEN OTHERS THEN rollback;
22 END;
23 /
Procedure created.
SQL>
SQL> exec P$UPDATE_TBL_USER_PROFILE_CAT(654)
PL/SQL procedure successfully completed.
SQL> select * from TBL_USER_PROFILE_CATEGORY;
ID_CATEGORY ID_USER
18 1103
629 1103
110 1103
110 1104
18 1104
37 1103
24 1103
7 104
37 1104
22 1103
22 1104
25 1104
25 1103
13 rows selected.
SQL> Please, paste here what's your code...
Nicolas. -
Accessing Secured Web Services fromPL/SQL Code.
Hi ,
This is an urgent requirement.We need to call a Web Sercured which is secured(That we need Authenticate using Digital Signatures).I don't how to call a Secured web service from PL/SQL code.with java it is possible.
Can anyone help me in confoguring/Writing code to call web services with Digital Certificates.
Regards,
RamIn the XmlDigester class you would have to change the following 2 functions...
public int Compare(Object x, Object y)
XmlAttribute lhs = (XmlAttribute)x;
XmlAttribute rhs = (XmlAttribute)y;
string ls = lhs.NamespaceURI;
string rs = rhs.NamespaceURI;
if ((ls == rs) || (ls.Equals(rs) && ls != null && rs != null))
ls = lhs.LocalName;
rs = rhs.LocalName;
if (ls == null)
return -1;
if (rs == null)
return 1;
byte[] larr = Encoding.UTF8.GetBytes(ls);
byte[] rarr = Encoding.UTF8.GetBytes(rs);
int len = Math.Min(larr.Length, rarr.Length);
for (int i = 0; i < len; i++)
int li = (int)(larr[i] & 0xFF);
int ri = (int)(rarr[i] & 0xFF);
int d = li - ri;
if (d != 0)
return d;
return larr.Length - rarr.Length;
private void Serialize(string s, Stream outStream)
byte[] bytes = Encoding.UTF8.GetBytes(s);
int len = bytes.Length;
Serialize((byte)(len >> 8), outStream);
Serialize((byte)(len), outStream);
Serialize(bytes, outStream);
That should do the trick. -
Calling a Java Function from PL/SQL
Hi,
I would like to call a Java API from a java class residing on the middle tier ($OA_JAVA)
from the subscription code of a business event. The business event will have a
subscription with java rule function as my Java API. And the business event will be
raised from PL/SQL code using WF_EVENT.RAISE API. I want the Java API to
executed SYNCHRONOUSLY without deferring the event. Can you please provide
pointers to this.
Regards
RameshDocumentation here: http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref185
says JPublisher can publish records too.
But when I change the example given at http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref190 as following:
PACKAGE "COMPANY" AS
type emp_rec is record (empno number, ename varchar2(10));
type emp_list is varray(5) of emp_rec;
type factory is record (
name varchar(10),
emps emp_list
function get_factory(p_name varchar) return factory;
END;
then I see <unknown type or type not found> at sql or java files generated. Any ideas?
Maybe you are looking for
-
Lenovo System update 5.1 won't install on windows 8
My sytstem update worked for a few weeks in windows 8 and then it stopped loading. I tried to do an uninstall and reinstall but unfortunately I get the following message "the wizard was interrupted before lenovo system update could be completely ins
-
Why is it that when I am trying to install an adobe product, I get 33% of the way through and then it gives me an error "unable to load metafile"?? It happened with Reader and now with Flash player. With the Reader, I was able to find a different i
-
How can I tell if my computer orweb surfing is being monitored?
How can I tell if my computer orweb surfing is being monitored? just got Apple Remote Desktop 3 at the office and want to know if Big Brother is watching me....how can I know?
-
From iPhone 4 to iPhone 6 , how ?
I Have a new iPhone 6 , Replacing my iPhone 4. should I make full restore or restore from iPhone 4 backup ? As the new iPhone is a different product and not the same iOS version ? Thanks PS. I've made a restore from iPhone 4 but I can make a new rest
-
Can i connect skybox to my 2012 27" iMac
I have a late 2012 27" imac and was wondering can i connect my xbox one or sky box to my imac I have a a cable that connects to thunderbolt and has hdmi input at other end. but can i use this an an input rather than an output. any help would be grate