Drop Directory...
I dropped a directory, but i can´t delete the folder from file system. Is says it is being used. What´s wrong?
What's wrong? Perhaps you can explain to us what about your question relates to the following:
1. Oracle
2. SQL
3. PL/SQL
and then someone can help you.
Similar Messages
-
Oracle 10g enterprise manager create directory
Hi,
I am new to using Oracle 10g on Linux and struggle with creating a new directory using the Enterprise Manager "wizard".
I go to Database Instance > Directory Objects > Create Directory objects
and try it with \home\oracle , then test the file system it says directory not available.
pressing OK and continueing with my data dump does not work because I get the error "The directory does not exist"
I wonder why it has not been created?
moreover how do I delete the directory objects. I cant find a delete button using the enterprise manager browser ui ?
Edited by: metalray on 10-Jul-2009 09:12metalray wrote:
Hi EdStevens,
thanks for your reply.
I have heard this "read a book" a thousand times and gues what. I am
reading a book and this is exercise 9.2 and it tells me (as part
of the ultimate learning path) to use the enterprise manager
after I have created the directory with sqlplus.
I also tried the intuitiv DROP DIRECTORY in sqlplus as well but...
the directory does apparently not exist (altough I can see it clearly there in the list).That could be an ownership issue. Who does the directory belong to? who are you logged on as?
>
>
>
Hence I came to the conlusion to create a directory using the good old enterprise manager and it did not work too well either.
whatever I type in there I get file system does not exist. I guess I do something wrong with the PATH written into the textbox right?
[directory creation does not work|http://metalray.redio.de/dokumente/linux01.jpg]
Who are you connecting as when you log on to OEM? Try logging on with sysdba authority and you should see some more options available on the directory management page.
>
>
@DMBS direct
what I cant see is a delete button....
[no delete button|http://metalray.redio.de/dokumente/linux02.jpg] -
Hi,
I have a doubt..
I'm trying to create an Oracle directory:
CREATE OR REPLACE DIRECTORY
PROTPL[b]-RP[b]-01_TPL_DB AS
'/utl_db/skedul/protpl-rp-01';
But I get an error:
Message Code ORA-00905 was not found. Please verify and re-enter.
Instead using a different name, witout char '-' , I have no problem.
Is char '-' not legal for the name of Oracle directory?
Thanks a lotIs char '-' not legal for the name of Oracle directory?As in all oracle object name, until you use double-quote :
SQL> CREATE OR REPLACE DIRECTORY
2 PROTPL-RP-01_TPL_DB AS
3 '/utl_db/skedul/protpl-rp-01';
PROTPL-RP-01_TPL_DB AS
ERROR at line 2:
ORA-00905: missing keyword
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE DIRECTORY
2 "PROTPL-RP-01_TPL_DB" AS
3* '/utl_db/skedul/protpl-rp-01'
SQL> /
Directory created.
SQL> But in this case, you will need to use double-quote on each call of this object :
SQL> drop directory PROTPL-RP-01_TPL_DB;
drop directory PROTPL-RP-01_TPL_DB
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> ed
Wrote file afiedt.buf
1* drop directory "PROTPL-RP-01_TPL_DB"
SQL> /
Directory dropped.
SQL> Nicolas. -
Hi,
I created some of the directories sometime back which are not used thesedays. I like to delete some particular directories. When I tried to delete using delete statement I am getting INSUFFICIENT PRIVILEGES error message.
Can anyone help me in getting out unused directory objects.The statement is not DELETE but DROP DIRECTORY
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_812a.htm#2066782 -
Upgrade 11.1.1.5 to 11.1.1.6 Linux X86 64
Hi,
Just upgraded from 11.1.1.5 to 11.1.1.6. Here you have my detailed upgrade procedure based on links below. Hope it will help some of you.
Guides:
http://www.oracle.com/technetwork/middleware/bi-enterprise-edition/downloads
http://docs.oracle.com/cd/E23943_01/bi.1111/e16452/bi_plan.htm#BABECJJH
http://docs.oracle.com/cd/E16764_01/doc.1111/e14495/install_screens.htm
http://gerardnico.com/wiki/dat/obiee/patch_11g_111160 (it's about windows installation but still helpful)
1) Check prerequisites
Check your web logic version (need to be 10.3.5 or 10.3.6) -> In the WebLogic console, in the left navigation tree, click on "Environment", then "Servers". Then click on one of the servers in the list. Then click on the "Monitoring" tab. Look at the "WebLogic Version" field.
If you like, check detailed requirements:
http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_installer.htm#BGBBHDJA
http://docs.oracle.com/html/E18558_01/fusion_requirements.htm
2) Stop services
Stop OBIEE services OMPN: /mnt/data/obi11g/instances/instance1/bin/opmnctl stopall
Stop Weblogic: /mnt/data/obi11g/user_projects/domains/bifoundation_domain/bin/stopWebLogic.sh
Confirm that weblogic is not running: ps aux | grep java
3) use putty with XMING (if you run inslallation remotely)
download from: http://sourceforge.net/projects/xming/
guide: http://qiu.bioweb.hunter.cuny.edu/index.php?option=com_content&view=article&id=110
Maybe you will need to install "/usr/bin/xdpyinfo" to make it work
4) start installer
Run installer with oracle account (Anyway installer script won't let you run it from root account).
/mnt/data/OBI_11116_installer_unp/bishiphome/Disk1/runInstaller
-> Skip software updates
-> Next
-> Software Install only
-> Next
5) make all prerequisites passed / sometimes warnings are accepted
In our case:
A) to pass "check operating system certification" needed to change "/etc/oracle-release" from “Oracle 6.1” to just “6” (so it match one of allowed versions)
B) to pass "checking recommended operating system packages" -> needed to install several packages (it's more convinient to use prerequisite log than read packages names from installer window, in our case log was located in: /tmp/OraInstall2012-03-06_02-43-06PM/prereq/linux64/ias_prereq_results.xml)
C) Even after installing all packages prerequisites check didn't pass for 2 of them, so finally "checking recommended operating system packages" got warning, however we were sure that packages are in place in system
6) Provide Oracle Middleware home and Oracle Home Directory
How to find it out: http://docs.oracle.com/cd/E11857_01/install.111/e16847/preparing_for_install.htm#BACIGBGF
In our case:
Middleware Home: /mnt/data/obi11g
BI Oracle Home: Oracle_BI1
7) Finish instalation
After installation is finishes close installer.
In our case with no issues and it took about 15 minutes.
8) Check schemas
see http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_assistant.htm#BABHFEGH
In our case database is located on separate server, so needed to connect to it from my local windows machine with PL-SQL developer as "sys" user and verify if 2 expected schemas are in place with version 11.1.1.5
SELECT t.* FROM SCHEMA_VERSION_REGISTRY t;
9) Update Schemas with Patch Set Assistant
Connect to server with putty with Xming (as when starting installation)
Run patch set assistant separately for each of 2 schemas: /mnt/data/obi11g/Oracle_BI1/bin/psa
xxx_MDS (The prefix_MDS schema must be updated first, in fact installer won't let you do it in wrong order)
xxx_BIPLATFORM
Both times tyou need to check prerequisites check boxes: "Database backup completed" and "Database version is certified...".
You need to provide connection string. As mentioned in my case it was different IP than OBI server itself.
As given in installer example DBA User name: "sys as sysdba"
Then provide your schema user and password (e.g. schema password for sample oracle installation is "Admin123")
10) validate patch set installation
again connect as "sys" user and run query: SELECT t.* FROM SCHEMA_VERSION_REGISTRY t;
for both xxx_BIPLATFORM and xxx_MDS you get "11.1.1.6" ... "VALID"
11) Upgrading System Components
http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_installer.htm#PATCH250
http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_installer.htm#CBHJHJCF
A) start administration service:
nohup /mnt/data/obi11g/user_projects/domains/bifoundation_domain/bin/startWebLogic.sh
B) check if there are no issues in : /home/obi/nohup.out
C) set oracle home / confirm that it is set
export ORACLE_HOME=/mnt/data/obi11g/Oracle_BI1
env | grep ORACLE_HOME
D) start obiee services
/mnt/data/obi11g/instances/instance1/bin/opmnctl startall
E) verify that obiee services are alive
/mnt/data/obi11g/instances/instance1/bin/opmnctl status -l
F) run upgrade
http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_installer.htm#PATCH250
http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_installer.htm#CBHJHJCF
/mnt/data/obi11g/Oracle_BI1/opmn/bin/upgradenonj2eeapp.sh
-oracleInstance /mnt/data/obi11g/instances/instance1 -adminHost localhost -adminPort 7001 -adminUsername xxx
in default oracle installation xxx = "weblogic", you will need to provide password few times during install.
12) Updating Fusion Middleware Shared Libraries
http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_installer.htm#PATCH685
A) Stop all running instances, Managed Servers, Administration Server, and Node Manager in the domain.
/mnt/data/obi11g/instances/instance1/bin/opmnctl stopall
/mnt/data/obi11g/user_projects/domains/bifoundation_domain/bin/stopWebLogic.sh
B) confirm that weblogic is not running
ps aux | grep java
C) run WLST
/mnt/data/obi11g/oracle_common/common/bin/wlst.sh
wlst> upgradeJRF("/mnt/data/obi11g/user_projects/domains/bifoundation_domain")
In our case we got "skip, JRF is up-to-date"
13) Updating Configurations and Stores
http://docs.oracle.com/cd/E23943_01/doc.1111/e16793/patch_set_installer.htm#PATCH721
A) Start weblogic and opmnctl
B) run WLST
/mnt/data/obi11g/oracle_common/common/bin/wlst.sh
wlst> upgradeOpss(jpsConfig=”/mnt/data/obi11g/user_projects/domains/bifoundation_domain/config/fmwconfig/jps-config.xml”, jaznData="/mnt/data/obi11g/oracle_common/modules/oracle.jps_11.1.1/domain_config/system-jazn-data.xml")
14) "Updating Oracle Business Intelligence Code Grants" & "Updating Oracle Business Intelligence Catalogs"
Boths this steps can be skipped for 11.1.1.5 to 11.1.1.6 upgrade, as I understood from Oracle upgrade guide.
15) Reinstall windows client "biee_client_install.exe"
A) uninstall previous version (in my case 11.1.1.4)
B) download and install "Oracle Business Intelligence Developer Client Tools Installer (11.1.1.6.0)"
First glance issues after installation (to be investigated next days...):
- does not work at all with my chrome browser
- issue with existing dashboard prompts (list of available values is not displayed combo box, however can use "search" to pick it from list)
- some of existing navigation links stopped to work
Regards,Hi,
rafaelfm wrote:
If I got it right, you suggest using the Method proposed on the first message, without Data Guard.
I too would prefer not to touch production database until I test all the procedure. I would just run the pre-upgrade in production and use production backups during the tests phase.The guys here gave great suggestions but I'd do in a different way.
1) Execute pre-upgrades scripts and checks
2) Backup current database with RMAN and make backup files available to the new host
3) Install Grid Infrastcure 11.2.0.2 on new cluster
4) Configure ASM on new Cluster
5) Install Oracle Database RAC 11.2.0.2 on new cluster
6) Create the RAC Database (using DBCA) with the same DBNAME of the original database. (this save a lot work)
7) Create the Database Services (if exists)
8) Shutdown Database / Remove Database (only files controlfile/datafiles/redo) - Easy way is drop directory on ASM. Leave configuration of Network/OCR in place.
9) Create a new PFILE from production SPFILE. Change parameter of SPFILE of new RAC using PFILE.
10) RESTORE CONTROLFILE AND DATABASE
11) RECOVER DATABASE and execute 'ALTER DATABASE OPEN RESETLOG' the error ORA-39700 will be raised and database will shutdown leave database down.
12) Using DBUA perfom UPGRADE to 11.2.0.2.
13) remove extra undo tablespaces e redo log threads
You also suggest to use DBUA. Is it possible to use DBUA when you are restoring the database to the other cluster where the new version is installed?Yes.. You must perform recover and open resetlogs database, the error (ORA-39700: database must be opened with UPGRADE option) will be raised and database will shutdown, leave database down and perform upgrade using DBUA.
Regards,
Levi Pereira
Edited by: Levi Pereira on May 20, 2011 11:59 PM -
Unable to find line break between two lines in attachment file.
Dear all I will be very great full if someone help me out,
I am trying to send mail through SMTP server with an attachment of oracle report, but I am unable to find line break between two lines, when I down load the attachment from mail and open attach.txt file by double click on it. Next line starts right after previous line ends, it should starts with new line.
In order to send an attachment file, I am reading source file line by line and put MIME protocol’s attachment instance, contain of source file is being properly written into target file if I open that attachment on cmd prompt.
Following code may help you to understand the case.
Thanks in advance.
My code is as follows:-
create or replace procedure bec_file_test
v_subject varchar2, -- Subject of the email
v_body varchar2, -- Body of the email
v_from VARCHAR2 default 'XYZ.com', -- sender mail id
v_to varchar2 default 'XYZ.com', -- Field To of the email
v_cc varchar2 default 'XYZ.com' -- cc address
) is
-- variable to hold the smtp server connection
v_smtp_connection utl_smtp.connection;
-- variable to hold the smtp host name
v_smtp_host varchar2(100) default 'mail.bec-group.com';
-- variable to hold the smtp port
v_smtp_port number default 25;
-- composite of {CR}{LF} caridge return and line feed.
CRLF varchar2(2):=CHR(13)||CHR(10);
cursor pr_rec is
select requisition_no,line_no,release_no,a.contract,
a.project_id,substr(a.activity_seq,1,11)ACT_SEQ,
substr(a.part_no,1,12)PART_NO,
substr(a.description,1,32)DESCRIPTION,
substr(a.Bal_qty,1,8) BAL_QTY,
substr(a.unit_meas,1,5)UOM,
a.wanted_receipt_date WAN_REC_DT,
a.latest_order_date LAT_ORD_DT
from bec_pr_line_rep a
where a.Bal_qty>0 and a.header_state not in 'Closed'
and upper(a.state1) like 'RELEASED' and a.contract not in ('U1ENG','ULENG','U1FND','U2FND')
and a.buyer_code='70306'
order by a.part_no;
begin
declare
fHandle UTL_FILE.FILE_TYPE;
v_msg_line varchar2(2000);
-- v_buffer varchar2(20000);
--ALTER SYSTEM SET utl_file_dir = 'D:\Database\temp'
--COMMENT='Temporary change on Dec 14'
--SCOPE=SPFILE;
SELECT name, value
FROM gv$parameter
WHERE name = 'utl_file_dir';
--drop directory my_directory
--CREATE or replace DIRECTORY my_directory AS 'D:\database\temp';
--GRANT read,write ON DIRECTORY my_directory TO PUBLIC;
begin ---writing data into a file.
fHandle := UTL_FILE.FOPEN('MY_DIRECTORY', 'pending_pr_summry.txt', 'w');
UTL_FILE.put_line(fHandle, ' Pending PR to process (detail report)');
UTL_FILE.put_line(fHandle,TO_CHAR(SYSDATE,'MM-DD-YY HH:MI:SS AM'));
UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
UTL_FILE.put_line(fHandle, 'Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt' );
UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
for pr_temp in pr_rec loop
begin
v_msg_line:=to_char(rpad(pr_temp.requisition_no,12,' ')||'|'||
lpad(pr_temp.line_no,3,' ')||'|'||
lpad(pr_temp.release_no,3,' ')||'|'||
rpad(pr_temp.contract,7,' ')||'|'||
lpad(nvl(pr_temp.project_id,' '),7,' ')||'|'||
lpad(nvl(pr_temp.act_seq,' '),12,' ')||'|'||
lpad(pr_temp.part_no,12,' ')||'|'||
rpad(pr_temp.description,35,' ')||'|'||
lpad(pr_temp.bal_qty,10,' ')||'|'||
rpad(pr_temp.uom,6,' ')||'|'||
lpad(pr_temp.wan_rec_dt,14,' ')||'|'||
lpad(pr_temp.lat_ord_dt,14,' '));
UTL_FILE.put_line(fHandle,v_msg_line);
end;
end loop;
UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
UTL_FILE.put_line(fHandle, ' Regards : IFSAPP ( Application owner ) ');
UTL_FILE.FCLOSE(fHandle); ------------writing into file is successfuly done here!
--Reading of file starts here containt will be added in attchment file
fHandle :=UTL_FILE.FOPEN('MY_DIRECTORY','pending_pr_summry.txt','R' );
-- establish the connection to the smtp server
v_smtp_connection := utl_smtp.open_connection(v_smtp_host, v_smtp_port); /** OPEN CONNECTION ON THE SERVER **/
-- perform a handshake with the smtp server
utl_smtp.helo(v_smtp_connection, v_smtp_host); /** DO THE INITIAL HAND SHAKE **/
-- set the 'from' address of the message
utl_smtp.mail(v_smtp_connection, v_from);
-- add the recipient to the message
utl_smtp.rcpt(v_smtp_connection, v_to);
-- send the email
utl_smtp.open_data(v_smtp_connection);
v_msg_line:='Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || CRLF ||
'From: ' || v_from || CRLF ||
'Subject: ' || v_subject || CRLF ||
'To: ' || v_to || CRLF ||
'Cc: ' || v_cc || CRLF ||
'MIME-Version: 1.0'|| CRLF || -- Use MIME mail standard
'Content-Type: multipart/mixed;'||CRLF ||
' boundary="-----SECBOUND"'||CRLF||
CRLF ||'-------SECBOUND'|| CRLF ||
'Content-Type: text/plain;'|| CRLF ||
'Content-Transfer_Encoding: 7bit'|| CRLF ||
CRLF ||v_body|| CRLF; -- Message body
utl_smtp.write_data(v_smtp_connection,v_msg_line);
v_msg_line:='-------SECBOUND'|| CRLF ||
'Content-Type: application/octet-stream;'|| CRLF ||
'Content-Type: text/plain;'|| CRLF ||
'name="pending_pr_summry.txt"'|| CRLF ||
'Content-Transfer_Encoding: 8bit'|| CRLF ||
'Content-Disposition: attachment;'|| CRLF ||
' filename="pending_pr_summry.txt"'|| CRLF || CRLF; -- Content of attachment
utl_smtp.write_data(v_smtp_connection,v_msg_line);
-- check file is opened
IF utl_file.is_open(fHandle) THEN
-- loop lines in the file
LOOP
BEGIN -- Content of attachment
utl_file.get_line(fHandle,v_msg_line);
v_msg_line:=concat(v_msg_line,CRLF);
utl_smtp.write_data(v_smtp_connection,v_msg_line);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
END IF;
--end of attachment containt
utl_smtp.write_data(v_smtp_connection,v_msg_line);
UTL_FILE.FCLOSE(fHandle);
utl_smtp.close_data(v_smtp_connection);
utl_smtp.quit(v_smtp_connection);
exception
when utl_smtp.invalid_operation then
dbms_output.put_line(' Invalid Operation in Mail attempt using UTL_SMTP.');
when utl_smtp.transient_error then
dbms_output.put_line(' Temporary e-mail issue - try again');
when utl_smtp.permanent_error then
dbms_output.put_line(' Permanent Error Encountered.');
when others then
dbms_output.put_line('Exception: SQLCODE=' || SQLCODE || ' SQLERRM=' || SQLERRM);
RAISE;
end;
end bec_file_test;Pending PR to process (detail report)01-17-13 12:43:19 PM--------------------------------------------------------------------------------------------------------------------------------------------------Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt--------------------------------------------------------------------------------------------------------------------------------------------------MAT/250370 | 2| 1|ISCSP | 4977| 100004207| 0104000016|Angle 50 X 50 X 6 IS:2062 Grade |500|kg |30-NOV-2012| 20-nov-2012MAT/250370 | 3| 1|ISCSP | 4977| 100004207| 0105000002|Channel 100 X 50 IS:2062 Grade A | 1000|kg | 30-NOV-2012| 20-nov-2012MAT/250579 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 2991|kg | 13-DEC-2012| 03-dec-2012MAT/250606 | 2| |NMDCJ | 6002| 100005860| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | |1|NMDCJ|6001|100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 1500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 3| 1|NMDCJ | 6002| 100005818| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 3939|kg | 29-DEC-2012| 19-dec-2012MAT/250606 | 4| 1|NMDCJ | 6002| 100005860| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 39000|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 4| 1|NMDCJ | 6001| 100005580| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 2| 1|NMDCJ | 6002| 100005818| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 12183|kg | 29-DEC-2012| 19-dec-2012MAT/250606 | 6| 1|NMDCJ | 6002| 100005860| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 9500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 6| 1|NMDCJ | 6001| 100005580| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 6| 1|NMDCJ | 6002| 100005818| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 7| 1|NMDCJ | 6001| 100005580| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 22000|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 7| 1|NMDCJ | 6002| 100005818| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 27060|kg | 29-DEC-2012| 19-dec-2012MAT/251138 | 1| 1|NMDCJ | 6002| 100005825| 3501000001|Cement 50 kg | 1|pkt | 25-DEC-2013| 14-dec-2013--------------------------------------------------------------------------------------------------------------------------------------------------
where as source file is like that:-
Pending PR to process (detail report)
01-17-13 12:43:19 PM
Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt
MAT/250370 | 2| 1|ISCSP | 4977| 100004207| 0104000016|Angle 50 X 50 X 6 IS:2062 Grade | 5500|kg | 30-NOV-2012| 20-nov-2012
MAT/250370 | 3| 1|ISCSP | 4977| 100004207| 0105000002|Channel 100 X 50 IS:2062 Grade A | 1000|kg | 30-NOV-2012| 20-nov-2012
MAT/250579 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 2991|kg | 13-DEC-2012| 03-dec-2012
MAT/250606 | 2| 1|NMDCJ | 6002| 100005860| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012
MAT/250607 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 1500|kg | 29-DEC-2012| 19-dec-2012
MAT/250194 | 3| 1|NMDCJ | 6002| 100005818| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 3939|kg | 29-DEC-2012| 19-dec-2012
MAT/250606 | 4| 1|NMDCJ | 6002| 100005860| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 39000|kg | 29-DEC-2012| 19-dec-2012
MAT/250607 | 4| 1|NMDCJ | 6001| 100005580| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012
MAT/250194 | 2| 1|NMDCJ | 6002| 100005818| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 12183|kg | 29-DEC-2012| 19-dec-2012
MAT/250606 | 6| 1|NMDCJ | 6002| 100005860| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 9500|kg | 29-DEC-2012| 19-dec-2012
MAT/250607 | 6| 1|NMDCJ | 6001| 100005580| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012
MAT/250194 | 6| 1|NMDCJ | 6002| 100005818| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012
MAT/250607 | 7| 1|NMDCJ | 6001| 100005580| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 22000|kg | 29-DEC-2012| 19-dec-2012
MAT/250194 | 7| 1|NMDCJ | 6002| 100005818| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 27060|kg | 29-DEC-2012| 19-dec-2012
MAT/251138 | 1| 1|NMDCJ | 6002| 100005825| 3501000001|Cement 50 kg | 1 |pkt | 25-DEC-2013| 14-dec-2013
Ignore alignment. It is well formatted in source file. -
Error compiling procedure send mail
Hi all,
I have this error message (on 10.2 version)
Table or view doesn't exist
At this line
+ select dd.directory_name into directory_name from dba_directories dd+
+ where dd.directory_path = line and rownum = 1;+
But I don't know how can resolve it.
This is the all procedure
[http://forums.oracle.com/forums/]
CREATE OR REPLACE PROCEDURE P_SPEDEMAIATTA ( from_name IN VARCHAR2,
to_names IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2 default null,
html_message IN VARCHAR2 default null,
cc_names IN VARCHAR2 default null,
bcc_names IN VARCHAR2 default null,
filename1 varchar2 default null,
filetype1 varchar2 default 'text/plain',
filename2 varchar2 default null,
filetype2 varchar2 default 'text/plain',
filename3 varchar2 default null,
filetype3 varchar2 default 'text/plain',
V_CODIERRO OUT VARCHAR2,
V_DESCERRO OUT VARCHAR2)
is
-- Change the SMTP host name and port number below to your own values,
-- if not localhost on port 25:
smtp_host varchar2(256) := 'SMTP.INET.IT';
smtp_port number := 25;
-- Change the boundary string, if needed, which demarcates boundaries of
-- parts in a multi-part email, and should not appear inside the body of
-- any part of the e-mail:
boundary constant varchar2(256) := 'CES.Boundary.DACA587499938898';
recipients varchar2(32767);
directory_path varchar2(256);
file_name varchar2(256);
crlf varchar2(2):= chr(13) || chr(10);
mesg varchar2(32767);
conn UTL_SMTP.CONNECTION;
type varchar2_table is table of varchar2(256) index by binary_integer;
file_array varchar2_table;
type_array varchar2_table;
i binary_integer;
my_code number;
my_errm varchar2(32767);
-- Function to return the next email address in the list of email addresses,
-- separated by either a "," or a ";". From Oracle's demo_mail. The format
-- of mailbox may be in one of these:
-- someone@some-domain
-- "Someone at some domain" <someone@some-domain>
-- Someone at some domain <someone@some-domain>
FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
addr VARCHAR2(256);
i pls_integer;
FUNCTION lookup_unquoted_char(str IN VARCHAR2,
chrs IN VARCHAR2) RETURN pls_integer IS
c VARCHAR2(5);
i pls_integer;
len pls_integer;
inside_quote BOOLEAN;
BEGIN
inside_quote := false;
i := 1;
len := length(str);
WHILE (i <= len) LOOP
c := substr(str, i, 1);
IF (inside_quote) THEN
IF (c = '"') THEN
inside_quote := false;
ELSIF (c = '\') THEN
i := i + 1; -- Skip the quote character
END IF;
GOTO next_char;
END IF;
IF (c = '"') THEN
inside_quote := true;
GOTO next_char;
END IF;
IF (instr(chrs, c) >= 1) THEN
RETURN i;
END IF;
<<next_char>>
i := i + 1;
END LOOP;
RETURN 0;
END;
BEGIN
addr_list := ltrim(addr_list);
i := lookup_unquoted_char(addr_list, ',;');
IF (i >= 1) THEN
addr := substr(addr_list, 1, i - 1);
addr_list := substr(addr_list, i + 1);
ELSE
addr := addr_list;
addr_list := '';
END IF;
i := lookup_unquoted_char(addr, '<'>');
IF (i >= 1) THEN
addr := substr(addr, 1, i - 1);
END IF;
END IF;
i := lookup_unquoted_char(addr, '@');
IF (i = 0 and smtp_host != 'localhost') THEN
i := instr(smtp_host, '.', -1, 2);
addr := addr || '@' || substr(smtp_host, i + 1);
END IF;
addr := '<'>';
RETURN addr;
END;
-- Procedure to split a file pathname into its directory path and file name
-- components.
PROCEDURE split_path_name(file_path IN VARCHAR2, directory_path OUT VARCHAR2,
file_name OUT VARCHAR2) IS
pos number;
begin
-- Separate the filename from the directory name
pos := instr(file_path,'/',-1);
if pos = 0 then
pos := instr(file_path,'\',-1);
end if;
if pos = 0 then
directory_path := null;
else
directory_path := substr(file_path,1,pos - 1);
end if;
file_name := substr(file_path,pos + 1);
end;
-- Procedure to append a file's contents to the e-mail
PROCEDURE append_file(directory_path IN VARCHAR2, file_name IN VARCHAR2,
file_type IN VARCHAR2, conn IN OUT UTL_SMTP.CONNECTION) IS
generated_name varchar2(30) := 'CESDIR' || to_char(sysdate,'HH24MISS');
directory_name varchar2(30);
file_handle utl_file.file_type;
bfile_handle bfile;
bfile_len number;
pos number;
read_bytes number;
line varchar2(1000);
data raw(200);
my_code number;
my_errm varchar2(32767);
begin
begin
-- Grant access to the directory, unless already defined, and open
-- the file (as a bfile for a binary file, otherwise as a text file).
begin
line := directory_path;
select dd.directory_name into directory_name from dba_directories dd
where dd.directory_path = line and rownum = 1;
exception
when no_data_found then
directory_name := generated_name;
end;
if directory_name = generated_name then
execute immediate 'create or replace directory ' || directory_name ||
' as ''' || directory_path || '''';
execute immediate 'grant read on directory ' || directory_name ||
' to public';
end if;
if substr(file_type,1,4) != 'text' then
bfile_handle := bfilename(directory_name,file_name);
bfile_len := dbms_lob.getlength(bfile_handle);
pos := 1;
dbms_lob.open(bfile_handle,dbms_lob.lob_readonly);
else
file_handle := utl_file.fopen(directory_name,file_name,'r');
end if;
-- Append the file contents to the end of the message
loop
-- If it is a binary file, process it 57 bytes at a time,
-- reading them in with a LOB read, encoding them in BASE64,
-- and writing out the encoded binary string as raw data
if substr(file_type,1,4) != 'text' then
if pos + 57 - 1 > bfile_len then
read_bytes := bfile_len - pos + 1;
else
read_bytes := 57;
end if;
dbms_lob.read(bfile_handle,read_bytes,pos,data);
utl_smtp.write_raw_data(conn,utl_encode.base64_encode(data));
pos := pos + 57;
if pos > bfile_len then
exit;
end if;
-- If it is a text file, get the next line of text, append a
-- carriage return / line feed to it, and write it out
else
utl_file.get_line(file_handle,line);
utl_smtp.write_data(conn,line || crlf);
end if;
end loop;
-- Output any errors, except at end when no more data is found
exception
when no_data_found then
null;
when others then
my_code := SQLCODE;
my_errm := SQLERRM;
dbms_output.put_line('Error code ' || my_code || ': ' ||
my_errm);
end;
-- Close the file (binary or text)
if substr(file_type,1,4) != 'text' then
dbms_lob.close(bfile_handle);
else
utl_file.fclose(file_handle);
end if;
if directory_name = generated_name then
execute immediate 'drop directory ' || directory_name;
end if;
end;
begin
-- Load the three filenames and file (mime) types into an array for
-- easier handling later
file_array(1) := filename1;
file_array(2) := filename2;
file_array(3) := filename3;
type_array(1) := filetype1;
type_array(2) := filetype2;
type_array(3) := filetype3;
-- Open the SMTP connection and set the From and To e-mail addresses
conn := utl_smtp.open_connection(smtp_host,smtp_port);
utl_smtp.helo(conn,smtp_host);
recipients := from_name;
utl_smtp.mail(conn,get_address(recipients));
recipients := to_names;
while recipients is not null loop
utl_smtp.rcpt(conn,get_address(recipients));
end loop;
recipients := cc_names;
while recipients is not null loop
utl_smtp.rcpt(conn,get_address(recipients));
end loop;
recipients := bcc_names;
while recipients is not null loop
utl_smtp.rcpt(conn,get_address(recipients));
end loop;
utl_smtp.open_data(conn);
-- Build the start of the mail message
mesg := 'Date: ' || TO_CHAR(SYSDATE,'dd Mon yy hh24:mi:ss') || crlf ||
'From: ' || from_name || crlf ||
'Subject: ' || subject || crlf ||
'To: ' || to_names || crlf;
if cc_names is not null then
mesg := mesg || 'Cc: ' || cc_names || crlf;
end if;
if bcc_names is not null then
mesg := mesg || 'Bcc: ' || bcc_names || crlf;
end if;
mesg := mesg || 'Mime-Version: 1.0' || crlf ||
'Content-Type: multipart/mixed; boundary="' || boundary || '"' ||
crlf || crlf ||
'This is a Mime message, which your current mail reader may not' || crlf ||
'understand. Parts of the message will appear as text. If the remainder' || crlf ||
'appears as random characters in the message body, instead of as' || crlf ||
'attachments, then you''ll have to extract these parts and decode them' || crlf ||
'manually.' || crlf || crlf;
utl_smtp.write_data(conn,mesg);
-- Write the text message or message file, if any
if message is not null then
mesg := '--' || boundary || crlf ||
'Content-Type: text/plain; name="message.txt"; charset=US-ASCII' ||
crlf ||
'Content-Disposition: inline; filename="message.txt"' || crlf ||
'Content-Transfer-Encoding: 7bit' || crlf || crlf;
utl_smtp.write_data(conn,mesg);
if instr(message,'/') = 1 or instr(message,':\') = 2 or
instr(message,'\\') = 1 then
split_path_name(message,directory_path,file_name);
append_file(directory_path,file_name,'text',conn);
utl_smtp.write_data(conn,crlf);
else
utl_smtp.write_data(conn,message || crlf);
end if;
end if;
-- Write the HTML message or message file, if any
if html_message is not null then
mesg := '--' || boundary || crlf ||
'Content-Type: text/html; name="message.html"; charset=US-ASCII' ||
crlf ||
'Content-Disposition: inline; filename="message.html"' || crlf ||
'Content-Transfer-Encoding: 7bit' || crlf || crlf;
utl_smtp.write_data(conn,mesg);
if instr(html_message,'/') = 1 or instr(html_message,':\') = 2 or
instr(html_message,'\\') = 1 then
split_path_name(html_message,directory_path,file_name);
append_file(directory_path,file_name,'text',conn);
utl_smtp.write_data(conn,crlf);
else
utl_smtp.write_data(conn,html_message || crlf);
end if;
end if;
-- Append the files
for i in 1..3 loop
-- If the filename has been supplied ...
if file_array(i) is not null then
split_path_name(file_array(i),directory_path,file_name);
-- Generate the MIME boundary line according to the file (mime) type
-- specified.
mesg := crlf || '--' || boundary || crlf;
if substr(type_array(i),1,4) != 'text' then
mesg := mesg || 'Content-Type: ' || type_array(i) ||
'; name="' || file_name || '"' || crlf ||
'Content-Disposition: attachment; filename="' ||
file_name || '"' || crlf ||
'Content-Transfer-Encoding: base64' || crlf || crlf ;
else
mesg := mesg || 'Content-Type: application/octet-stream; name="' ||
file_name || '"' || crlf ||
'Content-Disposition: attachment; filename="' ||
file_name || '"' || crlf ||
'Content-Transfer-Encoding: 7bit' || crlf || crlf ;
end if;
utl_smtp.write_data(conn,mesg);
-- Append the file contents to the end of the message
append_file(directory_path,file_name,type_array(i),conn);
utl_smtp.write_data(conn,crlf);
end if;
end loop;
-- Append the final boundary line
mesg := crlf || '--' || boundary || '--' || crlf;
utl_smtp.write_data(conn,mesg);
-- Close the SMTP connection
utl_smtp.close_data(conn);
utl_smtp.quit(conn);
exception
when utl_smtp.transient_error or utl_smtp.permanent_error then
my_code := SQLCODE;
my_errm := SQLERRM;
V_CODIERRO := SQLCODE;
V_DESCERRO := SQLERRM;
begin
utl_smtp.quit(conn);
exception
when utl_smtp.transient_error or utl_smtp.permanent_error then
null;
end;
-- raise_application_error(-20000,
-- 'Failed to send mail - SMTP server down or unavailable: Error code ' ||
-- my_code || ': ' || my_errm);
when others then
my_code := SQLCODE;
my_errm := SQLERRM;
V_CODIERRO := SQLCODE;
V_DESCERRO := SQLERRM;
raise_application_error(-20000,
'Failed to send mail: Error code ' || my_code || ': ' || my_errm);
end;
Edited by: mosquito70 on Jan 22, 2009 12:33 PMThank's,
but the problem is that I have the system user password but I haven't that of sys.
So, if I try to run the statment
grant select on dba_directories to myuser;
I have the this code error ORA-01031
How can resolve, without use all_directories?
Thank's
Bye -
How can i load a big xml data using sql loader into oracle
hi,
I have a large xml about 5M at c:\temp and interested to load it in an oracle table with the following structure:
emp
empno number(10),
ename varchar2(250),
sal number(15)i am new with xml database
Best Regards,hi,
when i am trying to follow the steps then getting following error:
any help will be greatly appreciated:
SELECT * FROM v$version;
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
DROP directory xmlstore;
Directory dropped.
my xml file:
< ?xml version="1.0" encoding="UTF-8"?>
<root>
<id>0</id>
<info>
<info_id>0</info_id>
<info_content>Text</info_content>
</info>
</root>
CREATE directory xmlstore11 AS 'c:\temp';
Directory created.
CREATE TABLE test
(xmldata xmltype);
TABLE created.
INSERT INTO test
VALUES
(XMLTYPE(bfilename('XMLSTORE11','info.xml'),NLS_CHARSET_ID('AL32UTF8')));
received error is as follow:
Error starting at line 24 in command:
INSERT INTO test
VALUES
(XMLTYPE(bfilename('XMLSTORE11','info.xml'),NLS_CHARSET_ID('AL32UTF8')))
Error report:
SQL Error: ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00231: invalid character 32 (' ') found in a Name or Nmtoken
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 295
ORA-06512: at line 1
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid. -
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. -
Add a unique constraint on binary XML table
How add a unique constraint of "brevet" field?
The following INSERT failed
SQL Error: ORA-19025: EXTRACTVALUE renvoie la valeur d'un seul noeud
19025. 00000 - "EXTRACTVALUE returns value of only one node"
If the ALTER is made after the INSERT is done, INSERT is valid but ALTER failed with the same error message!
/* copy the file compavions.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<compagnie>
<comp>AB</comp>
<flotte>
<avion immat="F-WTSS" capacite="90">
<typeAv>Concorde</typeAv>
</avion>
<avion immat="F-GFDR" capacite="145">
<typeAv>A320</typeAv>
</avion>
<avion immat="F-GTYA" capacite="150">
<typeAv>A320</typeAv>
</avion>
</flotte>
<nomComp>Air Blagnac</nomComp>
<pilotes>
<pilote>
<brevet>PL-1</brevet>
<nom>C. Sigaudes</nom>
</pilote>
<pilote>
<brevet>PL-2</brevet>
<nom>P. Filloux</nom>
</pilote>
</pilotes>
</compagnie>
in C:\...
--DROP DIRECTORY repxml;
--CREATE DIRECTORY repxml AS 'C:\...';
DROP TABLE pilote_binary_xml5;
CREATE TABLE pilote_binary_xml5 OF XMLType
XMLTYPE STORE AS BINARY XML
VIRTUAL COLUMNS
(col AS (EXTRACTVALUE(OBJECT_VALUE, '/compagnie/pilotes/pilote/brevet')));
ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);
INSERT INTO pilote_binary_xml5 VALUES (XMLType(BFILENAME ('REPXML','compavions.xml'), NLS_CHARSET_ID ('AL32UTF8')));
--ALTER TABLE pilote_binary_xml5 ADD CONSTRAINT brevet_unique UNIQUE (col);You could try something like
(extract(OBJECT_VALUE,compagnie/pilotes/pilote/brevet').getStringVal());
but this is probably unadvisable.
I suggest an alternative is for you to look at XMLINDEX so that you can bring the 'proper' XML functions into play like XMLTABLE etc. -
Installing Oracle Database Express Edition 11g on UBUNTU
Hello everyone,
I want to install Oracle Database Express Edition 11g on UBUNTU. I followed the steps from this link created by Dude:
https://forums.oracle.com/thread/2303639?start=0&tstart=0
My problem becomes when I type in from the terminal:
sudo /etc/init.d/oracle-xe configure
I followed the instructions there, agreeing t HTTP port 8080, port database listener 1521, specifying a password for my database account, and wanting Oracle Express to be started on boot. This is what I'm getting:
Starting Oracle Net Listener...touch: cannot touch `/var/lock/subsys/listener': No such file or directory
Done
Configuring database...
Database Configuration failed. Look into /u01/app/oracle/product/11.2.0/xe/config/log for details
I have no idea what this means, so I went into the log's location and I found 4 of them, so I clicked on each of them, and this is what I'm getting:
1. cloneDBCreation.log:
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
ORA-00845: MEMORY_TARGET not supported on this system
Create controlfile reuse set database "XE"
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
alter system enable restricted session
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
alter database "XE" open resetlogs
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
alter database rename global_name to "XE"
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
alter system switch logfile
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
alter system checkpoint
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
2. CloneRmanRestore.log
ORA-00845: MEMORY_TARGET not supported on this system
select TO_CHAR(systimestamp,'YYYYMMDD HH:MI:SS') from dual
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
declare
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
select TO_CHAR(systimestamp,'YYYYMMDD HH:MI:SS') from dual
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
3. postDBCreation.log
begin
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
File created.
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
ORA-00845: MEMORY_TARGET not supported on this system
select 'utl_recomp_begin: ' || to_char(sysdate, 'HH:MI:SS') from dual
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
BEGIN utl_recomp.recomp_serial(); END;
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
select 'utl_recomp_end: ' || to_char(sysdate, 'HH:MI:SS') from dual
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
4. postScripts.log
CREATE OR REPLACE LIBRARY dbms_sumadv_lib AS '/u01/app/oracle/product/11.2.0/xe/lib/libqsmashr.so';
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
BEGIN dbms_datapump_utl.replace_default_dir; END;
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
commit
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
create or replace directory XMLDIR as '/u01/app/oracle/product/11.2.0/xe/rdbms/xml'
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
DROP DIRECTORY ORACLE_OCM_CONFIG_DIR
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
DROP DIRECTORY ADMIN_DIR
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
DROP DIRECTORY WORK_DIR
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
BEGIN dbms_swrf_internal.cleanup_database(cleanup_local => FALSE); END;
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
commit
Can somebody that knows this, or has installed Oracle Express on Ubuntu, to please explain it to me what does it mean and why am I getting those errors. Please explain thoroughly as if I am an amateur person, IN DETAIL, STEP-BY-STEP. I want to run it and make it work! I heard that it encourages people to answer for points. I am open for your suggestions and experiences, as long as it's not 'use common sense', 'you're dumb', or an answer that is vaguely explained. Thank you for those that take the time to read it.
ec557fac-f825-4356-a220-1ec941ce7cd0Hi Pradeepcmst,
Thanks for your suggestion, but I found it sometimes misunderstanding on what he's trying to say - his instructions are not step-by-step and precise. Instead, I found this link that helped me a lot:
Installing Oracle 11gXE on Mint and Ubuntu | The Anti-Kyte -
Using Oracle Text to search through WORD, EXCEL and PDF documents
Hello again,
What I would like to know is if I have a WORD or PDF document stored in a table. Is it possible to use Oracle Text to search through the actual WORD or PDF document?
Thanks
DougYes you can do context sensitive searches on both PDF and Word docs. With the PDF you need to make sure they are text and not images. Some scanners will create PDFs that are nothing more than images of document.
Below is code sample that I made some time back to demonstrate the searching capabilities of Oracle Text. Note that the example makes use of the inso_filter that is no longer shipped with Oracle begging with Patch set 10.1.0.4. See metalink note 298017.1 for the changes. See the following link for more information on developing with Oracle Text.
http://download-west.oracle.com/docs/cd/B14117_01/text.101/b10729/toc.htm
begin example.
-- The following needs to be executed
-- as sys.
DROP DIRECTORY docs_dir;
CREATE OR REPLACE DIRECTORY docs_dir
AS 'C:\sql\oracle_text\documents';
GRANT READ ON DIRECTORY docs_dir TO text;
-- End sys ran SQL
DROP TABLE db_docs CASCADE CONSTRAINTS PURGE;
CREATE TABLE db_docs (
id NUMBER,
format VARCHAR2(10),
location VARCHAR2(50),
document BLOB,
CONSTRAINT i_db_docs_p PRIMARY KEY(id)
-- Several notes need to be made about this anonymous block.
-- First the 'DOCS_DIR' parameter is a directory object name.
-- This directory object name must be in upper case.
DECLARE
f_lob BFILE;
b_lob BLOB;
document_name VARCHAR2(50);
BEGIN
document_name := 'externaltables.doc';
INSERT INTO db_docs
VALUES (1, 'binary', 'C:\sql\oracle_text\documents\externaltables.doc', empty_blob())
RETURN document INTO b_lob;
f_lob := BFILENAME('DOCS_DIR', document_name);
DBMS_LOB.FILEOPEN(f_lob, DBMS_LOB.FILE_READONLY);
DBMS_LOB.LOADFROMFILE(b_lob, f_lob, DBMS_LOB.GETLENGTH(f_lob));
DBMS_LOB.FILECLOSE(f_lob);
COMMIT;
END;
-- build the index
-- Note that this index differs than the file system stored file
-- in that paramter datastore is ctxsys.defautl_datastore and not
-- ctxsys.file_datastore. FILE_DATASTORE is for documents that
-- exist on the file system. DEFAULT_DATASTORE is for documents
-- that are stored in the column.
create index db_docs_ctx on db_docs(document)
indextype is ctxsys.context
parameters (
'datastore ctxsys.default_datastore
filter ctxsys.inso_filter
format column format');
--search for something that is known to not be in the document.
SELECT SCORE(1), id, location
FROM db_docs
WHERE CONTAINS(document, 'Jenkinson', 1) > 0;
--search for something that is known to be in the document.
SELECT SCORE(1), id, location
FROM db_docs
WHERE CONTAINS(document, 'Albright', 1) > 0; -
BLOB access using PL/SQL or SQL
I have the following script which creates a table and populates it including an employee picture in a BLOB column.
-- * cr_lob.sql *
-- * created by Lloyd R. Weaver *
-- * February 24, 2003 *
Connect SYSTEM/MANAGER
-- * Initial cleanup *
DROP USER ORA4 CASCADE;
DROP TABLESPACE MEDIUM_VOL_DATA INCLUDING CONTENTS CASCADE CONSTRAINTS;
DROP TABLESPACE LARGE_OBJECT_INDEX INCLUDING CONTENTS CASCADE CONSTRAINTS;
DROP TABLESPACE LARGE_OBJECT_DATA INCLUDING CONTENTS CASCADE CONSTRAINTS;
DROP DIRECTORY PHOTOS;
HOST ERASE C:\ORACLE\ORADATA\ORCL\MED_VOL_DATA_F1.DBF
HOST ERASE C:\ORACLE\ORADATA\ORCL\LRG_OBJ_INDX_F1.DBF
HOST ERASE C:\ORACLE\ORADATA\ORCL\LRG_OBJ_DATA_F1.DBF
-- * Create user account for demo *
CREATE USER ORA4 IDENTIFIED BY ORA4
DEFAULT TABLESPACE USERS
QUOTA UNLIMITED ON USERS
QUOTA 0 ON SYSTEM;
GRANT DBA TO ORA4;
CONNECT ORA4/ORA4
-- * Step 1: Create Tablespaces for LOB scenario *
CREATE TABLESPACE MEDIUM_VOL_DATA
DATAFILE 'C:\ORACLE\ORADATA\ORCL\MED_VOL_DATA_F1.DBF' SIZE 2M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 10K NEXT 10K PCTINCREASE 0 MAXEXTENTS 100)
EXTENT MANAGEMENT DICTIONARY;
CREATE TABLESPACE LARGE_OBJECT_INDEX
DATAFILE 'C:\ORACLE\ORADATA\ORCL\LRG_OBJ_INDX_F1.DBF' SIZE 2M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 10K NEXT 10K PCTINCREASE 0 MAXEXTENTS 100)
EXTENT MANAGEMENT DICTIONARY;
CREATE TABLESPACE LARGE_OBJECT_DATA
DATAFILE 'C:\ORACLE\ORADATA\ORCL\LRG_OBJ_DATA_F1.DBF' SIZE 20M
AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 1M NEXT 1M PCTINCREASE 0 MAXEXTENTS 100)
EXTENT MANAGEMENT DICTIONARY;
-- * Step 2: Create a table with BLOB column and add primary key constraint *
CREATE TABLE LTI_INSTRUCTOR
(INST_ID NUMBER(4)
,INST_LNAME VARCHAR2(25)
,INST_FNAME VARCHAR2(12)
,INST_PHOTO BLOB DEFAULT EMPTY_BLOB())
LOB (INST_PHOTO) STORE AS INST_PHOTO_DATA_SEG
(TABLESPACE LARGE_OBJECT_DATA STORAGE (INITIAL 1M NEXT 1M PCTINCREASE 0)
DISABLE STORAGE IN ROW
CHUNK 10 NOCACHE NOLOGGING
PCTVERSION 10
INDEX INST_PHOTO_INDEX_SEG
(TABLESPACE LARGE_OBJECT_INDEX STORAGE (INITIAL 100K NEXT 100K PCTINCREASE 0)))
TABLESPACE MEDIUM_VOL_DATA STORAGE (INITIAL 100K NEXT 100K PCTINCREASE 0);
ALTER TABLE LTI_INSTRUCTOR
ADD CONSTRAINT LTI_INSTRUCTOR_PK
PRIMARY KEY (INST_ID);
-- * Step 3: Create the directory for the photos *
CREATE DIRECTORY PHOTOS AS 'C:\InstructorPhotos';
-- * Step 4: Create the procedure to insert a row into the table including the photo *
CREATE OR REPLACE PROCEDURE INSERT_LTI_INSTRUCTOR
(V_INST_ID IN LTI_INSTRUCTOR.INST_ID%TYPE
,V_INST_LNAME IN LTI_INSTRUCTOR.INST_LNAME%TYPE
,V_INST_FNAME IN LTI_INSTRUCTOR.INST_FNAME%TYPE
,V_PHOTO_FILE IN VARCHAR2) IS
FILELOC BFILE;
LOCBLOB BLOB;
LEN INT;
E_BLOB BLOB;
BEGIN
FILELOC := BFILENAME('PHOTOS', V_PHOTO_FILE);
E_BLOB := EMPTY_BLOB();
INSERT INTO LTI_INSTRUCTOR VALUES (V_INST_ID, V_INST_LNAME, V_INST_FNAME, E_BLOB)
RETURNING INST_PHOTO INTO LOCBLOB;
DBMS_LOB.FILEOPEN(FILELOC);
LEN := DBMS_LOB.GETLENGTH(FILELOC);
DBMS_LOB.LOADFROMFILE(LOCBLOB,FILELOC,LEN);
DBMS_LOB.FILECLOSEALL();
COMMIT;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20999, SQLERRM);
END;
-- * Step 5: Create a function to return the lenth of the BLOB field by reading it *
CREATE OR REPLACE FUNCTION INST_PHOTO_SIZE
(V_INST_ID LTI_INSTRUCTOR.INST_ID%TYPE)
RETURN NUMBER
IS
SRCH_LOB BLOB;
BUFFER RAW(16384);
AMOUNT BINARY_INTEGER := 16384;
POS INTEGER := 1;
COUNTER INTEGER := 1;
TOTAL_BYTES INTEGER;
BEGIN
SELECT INST_PHOTO
INTO SRCH_LOB
FROM LTI_INSTRUCTOR
WHERE INST_ID = V_INST_ID;
IF SRCH_LOB IS NOT NULL THEN
LOOP
DBMS_LOB.READ (SRCH_LOB, AMOUNT, POS, BUFFER);
POS := POS + AMOUNT;
COUNTER := COUNTER + 1;
END LOOP;
ELSE
TOTAL_BYTES := NULL;
END IF;
RETURN TOTAL_BYTES;
EXCEPTION
WHEN NO_DATA_FOUND THEN
TOTAL_BYTES := POS;
RETURN TOTAL_BYTES;
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20999, SQLERRM);
END;
-- * Step 6: Insert rows including photos into table and confirm data entry *
-- * Note: The photos are in the directory (case sensitive) defined in Step 3. *
EXECUTE INSERT_LTI_INSTRUCTOR(1001,'WEAVER','LLOYD','Lloyd.JPG');
EXECUTE INSERT_LTI_INSTRUCTOR(1002,'EVIL','LLOYD','lloyd-evil.jpg');
EXECUTE INSERT_LTI_INSTRUCTOR(1003,'SHELTON','CONNIE','Connie.JPG');
EXECUTE INSERT_LTI_INSTRUCTOR(1004,'SMITH','DOUG','Doug.JPG');
SELECT INST_ID, INST_LNAME, INST_FNAME, INST_PHOTO_SIZE(INST_ID) PHOTO_BYTES
FROM LTI_INSTRUCTOR;
I want to display the BLOB column on a asp web page but cannot get it to recognize the BLOB column back as a picture. Since this is being used to demo uses of PL/SQL, I would like to keep it all as SQL or PL/SQL
The asp page looks like the following...it selects the row from the table based on the instructor selected from another pane. (ORCLConnectORA4 is an ODBC connection)
<%
Const lcDBName = "ORCLConnectORA4"
%>
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#CC9900" vlink="#CC9900" alink="#EE1111">
<%
lID=Request.form("EmployeeSelection")
Set lConn = Server.CreateObject("ADODB.Connection")
lConn.ConnectionString = "DSN=" & lcDBName & ";UID=ORA4;PWD=ORA4"
lConn.Open
lSQL = "SELECT INST_FNAME, INST_LNAME, INST_PHOTO from LTI_INSTRUCTOR where INST_ID = " & lID
Set lRS = lConn.Execute(lSQL)
%>
<table border="1" cellspacing="0" width=80% align="center">
<%
lRows = 0
On Error Resume Next
lRS.MoveFirst
lRows = lRows + 1
lFNAME = lRS.Fields("INST_FNAME").Value
lLNAME = lRS.Fields("INST_LNAME").Value
lPHOTO = lRS.Fields("INST_PHOTO").Value
lConn.Execute(lSQL)
%>
<tr>
<td <%=lBGColor%> align="left" bgcolor="#990000" width="150"><font color="#FFFFFF" size="4"><strong><small>Employee ID</small></strong></font></td>
<td <%=lBGColor%> align="left" bgcolor="#CCCCCC"><b><font size="4" color="#990000"><small><%=lID%>
</small></font></b></td>
</tr>
<tr>
<td <%=lBGColor%> align="left" bgcolor="#990000" width="150"><font color="#FFFFFF" size="4"><strong><small>First Name</small></strong></font></td>
<td <%=lBGColor%> align="left" bgcolor="#CCCCCC"><b><font size="4" color="#990000"><small><%=lFNAME%>
</small></font></b></td>
</tr>
<tr>
<td <%=lBGColor%> align="left" bgcolor="#990000" width="150"><font color="#FFFFFF" size="4"><strong><small>Last Name</small></strong></font></td>
<td <%=lBGColor%> align="left" bgcolor="#CCCCCC"><b><font size="4" color="#990000"><small><%=lLNAME%>
</small></font></b></td>
</tr>
<tr>
<td align="left"><%=lPHOTO%></td>
</tr>
<%
lRS.Close
lConn.Close
%>
</table>
</body>
</html>Hi,
You've posted this to the web services list. Do you want to use a web service to retrieve the BLOB?
You might want to repost this to another of the forums
rgds
Susan Duncan -
Problem while using Utl_mail Package.
When i am trying to write file in local oracle server it works fine. But when i tried to write file in mapped or network drive system gives me a error message. I also want to write file in Client drive. How it would be possible.
I got something for Mapped drive i am not able to implement successfully.
The following example shows how this doesn't work, and in addition, shows how a directory can be remapped, without causing too much hassle to users who have existing procedures which write or read from the directory - unlike if a specific UTL_FILE_DIR is used. (But, remember, the procedures will go invalid when the directory is dropped - causing a recompile on next execute!)
SQL> connect system
Enter password: ******
Connected.
SQL> drop directory utl_file_dir;
Directory dropped.
SQL> create directory utl_file_dir as 's:\temp\norman\utl_file';
Directory created.
SQL> grant read,write on directory utl_file_dir to scott;
Grant succeeded.
SQL> connect scott/tiger
Connected.
SQL> execute empflatfile
BEGIN empflatfile; END;
ERROR at line 1:
ORA-20001: utl_file.invalid_operation
ORA-06512: at "SCOTT.EMPFLATFILE", line 19
ORA-06512: at line 1
So that didn't work - why not ?
In control panel, services (NT) or control panel, administrative tools, services - stop the OracleServiceXXXX service. Click on the login tab, and note that it is using a local system logon. That user has no rights to any shares (at least on our NT system,) and so is unable to access the shared drives by their mapped name or full UNC name.
If I change the service to logon as my own username and restart it, I can try again :
SQL> connect scott/tiger
Connected.
SQL> execute empflatfile
PL/SQL procedure successfully completed.
I could also go back and change the directory to use a mapped drive name (S:\temp\norman\utl_file) but if our sysadmins for NT decided to change the share name, or the mapped drive, the procedure would be broken again. It is advisable to use the full UNC name for the drive you are trying to access.
And finally, watch out for the times when you change your Windows password. When you do this, remember to amend your OracleServiceXXXX service again - otherwise the database won't startup.
It's not possible to start and stop database again and again. How can i gives all rights to current user to do this task.Wason Naveen wrote:
It's not possible to start and stop database again and again. How can i gives all rights to current user to do this task.You don't.. as it is IMO a serious security violation to attempt what you are doing.
The correct method is to have the client "+save+" the file it receives from the server - not for the server to write directly to the client's drive.
Using a web-based architecture, this is quite easy - the web browser makes a standard HTTP call (via a web server) to a PL/SQL procedure and it streams the file (using standard HTTP) to the browser. The web user now has the options to save or open the file (depending on the Mime type specified by the PL/SQL procedure and mapping of that type in the client's browser).
From a security, robustness, performance and scalability points of view.. I (wearing either DBA or sysadmin cap) would refuse to implement PL/SQL code on a server instance that writes directly to a client drive. -
Loading XML file into DB Table
Hi
I m quite new to the loading XML file into database table.
It will be great if anyone could guide me to through.
Now,
i have an XML file which has to be loaded into the DB table.
what are the steps involved in doing this. How do i go from here ??
your help is greatly appriciated ???
Thank you so much!!
-ShashiOK - Although you really should read the XMLDB FAQ on this forum, here is some sample code of ONE of the ways of doing it
(there are multiple ways - and this is not the most simple one)
Based on Oracle 11gR1
-- sqlplus /nolog
clear screen
set termout on
set feed on
set lines 40
set long 10000000
set serveroutput on
set lines 100
set echo on
connect / as sysdba
col filename for a80
col xml for a80
-- Create schema “OTN”
drop user OTN cascade;
purge dba_recyclebin;
create user OTN identified by OTN;
grant dba, xdbadmin to OTN;
EXECUTE dbms_java.grant_permission( 'OTN', 'java.io.FilePermission','G:\OTN\xmlstore','read' );
prompt pause
pause
clear screen
-- Create directory
connect OTN/OTN;
show user
drop directory OTN_USE_CASE;
CREATE directory OTN_USE_CASE AS 'G:\OTN\xmlstore';
SELECT extract((XMLTYPE(bfilename('OTN_USE_CASE','ABANDA-20030407215829881GMT.xml'),NLS_CHARSET_ID('AL32UTF8'))),'*') AS "XML"
from dual;
prompt pause
pause
clear screen
-- Directory Listing - Tom Kyte
create global temporary table DIR_LIST
( filename varchar2(255) )
on commit delete rows
create or replace
and compile java source named "DirList"
as
import java.io.*;
import java.sql.*;
public class DirList
{public static void getList(String directory)
throws SQLException
{ File path = new File( directory );
String[] list = path.list();
String element;
for(int i = 0; i < list.length; i++)
{ element = list;
#sql { INSERT INTO DIR_LIST (FILENAME)
VALUES (:element) };
create or replace procedure get_dir_list( p_directory in varchar2 )
as language java
name 'DirList.getList( java.lang.String )';
prompt pause
pause
clear screen
-- The content of the global temporary table
exec get_dir_list( 'G:\OTN\xmlstore' );
select * from dir_list;
-- "COMMIT" will clear / truncate the global temporary table...
prompt pause
pause
clear screen
-- Combined: Reading XML content from multiple XML files
commit;
exec get_dir_list( 'G:\OTN\xmlstore' );
select * from dir_list where filename like '%.xml'
and rownum <= 10;
prompt pause
pause
clear screen
select extract((XMLTYPE(bfilename('OTN_USE_CASE',dl.filename),NLS_CHARSET_ID('AL32UTF8'))),'*') AS "XML"
from dir_list dl
where dl.filename like '%.xml' and rownum <= 2;
prompt pause
pause
clear screen
-- If you can select it you can insert it...
-- drop table OTN_xml_store purge;
create table OTN_xml_store of xmltype
xmltype store as binary xml
commit;
exec get_dir_list( 'G:\OTN\xmlstore' );
set time on timing on
insert into OTN_xml_store
select XMLTYPE(bfilename('OTN_USE_CASE',dl.filename),NLS_CHARSET_ID('AL32UTF8')) AS "XML"
from dir_list dl
where dl.filename like '%.xml';
set time off timing off
commit;
select count(*) from OTN_xml_store;
prompt pause
pause
clear screen
-- If you can select it you can create resources and files
set time on timing on
commit;
exec get_dir_list( 'G:\OTN\xmlstore' );
select count(*) from dir_list where filename like '%.xml';
set serveroutput on size 10000
DECLARE
XMLdoc XMLType;
res BOOLEAN;
v_foldername varchar2(4000) := '/public/OTN/';
cursor c1
is
select dl.filename FNAME
, XMLTYPE(bfilename('OTN_USE_CASE',dl.filename),NLS_CHARSET_ID('AL32UTF8')) XMLCONTENT
from dir_list dl
where dl.filename like '%.xml'
and rownum <= 100;
BEGIN
-- Create XDB repository Folder
if (dbms_xdb.existsResource(v_foldername))
then
dbms_xdb.deleteResource(v_foldername,dbms_xdb.DELETE_RECURSIVE_FORCE);
end if;
res:=DBMS_XDB.createFolder(v_foldername);
-- Create XML files in the XDB Repository
for r1 in c1
loop
if (DBMS_XDB.CREATERESOURCE(v_foldername||r1.fname, r1.xmlcontent))
then
dbms_output.put_line(v_foldername||r1.fname);
null;
else
dbms_output.put_line('Loop Exception :'||sqlerrm);
end if;
end loop;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line('Others Exception: '||sqlerrm);
END;
set time off timing off
commit;
prompt pause
pause
clear screen
-- FTP and HTTP
clear screen
prompt
prompt *** FTP - Demo ***
prompt
prompt pause
pause
host ftp
-- open localhost 2100
-- user OTN OTN
-- cd public
-- cd OTN
-- ls
-- bye
clear screen
prompt
prompt *** Microsoft Internet Explorer - Demo ***
prompt
prompt pause
pause
host "C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://OTN:OTN@localhost:8080/public/OTN/
prompt pause
pause
-- Accessing the XDB Repository content via Resource View
-- Selecting content from a resource via XBDUriType
clear screen
prompt set long 300
set long 300
prompt Relative Path - (path)
SELECT path(1) as filename
FROM RESOURCE_VIEW
WHERE under_path(RES, '/public/OTN', 1) = 1
and rownum <= 10
prompt pause
pause
clear screen
prompt Absolute Path - (any_path)
select xdburitype(any_path).getClob() as xml
FROM RESOURCE_VIEW
WHERE under_path(RES, '/public/OTN', 1) = 1
and rownum <= 1;
prompt pause
pause
-- CLEANUP ENVIRONMENT
clear screen
prompt
prompt >>>>> Clean UP !!! <<<<<<
prompt
prompt Cleanup environment and drop user...!!!
prompt
pause
clear screen
conn / as sysdba
alter session set current_schema=OTN;
begin
dbms_xdb.deleteResource('/public/OTN',dbms_xdb.DELETE_RECURSIVE_FORCE);
commit;
end;
alter session set current_schema=sys;
drop user OTN cascade;
Based on http://www.liberidu.com/blog/?p=1053
Maybe you are looking for
-
Can you have Two iMessage accounts on a MBP
We have mid 2009 MBP running Yosemite 10.10.1 The MBP is in my wifes name, I tend to use it all the time rather than the wife, so I use her user account rather making my own user account on the Mac, but do we have our own Apple id's. The MBP has neve
-
FCS is only deleting my FCP project file and not linked assets. please help.
When deleting a FCP project from FCS it does not give me the option to delete all linked media. It only deletes the FCP project file leaving me to delete all related media manually. In the user guide it says it should give me the option to delete the
-
Problem in using ora:countNodes
Hi i am trying to poll database and receive the records using receive activity. later i am trying to count the number of record polled each time. i am using ora:countNodes function. But i am getting the below error : Error while processing xpath expr
-
Setting intensity graph to blinking causes LV2012 to crash
Hi, This VI crashes when setting blinking to TRUE, using LV2012, Win7 32 bit. I saw that this was a bug in 2004 , hasn't it been fixed yet? Or am I missing something obvious? Thanks, Danielle "Wisdom comes from experience. Experience is often a resul
-
Thir party + subcontracting without PP component
My client gives material for subcontracting to a subcontractor who is physically near to the customer. There is no point in bringing all the material from Chennai to North India. So the requirements is that the material should be given for subcontra