Unix script output sql result to terminal
Hi,
I run the script below within a unix script. the query runs but only outputs the first line. I need the whole results output to the terminal.. please let me know if I am doing something wrong. thanks
ORACLE_SID=orcl
export ORACLE_SID
SHELL=/bin/sh
db="username/password"
sqlplus -s $db <<xxx
set serveroutput on
define yy=100
whenever sqlerror exit yy
begin
declare
Dyn_table_name VARCHAR2(100);
Dyn_query_string VARCHAR2(4000);
Type csr_dyn IS REF CURSOR;
csr_dyn1 csr_dyn;
col1 varchar2(200);
col2 varchar2(200);
col3 varchar2(200);
col4 varchar2(200);
col5 varchar2(200);
begin
Dyn_table_name :='''my_table''';
Dyn_query_string :='SELECT b.session_id ,s.serial#,NVL(b.oracle_username,''(oracle)'') AS username,'
||'a.object_name,b.os_user_name FROM dba_objects a,v\$locked_object b,v\$session s'
||' WHERE a.object_id =Upper(b.object_id)and b.session_id=s.sid and a.object_name='||Dyn_table_name;
/*dbms_output.put_line(Dyn_query_string);*/
dbms_output.put_line('SID'||' '|| 'serial#' || ' '||'USERNAME'||' '||'OBJECT_NAME'||' '||'OS_USER_NAME');
dbms_output.put_line('------------------------------------------------------------------------------------');
OPEN csr_dyn1 FOR dyn_query_string;
LOOP
FETCH csr_dyn1 INTO col1,col2,col3,col4,col5;
EXIT WHEN csr_dyn1%NOTFOUND;
dbms_output.put_line(col1||' '|| col2||' '|| col3 || ' ' || col4 ||' '|| col5);
END LOOP;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line(to_char(sqlcode)|| ' '|| sqlerrm);
end;
end;
set serveroutput off
exit
xxx
Sorry all your suggestion did not work ( the log file had this error message
Usage 1: sqlplus -H | -V
-H Displays the SQL*Plus version and the
usage help.
-V Displays the SQL*Plus version.
Usage 2: sqlplus [ [<option>] [<logon>] [<start>] ]
<option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]
... I know its possible to login into sqlplus and run the querry, but I want it as a script which would output this kind of result to the screen
SESSION_ID SERIAL# USERNAME OBJECT_NAME OS_USER_NAME
251 30330 PRD my table oracle
335 11624 PRD my table oracle
469 2592 PRD my table oracle
849 8619 PRD my table oracle
934 40211 PRD my table oracle
955 15043 PRD my table oracle
is it possible or am I asking for the impossible...!!! I appreciate your suggestion... you can alter the script I put up and paste the correction so that I can see cleary how you made it work for you.
Similar Messages
-
Can we run a unix script from sql plus
Hello,
Is there any possibility to run unix command from sql plus? I would appreciate if you can provide with the syntax.
Thank You
KKuser539616 wrote:
Hello,
Is there any possibility to run unix command from sql plus? I would appreciate if you can provide with the syntax.
Thank You
KKWithin sqlplus you can run
1) SQL statements
2) PL/SQL blocks
3) any valid sqlplus command.
SQLplus commands are documented in the SQLPlus reference manual. For 10g this is found at http://docs.oracle.com/cd/B19306_01/server.102/b14357/toc.htm. You might be interested in the HOST command, detailed at http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12026.htm#sthref2314
Just beware that the HOST command (or the shortcut version of it alluded to by Warren Tolentino) spawns a child process. When control comes back to sqlplus, that child process is gone.
What is the business problem you are trying to solve? If we knew that we could probably give better advice than blindly giving you the correct technical answer to a narrow question. -
Saving a script as .sql results in .pls file
I wrote a SQL statement in Raptor which I saved as .sql file.
The generated file has a .pls suffix instead of the .sql suffix.This is a bug. number 4926221
-
Oracle career with unix scripting?
hi
iam working in a reputed mnc with CMMi level 5 .started as fresher (BE I.T) i have around 1.6 years of experiance in unix scripting/oracle sql production support.
with learning of sql and shell scripting
i want to make my career in oracle which should be more dynamic,learning and creative not like in production support which have monotonus life.
could anyone please guide me about what career path i should choose ?
DBA , i have heard is montonous job too with same routine backups,no creativity with nightshifts and all, but it is more stable as people said. I have no experiance of it.
second devolper track in sql/pl sql having its own limitations like less demand, less financial growth etc. and people usually wants to shift in other area like BO
i don`t have any info about others areas like that i would like to explore
1)Datawarehousing
2)Oracle apps
3)Business objects (BO reporting)
4)Oracle CRM etc
5)Others (thats all i know,please add some others if they are creative )
iam really confsused now which way to chosse. and how to jump in other company on wat basis?
preparing for OCA right now but uncertain for career.
Seeking good help from forum experts."with learning of sql and shell scripting"
Ah, very good move, so you must pick my tool, it is all about managing Oracle DB through Korn shell http://www.smenu.org.
As of your question, the answer is in your mood and preference.
Oracle DBA: Definitely more money, less opportunity. the job is dwindling somehow due to Grid automation and budget restriction.
It is not that you don't need DBA, but manager thinks they can do without and don't (try) replace them. Pressure on DBA is a myth: more work = more money = happy DBA until wife run away.
Developer : Definitely less money, not necessary more opportunity unless you have java EE. no shift but more pressure: Projects are always in late, usually in the development area, not in the infrastructure.
One funny thing I noticed during these last 15 years, is that DBA have usually more children than others people (unix sys admin or Dev). Probably related to better earning.
DBA can be boring or passionate depending on your own knowledge, most of others DBA I know are still in the job, only one is now JAVA EE guy. -
SQL Developer Script Output too limited for student - how to increase?
I'm just a student trying to migrate from notepad and SQL Plus to using the SQL Developer for the comprehensive course project. Unfortunately, the script output is way too limited... it only reports a fourth of my last assignment's results - not enough to use in the project. How specifically can this be increased. I have version 1.1.0.21 running on Windows XP on a laptop with 512k memory.
Thanks much for any/all assist. I don't want to go back to notepad!!Thank you for the advice, but I had tried that. My script is 305 lines counting blank lines and the SQL developer displays only about 35 lines of results corresponding to 58 lines of input. When I run the same script in SQL Plus in a console window using the @filename command, I get the entire output.
My input and output follow:
Input:
spool project-test-out.txt
prompt 'name'
prompt 'Assignment X, parts 2b - 2h and 3a - 3b '
create table Customer (
CustID Integer,
Name Char(10),
State Char(2),
primary key (CustID) );
create view CustID_List (ID_Cust) as (select custID from Customer);
create table Inventory (
PartID Integer,
Item Char(10),
Cost Float,
OnHand Integer,
primary key (PartID) );
create table Invoice (
InvNum Integer,
InvDate DATE,
CustID Integer,
primary key (InvNum),
foreign key (CustID) references Customer);
create table Invoice_Item (
InvNum Integer,
PartID Integer,
Quantity Integer,
foreign key (InvNum) references Invoice,
foreign key (PartID) references Inventory);
insert into customer values ( 101, 'Kerry', 'MA' );
insert into customer values ( 102, 'Edwards', 'NC' );
insert into customer values ( 103, 'Cheney', 'TX' );
insert into customer values ( 104, 'Bush', 'TX' );
insert into Inventory values ( 1, 'Boots ', 149.95, 6 );
insert into Inventory values ( 2, 'Spurs ', 12.95, 24 );
insert into Inventory values ( 3, 'Buckle ', 19.95, 4 );
insert into Inventory values ( 4, 'Hat ', 60.00, 12 );
insert into Inventory values ( 5, 'Holster', 75.00, 8 );
insert into Inventory values ( 6, 'Saddle ', 350.00, 2 );
prompt 'Part grad 3b - unsatisfying solution, limitations of Oracle 10g Express'
prompt 'After many trials, found oracle discussion on web stating that'
prompt 'Oracle 9 does not allow subqueries in the trigger WHEN clause.'
prompt 'What a pain. Thus the solution here has become rather inelegant.'
prompt 'The trigger and following select statement are byproducts of various'
prompt 'simplification attempts, none of which worked.'
select ID_Cust from custID_List;
create trigger Invoice_CustID_CK before insert on Invoice
REFERENCING NEW AS newCustID
FOR EACH ROW
BEGIN
if (:newCustID.CustID = 205 )
-- {{want line below but it generates error of: subquery not allowed in }}
-- {{this context }}
-- if (:newCustID.CustID NOT IN
-- (Select ID_Cust from CustID_List))
then :newCustID.CustID := NULL;
end if;
END;
run;
show errors trigger Invoice_CustID_CK;
insert into invoice values ( 201, '01-Aug-2006', 101 );
insert into invoice values ( 202, '02-Sep-2006', 101 );
insert into invoice values ( 203, '05-Oct-2006', 103 );
insert into invoice values ( 204, '07-Oct-2006', 102 );
insert into invoice values ( 205, '09-Oct-2006', 205 );
insert into Invoice_Item values ( 201, 1, 1 );
insert into Invoice_Item values ( 201, 2, 1 );
insert into Invoice_Item values ( 202, 5, 2 );
insert into Invoice_Item values ( 203, 1, 2 );
insert into Invoice_Item values ( 203, 2, 2 );
insert into Invoice_Item values ( 203, 3, 2 );
insert into Invoice_Item values ( 203, 4, 2 );
insert into Invoice_Item values ( 204, 4, 2 );
insert into Invoice_Item values ( 204, 1, 1 );
select * from invoice;
select * from customer;
select * from invoice_item;
select * from inventory;
prompt 'Preparation for part 2b - create view showing onhand and starting inventory'
alter table inventory add (start_inventory integer);
update inventory
set start_inventory = onhand;
create view inv_changes as
select partid, sum(quantity) as sales_by_id
from invoice_item
group by partid;
create table inventory_invoiced as
select inventory.partid, item, cost, onhand, start_inventory, COALESCE (sales_by_id, 0) as sales_by_id_NZ
from inventory left outer join inv_changes
on inventory.partid = inv_changes.partid;
select * from inventory_invoiced;
update inventory_invoiced
Set
onhand = onhand - sales_by_id_NZ;
select * from inventory_invoiced;
prompt 'Part 2b - What item has the least on hand inventory after processing the invoices?'
select item
from inventory_invoiced
where onhand = (select min(onhand) from inventory_invoiced);
prompt 'Part 2c - How much does customer 101 owe?'
create view cust101_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 101);
select * from cust101_orders;
select sum(quantity * cost) as cust101_bill
from cust101_orders, inventory
where cust101_orders.partID = inventory.partID;
prompt 'Part 2d - Which customer has the biggest bill?'
prompt ' desirable solution is to do part 2c as a general case '
prompt ' using a stored function such that the custID is passed '
prompt ' to the function. Unfortunately, neither function below '
prompt ' compiles. First case trips on creating the view. Second'
prompt ' case being arewrite without a view - ifit even works - '
prompt ' trips on the complicated select'
create or replace function ind_customer_bill
(ind_customer_ID in integer)
return Float
IS ind_total_bill Float;
begin
create view cust_orders as
select distinct partID, quantity
from invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = ind_customer_ID);
select sum(quantity * cost) into ind_total_bill
from cust_orders, inventory
where cust_orders.partid = inventory.partid;
drop view cust_orders;
return (ind_total_bill);
end;
show errors function ind_customer_bill;
create or replace function ind_customer_bill
(ind_customer_ID in integer)
return Float
IS ind_total_bill Float;
begin
select sum(quantity * cost) into ind_total_bill
from inventory, (select distinct partID as interim_partID, quantity
from invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = ind_customer_ID))
where interim_partID = inventory.partid;
return (ind_total_bill);
end;
show errors function ind_customer_bill;
Prompt 'part 2d continued using shameful brute force technique'
select * from cust101_orders;
create view cust101_due as
select sum(quantity * cost) as cust101_bill
from cust101_orders, inventory
where cust101_orders.partID = inventory.partID;
create view cust102_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 102);
select * from cust102_orders;
create view cust102_due as
select sum(quantity * cost) as cust102_bill
from cust102_orders, inventory
where cust102_orders.partID = inventory.partID;
create view cust103_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 103);
select * from cust103_orders;
create view cust103_due as
select sum(quantity * cost) as cust103_bill
from cust103_orders, inventory
where cust103_orders.partID = inventory.partID;
create view cust104_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 104);
select * from cust104_orders;
create view cust104_due as
select sum(quantity * cost) as cust104_bill
from cust104_orders, inventory
where cust104_orders.partID = inventory.partID;
prompt 'and the answer to part 2d - biggest bill is'
select *
from cust101_due, cust102_due, cust103_due, cust104_due;
prompt 'Part 2e - What items were the most popular (most sold)'
select item
from inventory_invoiced
where sales_by_id_NZ >= ANY (
select max(sales_by_id_NZ) from inventory_invoiced);
prompt 'Part 2f - What was the value of the original inventory'
select sum (start_inventory * cost) as total_start_inventory
from inventory_invoiced;
prompt 'Part 2g - What was the value of the ending inventory'
select sum (onhand * cost) as total_ending_inventory
from inventory_invoiced;
prompt 'Part 2h - What customers did not place an order'
-- after some testing of the inner nest parts wherein the left outer join
-- results in a CustID_List entry 104 having a null entry in
-- invoice's CustID list.
select Name
from customer
where custID IN (select ID_Cust
from (select ID_Cust, CustID
from CustID_List left outer join invoice on
ID_Cust = CustID)
where CUSTID IS NULL);
prompt 'Part 3a - What items were not purchased by anyone'
select item as unpurchased
from inventory_invoiced
where sales_by_id_nz = 0;
prompt 'Part 3b - table modifications for invoices to have valid CustID'
prompt ' -- see 3b section at top of file, notes and trigger '
drop view cust101_due;
drop view cust102_due;
drop view cust103_due;
drop view cust104_due;
drop function ind_customer_bill;
drop view cust101_orders;
drop view cust102_orders;
drop view cust103_orders;
drop view cust104_orders;
drop table inventory_invoiced;
drop view inv_changes;
drop view custID_List;
drop table invoice_item;
drop table invoice;
drop table inventory;
drop table customer;
Output:
'name'
'Assignment X, parts 2b - 2h and 3a - 3b '
create table succeeded.
create view succeeded.
create table succeeded.
create table succeeded.
create table succeeded.
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
'Part grad 3b - unsatisfying solution, limitations of Oracle 10g Express'
'After many trials, found oracle discussion on web stating that'
'Oracle 9 does not allow subqueries in the trigger WHEN clause.'
'What a pain. Thus the solution here has become rather inelegant.'
'The trigger and following select statement are byproducts of various'
'simplification attempts, none of which worked.'
ID_CUST
101
102
103
104
4 rows selected
trigger Invoice_CustID_CK Compiled. -
SQL Worksheet - Script output is restricted to 5000 rows
Hello,
till now only 5000 rows are currently supported in a script results.
I have read, this count will be a preference in future releases. Is there such a release and if "yes" how can I change this count of rows?
Script Output of SQL Worksheet is the only possibility in SQL Developer I know, to export data from a query, that is a join of multiple tables, into flat file. Is there another one?
Thanks,
TzonkaYou can run your query as a statement (F9) and the results will be displayed in the Results tab. In the Results tab, you can right-click, select Export and then Text. This will allow you to export the results of the query into a text file (or the clipboard). This will enclose values with " and separate with tabs (allowing alternatives is another "wait for a later release" function).
This will produce the equivalent output of creating the view and exporting the data from the view tab as suggested by Sharon, without having to go to the effort of creating the view.
If by "flat file" you mean exactly what you would get with a spool from SQL*Plus, then the Script tab is your only option and you are restricted to the 5000 rows. -
SQL Developer formatting script output
Im new to sql developer. I have been unable to format the script output to decrease the width of the column below.
All numeric columns seem to use 22 underscores. I would like to format this to make it more presentable to users.
I have tried column, substr, and the various trims. While these work in native unix, they do not seem to work in
SQL Developer. Up till now I have found SQL Developer to be a very usefull tool. I hope this is just a matter of me not
having enough knowledge of the product and not a problem with it.
Any and all assistance greatly appreciated.
MACCNO
3021202788184 wrote:
What I need is to produce the following (column is numeric 5)
HEAD1
12345
instead of what comes out currently
HEAD1
12345
Yes, have checked preferences but could not see anything to change.
Edited by: 788184 on 12/08/2010 19:55I think the problem is related to SQL*PLUS. SQL Developer tries to mimick SQL*PLUS whan you run something as a script. The mimicking s not perfect though.
The size of this line depends on the typeof the database field. For numbers a larger line is taken. For varchar2 it depends from the size of the values or the header.
If you are absolutly sure that data inside this column is always smaller, then you could try the following thing.
select cast(HEAD1 as varchar2(5)) as HEAD1 from yourTableBe careful since this will do a number to string conversion. But since it seems to be for reporting purposes that should be ok. -
How can I pass value from sql query to unix script
I am new to oracle/unix.
I want to write a simple script to find max date from a table and then pass date into a variable in a korn shell script.
sql is select max(date) from table;
how can I pass that value in unix shell as a variable. ThanksI use to code like this.
Enjoy Scripting.
cmd.sql
select sysdate from dual;
exit
db.sh
#! /usr/bin/ksh
. ~oracle/.orapaths
dbdate=$(sqlplus -S user/pwd@servicename @cmd.sql)
echo $dbdate
Run shell scripts
./db.sh
SYSDATE --------- 19-JAN-07 -
How to flush script output in sql developer
Greetings from a newbie,
how can I flush script output in sql developer?
regards,
ValerieFlush? You can wipe the Output pane by pressing the "Clear" icon (crayon gum): the first icon on the tab's mini-toolbar.
Does that answer your question?
K. -
How ro run unix script freom pl/sql - dbms_scheduler 11.2.0.3
Hi,
Using 11.2.0.3 and have a unix script which works fine.
Want to run this unix script every time a piece of pl/sql runs
have put below in but doesn't actually run it.
How can we achieve this?
Many Thanks
idea is that file we create locqally on server is copied to another via the unix script caled form pl/sql
DBMS_SCHEDULER.create_program (
program_name => 'test_executable_prog',
program_type => 'EXECUTABLE',
program_action => '/oracle/jm/data/dataout/copy_tcfile',
number_of_arguments => 0,
enabled => TRUE,
comments => 'CREATE_PROGRAM test using a schell script.');Tried below but no joy
-- Shell Script (OS executable file).
/*DBMS_SCHEDULER.drop_program(program_name => 'por_copy_files');
DBMS_SCHEDULER.create_program (
program_name => 'por_copy_files',
program_type => 'EXECUTABLE',
program_action => ' /oracle/jm/data/dataout/copy_tcfile',
number_of_arguments => 0,
enabled => TRUE,
comments => 'CREATE_PROGRAM test using a schell script.');
DBMS_SCHEDULER.create_job (
job_name => 'por_copy_files_job',
program_name => 'por_copy_files',
start_date => null,--SYSTIMESTAMP,
repeat_interval => null,--'freq=hourly; byminute=0',
end_date => NULL,
enabled => TRUE,
comments => 'Job defined by existing program and inline schedule.');Edited by: user5716448 on 03-Oct-2012 08:35
Getting message when look in all_scheduler_job_run_details
ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
even thoug hfile exists
Edited by: user5716448 on 03-Oct-2012 08:50When run for unix command line which o.k
get
AUTHSTATE=files
A__z=! LOGNAME
COLUMNS=132
EDITOR=vi
ENV=/home/oracle/.kshrc
HOME=/home/oracle
LANG=en_US
LC__FASTMSG=true
LOCPATH=/usr/lib/nls/loc
LOGIN=oracle
LOGNAME=oracle
MAIL=/usr/spool/mail/oracle
MAILMSG=[YOU HAVE NEW MAIL]
MAIL_HOST=prdikw01
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
ODMDIR=/etc/objrepos
ORACLE_BASE=/oracle/app/oracle
ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
ORACLE_SID=IKW
ORACLE_TERM=vt100
ORATAB_PATH=/etc
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr/java5/bin:/usr/local/bin:/etc:/usr/sbin:/usr/ucb:/h
ome/oracle/bin:/usr/bin/X11:/sbin:/oracle/app/oracle/product/11.2.0/dbhome_1/bin:/oracle/app/oracle/product/11.2.0/dbhome_1/OPatch
PS1=[$ORACLE_SID]$PWD $
PWD=/oracle/jm/data
SHELL=/usr/bin/ksh
TERM=xterm
TMPDIR=/tmp
TZ=GMT0BST,M3.5.0,M10.5.0
USER=oracle
_=/usr/bin/env
dba=/home/oracle/dbaWhen run from pl/sql
get
ORA-27369: job of type EXECUTABLE failed with exit code: 255
STANDARD_ERROR="execve: Exec format error"when try
dbms_scheduler.create_job(
job_name => 'POR_JOB',
job_type => 'EXECUTABLE',
job_action => '/oracle/jm/data/copy_tcfile',
start_date => SYSTIMESTAMP,
number_of_arguments=>0,
enabled => true,
auto_Drop => true,
comments => 'Demo');Above code in pl/sql where create job and schedule job separately gives file not found message even though give full path -
Scripting pl/sql from unix
I am wondering if there is a way to do this with certain restrictions. If not, I can do it another way.
1. I have a list of values in a unix .txt file of the form
VALUEA
VALUEB
VALUEC
I know how to read a list in unix using a loop.
2. I want to call a pl/sql anonymous block that I have in a .sql file 1 time for every value in this script and pass the value.
I do know how to read a value and then pass it to a pl/sql parameter and then call the pl/sql parameter.
What I don't know how to do is
Do this with only logging into sqlplus one time. I dont want to do the following
unix runs in a loop
reads 1 record from file
logs into sqlplus
runs the procedure and passes the value
log out of sqlplus
end loop
I want to
1. read all the values from the file
2. store it somehow in memory (variable of some sort)
3. pass this value to the pl/sql procedure
I do not want to make any objects in the database such as a global temporary table.
Yes I can actually do this, but wondering if it is possible to avoid. Makes it easier to deploy to alot of different databases. If I have to make a database object, then i have to make an object in alot of databases. If I can run it all from unix, all I have to do is change the target and the password. So it is easier to deploy.I don't need to put this in an Oracle Directory. I am not calling anything from pl/sql stored in the database. It is going to all be done with unix scripts and anonymous block sql in .sql statements in the OS. This allows me to take advantage of clustered storage (I can have alot of databases servers mounted on 1 directory). So the unix script will log into oracle and call the .sql script.
I can build the pl/sql dynamically. I'd rather not do that. The thing is I have alot of databases I want to deploy code to. So I am trying to come up with a pattern I can follow. So if I add a new database or what to deploy somewhere else, I can just use add a line to a file.
Adding database objects every time I need to deploy to a new database is a pain. It is far more scaleable to handle all of this in unix.
Edited by: Guess2 on Jan 12, 2010 7:43 AM -
More on unix script from pl/sql
Hi All,
There was this discussion on starting unix scripts from within a pl/sql stored procedure started on August 31.
All comments were targeted towards an oracle 8X solution.
Does anyone have a solution for 7.3.4?
Somebody mentioned something about using dbms_pipe package.
So, just to rephrase the problem:
- Need to execute any unix command/script from within a pl/sql block (stored procedure). Instance is oracle 7.3.4
Thanks!
EnriqueHi Juan,
You can try this solution:
enable in the the init file the parameter
utl_file_dir="target_directory"In this way You permit the the DB to writing directly to the filesistem in the directory You specified.
After restarting the istance You may write Your own code that, using the supplied package UTL_FILE, writes a file in that directory (es. my_script.sh)
Then, instruct the cron daemon to execute every 1 minute this command.
You may append to the script the self-destruction after the execution.
I hope that this will help You.
Max -
Call a unix script from pl/sql package
Hi,
Using 11.2.0.3 on AIX.
Is it possible to call unix script from pl/sql package?
I am cretaing a file in a directory but would like this to automatically be written to an archive directory as well.
Could either use 2 utl_file.put_lines to 2 separate directories or 1 utl_file and cal script to archive file in another directory.?
Thoughts?
Thanksuser5716448 wrote:
What am I doing wrong?think how file name will look like:
SQL> select 'file_name' || to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;
'FILE_NAME'||TO_CHAR(SYSDATE
file_name15/08/2012 11:47:51Will AIX swallow such name? Obviously not. And, unfortunately, UTL_FILE.FCOPY doesn't raise an error in such case. So use someting like:
UTL_FILE.FCOPY ('SOURCE_DIR',v_FILE_NAME,'DEST_DIR',v_file_name||to_char(sysdate,'DD_MM_YYYY_HH24_MI_SS'));SY. -
Unix script in Oracle Pl/sql
I created a unix script which is automatically transfer the file from one instance to other .Now i want to call that script from pl/sql ,how can i do that
Kindly give the suggestionCheck the following link. It contains the steps to execute system commands from PL/SQL.
http://www-rohan.sdsu.edu/doc/oracle/server803/A54642_01/ch8.htm -
I want to run a UNIX script via PL/SQL. I want the script to be run with no assistance from an outside source. The script contains a 'ls'. Is this possible and if so, how.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Christopher Racicot ([email protected]):
You can use an "external procedure", written in C, which then uses the C runtime library to access the UNIX shell. This features is
also known as "callouts".
We will likely add better native support
in PL/SQL for various operating system
activities in a future release.<HR></BLOCKQUOTE>
Can you invoke Perl from within PLSQL?
Maybe you are looking for
-
Dual Booting Windows 7 with pre-installed Windows 8 Laptop
Hi All, Just after a bit of advice, my girlfriend has recently got a new laptop and unfortunately she doesn't like it, despite me loving Windows 8.1. She would like to try Windows 8 but is going back to Uni soon so would like Windows 7 as a back-up d
-
Dear All, I have created a web service from a function module. I have also created a proxy for the web service. Before creating the logical port, I am also including the same port name in the endpoint of the service. My scenario is, I am creating and
-
Hi Sanjeev Wish you and everyone in this forum a Very Happy Newyear Well,to my problem now... When I receive the traps from WLS for shutdown or restart,the hostname is displayed as localhost and not the actual hostname.This happens when the traps go
-
Finding missing files that are a different file type?
I had several folders of jpegs that i converted to dng with lightroom. I lost the dng files and now i only have the original jpegs. when i introduce them back to lightroom it no longer recognizes them because of the different file type. When i "fi
-
Reinstalling OS to Macbook Air
My son has a Macbook Air purchased 3 months & 5 days ago . The hard drive died and the retailers "fixers" have put in a new H.D. but not re-installed Mac O/S. I find this amazing! However, we're now trying to re-install via remote install on the imac