PL/SQL :: Data To Existing File Using Spool Command?

Jul 19, 2012

I am calling a stored procedure from a shell script. This stored procedure is having a CLOB object as an OUT parameter. How to write the data in CLOB object a existing file which is there in my client system. Below is the shell and sql scripts.

Shell script
( echo "hello" ) > /root/file.txt
sqlplus -s $user/$pass@$tns @/root/proc.sql /root/file.txt << EOF
EOFSQL script
set pages 0
set trimspool off

[Code]...

spool offThis code writes contents of the OUT variable to file.txt, but my existing data ('hello') is lost.

I figured the it...Use append in the spool command...

View 1 Replies


ADVERTISEMENT

Format Output File By Command Spool

Jan 20, 2011

I use sqplus in oracle to output the command output to text file .

I use below set environment variable.

SQL> set echo off;
SQL> set linesize 3999;
SQL> set feedback off;
SQL> set feedback off;
SQL> set termout off;
SQL> set pagesize 0;
SQL> spool mapping.txt
select C_SIM_MSISDN,C_SIM_IMSI from RCA_SMART_CARD order by C_SIM_MSISDN;

In ouput file , it look like

SQL> select C_SIM_MSISDN,C_SIM_IMSI from RCA_SMART_CARD order by C_SIM_MSISDN;
060010007 10007
:
:
:
SQL> spool off;

any setting or command that allow me to remove the first sql command line" SQL>select XXXX" and the last command "SQL>spool off" after start up the "spool mapping.txt"

View 1 Replies View Related

Client Tools :: Format Output File By Command Spool?

Jan 20, 2011

I use sqplus in oracle to output the command output to text file .

I use below set environment varialble.

SQL> set echo off;
SQL> set linesize 3999;
SQL> set feedback off;
SQL> set feedback off;
SQL> set termout off;
SQL> set pagesize 0;
SQL> spool mapping.txt
select C_SIM_MSISDN,C_SIM_IMSI from RCA_SMART_CARD order by C_SIM_MSISDN;

In ouput file , it look like

SQL> select C_SIM_MSISDN,C_SIM_IMSI from RCA_SMART_CARD order by C_SIM_MSISDN;
060010007 10007
:
:
:
SQL> spool off;

any setting or command that allow me to remove the first sql command line" SQL>select XXXX" and the last command "SQL>spool off" after start up the "spool mapping.txt"

View 8 Replies View Related

Client Tools :: Use Spool Command To Export Data For Other Purposes Within Application

Feb 1, 2012

I would like to use the Spool command to export data for other purposes within the application. We would like to use tab delimiter to seperate the fields but the client wants to know if the text datatype fields can be wrapped in double quotes along with the tab delimiter..

SQL>create table test (id number(2), first_name varchar2(15), last_name varchar2(15),var_no number(4),
type varchar2(1),type_no number(12));

Table created.

SQL> insert into test values(1,'mary','ross',132,'S',12);

1 row created.

SQL> insert into test values(3,'Sue','Bill',432,'S',12);

1 row created.

I tried the below spool command to use tab delimited for all the fields but not sure how to wrap double quotes for only the text fields and also would to have the column names in the 1st row but don't seem to get the full column name in the csv file.

set echo off
set feedback off
set linesize 1000
set pagesize 4000
set trim on
set headsep off
set colsep '' (used tab between the quote)

spool test.csv
select id,first_name,last_name,var_no,type,type_no from test;
spool off

View 10 Replies View Related

Client Tools :: How To Spool Clob Data Into Flat File

Oct 11, 2011

I want to spool CLOB data into flat file ?

View 6 Replies View Related

SQL & PL/SQL :: How To Export Package Body Using Spool Command

Jan 8, 2013

I am trying to Spool a Package Body into a file using sqlplus. I tried 2 days:

WAY1
SET LINESIZE 32000;
SET PAGESIZE 0;
SET TRIMSPOOL ON;
SET ECHO OFF;
SET TERM OFF;
SET FEEDBACK OFF;

[code]....

WAY2
.....
SELECT dbms_metadata.get_ddl( 'PACKAGE', 'SPI_xxxx_PCK', 'owner') FROM dual;
......

In Way1, I got different DDL or partial DDL. In Way2, I got only first 2 lines of Package body. I am running this command from Schema user only.

View 7 Replies View Related

Import Data From Dmp File Using Command IMPDP?

May 2, 2011

I am trying to import data from a dmp file using the command IMPDP Here is the command :

impdp
USERID= core_edb_20112_ct/local
DIRECTORY=dir_core20112
DUMPFILE=CORE_EDB_20112_CT_20110426.DMP
LOGFILE=log_core02112_1.log
SCHEMAS=core_edb_20112_ct
REMAP_SCHEMA=core_edb_20112_ct:core_edb_20112_ct
PARALLEL=4
METRICS=Y TRANSFORM=OID:N
TRANSFORM=SEGMENT_ATTRIBUTES:N
REMAP_TABLESPACE=C64_EDB_TS:C64_EDB_TS

I am trying to import data in the following user : core_edb_20112_ct/local
This user is already created , using the tablespace named C64_EDB_TS
The dmp file resides in the location dir_core20112 ( e:\oracle)

I am getting the following error while i try to import

Import: Release 11.2.0.1.0 - Production on Mon May 2 12:47:54 2011

Copyright © 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Produc
tion
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-31694: master table "CORE_EDB_20112_CT"."SYS_IMPORT_FULL_01" failed to load/
unload
ORA-02354: error in exporting/importing data
ORA-02368: the following file is not valid for this load operation
ORA-02369: internal number in header in file e:\oracle\core_edb_20112_ct_20110426.dmp is not valid.

The DMP is copied from a different network location into the local drive where the command is running.

View 1 Replies View Related

SQL & PL/SQL :: File Spool Using UTL_FILE

Apr 27, 2012

How to spool the Japanese characters in table using UTL_FILE. I tried with utl_file.fopen it's general,it's spooling. but i am not sure it this right way or not. in this case we need to change any character.

We can't see this characters in TOAD. Only possible in PLSQL developer

create table test1(name varchar2(1000),fname varchar2(1000))

insert into test1 values ('名を入力してください。','姓を入力してください。')

commit;

View 6 Replies View Related

PL/SQL :: Spool File With CTE Query?

Jul 10, 2013

I am using something like below , the query runs fine in oracle SQL developer.But I would like to generate a text file by running the script, so I added the Spool command, and those settings,

  I tried to run it in SQL developer or SQLplus, they both fail.In SQL developer: I got: ORA-00933: SQL command not properly ended00933. 00000 -  "SQL command not properly ended"*Cause:    *Action:Error at Line: 16 Column: 1,542In SQLPlus, but I got an error: SP2-0734: unknown command beginning "CteRace As..." - rest of line ignored.it seems it doesn't understand the common expression table. -- SQL code below:set heading offset feedback offset newpage noneset echo offset termout

[code]...

View 3 Replies View Related

Client Tools :: Add Application Name In A Spool File?

Jul 26, 2011

To add application name in a spool file, I am using the below way.

sqlplus username/pwd@tns @xyz.sql APP0115

SQL> define appname="'&1'"
Enter value for 1: APP0115
SQL> prompt &appname
'APP0115'
SQL> spool &appname._html_jobs.csv;
SP2-0768: Illegal SPOOL command
Usage: SPOOL { <file> | OFF | OUT }
where <file> is file_name[.ext] [CRE[ATE]|REP[LACE]|APP[END]]

But I am getting the above error in the spool file clause because of single quote printing infront of the spool file. But the method of defining a character is "'&1'". So I cannot avoid this single quote in the define clause.

'APP0115'

print the appname like APP0115 instead 'APP0115'.then only I can use this in the spool file clause?

View 3 Replies View Related

Globalization :: Spool Brazilian Characters To A File

Jun 6, 2013

Oracle version Oracle Database 11g Release 11.2.0.1.0 - 64bit Production running on CentOS Linux release 6.0 (Final), kernel 2.6.32-71.29.1.el6.x86_64.

I am having a hard time spooling a file and displaying special Brazilian characters, even though I can see them correctly in SQLDeveloper:
LEOPOLDO COUTO DE MAGALHÃES JÚNIOR

Spool:
LEOPOLDO COUTO DE MAGALH?ES JUNIOR

I've tried changing the NLS_LANG at the session level, but that cannot be done. I don't want to change the default language of my DB, but really need these characters to display correctly in a file.

View 16 Replies View Related

PL/SQL :: Spool File Output From Unix To Windows

May 22, 2013

I'm running a sql file in Unix (using SQLPLUS command) and i want the file output to be sent to local windows directory. I specified the windows directory name in my Spool command (Spool C:/<Directory Name> ) , But it is not working

Our Unix server is a FTP server but i don't want to FTP the spool file from unix to Windows as the spool file is Huge and it takes hours for the transfer to complete (and we have to run the script multiple times).

Is there a way i can have the spool file created in Local windows directory when i run my sql script in Unix?

View 5 Replies View Related

Client Tools :: Creating Spool File Dynamically

Aug 20, 2010

how to create a file in a folder based on todays date. i need to know how to define a variable in sqlplus and assign a value to it.Here is the code below. The code gets executed without creating a spool file.

DEFINE _DATE = replace('C:\_sysdate_EU001.csv', '_sysdate_', TO_CHAR(SYSDATE, 'DD-MON-YYYY'))
spool _DATE
set serveroutput on size 100000
select * from dual;
spool off

View 14 Replies View Related

Client Tools :: Spool Clob Column To A Flag File

Jul 15, 2013

I would like to spool a clob column to a flag file, however some of the clob are greater than 32k, and I have to have the same record in a single line in the file. Is there any way to achieve this through spooling?

set heading off
set feedback off
set term off
set long 1000000
set longchunksize 500000
set line 32767
set trimspool on
set pagesize 50000
spool file.txt
@--this is my select statement.
spool off
exit

View 1 Replies View Related

Client Tools :: How To Get SQL Query Output Into Text File Without Spool Statement

Mar 7, 2011

I would like to store my sql query output into text file.Like for example:

select name from emp where emp_id=101;
Here output should be in text file as
swapna.

I dont want to use spool statement here,since If I use it,spool statement will also be printed in text file which is not my requirement.I just want to take only output.

View 1 Replies View Related

PL/SQL :: Spool Data From Tables Into Flat Files

Oct 23, 2012

I am trying to spool data from tables into flat files. I am using the following scripts to accomplish it

1. A cmd file (windows) that makes a call to a sql file
2. The SQL file which generates another query file at the run time, depending upon the table name passed to it
3. The run time query file , that executes the final query and spools the data into a txt file | delimited

For e.g. :

Actual command passed C:Spool_utilityspool_utility TABLE_NAME

E.g. of the spool utility file :

@echo off

SET dbuser=XX@YY
SET dbpw=xxxx

echo %date% - %time% - Start > %1%log.txt

echo START

sqlplus -s %dbuser%/%dbpw% @spool_utility.sql %1>%1.txt

echo %date% - %time% - Done >> %1%log.txt
echo DONE

E.g. of the spool_utility.sql

set echo off
SET newpage 0
SET feedback off
SET linesize 32767
set pagesize 0
[code]........

The above file generates a table_name.sql file with the actual table name at run time and gets executed and the output is written to the table_name.txt file.

This works perfectly fine. But the issue is when someone passes some wrong table name or if there is a actual run time error while executing the query , the error with details itself itself gets written to the end spool file.

For e.g. : if i do this just to generate an error and execute it from command line, the query generates an error and writes the error to the spool file , but at the command prompt where I executed the command I do not see any error and the process seems to have run perfectly well

set xxx on xxx off as above

spool &1.sql;

Prompt Select * from &1 where rownum><10---this will cause the issue

spool off
set termout ON
@ &1

EXIT

Eg of spool file generated :

from     table_name WHERE rownum><=10 *
ERROR at line 62:
ORA-00936: missing expression

My question is, is there any way i can capture this runtime error and return this error to my calling sql script spool_utility.sql and then propagate it to the calling command file and do some tasks for eg removing the spool file and writing the actual error to a log file . Basically any way to know at my OS calling level that the entire spooling operation was unsuccessful.

View 8 Replies View Related

Client Tools :: Dynamically Spool Data In PL/SQL Block?

Nov 22, 2012

I have a master table A that has 10+ columns along with data and a configuration table B that has only 2 columns i.e table name and column name. For ex:-

Table A:-

C1 C2 C3 C4 C5 C6
-- -- -- -- -- -----
1 2 3 4 3 6
4 5 6 5 5 5

Table B:-

Table_Name Column_Name
--------- ----------
A C1
A C2
A C3

Now I need to write a sql script that should take the table A Columns defined in Table B and then based on the columns it should spool the columns output from Table A.

For above ex:- I need to spool the C1,C2,C3 columns data from Table A in to some Unix path using SQL SCRIPT.

View 2 Replies View Related

SQL & PL/SQL :: Remove Data Recently Loaded But Not Disturbing Existing Original Data?

Jun 24, 2010

I have few tables in Oracle 9i/10g , and they already have data in them. I am trying to migrate the data coming from various source systems into these Oracle tables. There is a chance that after loading I might get some unwanted data into these tables.

How do I remove just that data which I have loaded recently, and do not disturb the original data it already has.

Need to backup those tables and reload the data back if there is any problem, but I am looking at a different approach. I just don't want to change the existing system, as lot of users use the system.

View 8 Replies View Related

Forms :: How To Call Batch File Existing In Network Path Through 6i

Aug 10, 2011

How to call a batch file existing in network path through oracle forms 6i. I am using following code in Forms 6i which is supposed to FTP some .text files to a UNIX box.

Host( '\guww.netdfs.root.Global Shared Data$(LEV)Leven Shared DataLeven Shared DataPublicCOMMONMatsEmpty Bottle ReportsSchedules Preliminaryftp_files_to_ddd.bat');

When I am running this batch file ftp_files_to_ddd.bat from local directory of my PC,it is working properly.

View 1 Replies View Related

Server Utilities :: Overwrite Existing Dump File In Expdp In Oracle 10g?

Apr 13, 2012

How we can overwrite existing dump file for expdp in oracle 10g because everytime we excute expdp and dmp file exist we get below error

ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31641: unable to create dump file "C:scott_emp.dmp"
ORA-27038: created file already exists
OSD-04010: <create> option specified, file already exists

We have one feature in 11g reuse_dumpfiles=y ,which doesnt work in 10g, I want something which can overwrite existing dumpfile in 10g?

View 1 Replies View Related

Forms :: Command To Run SQL File?

Mar 8, 2011

i want to run sql file by forms...is there command do that

View 3 Replies View Related

Which Command Use To Set File Storage In Oracle

Oct 26, 2006

I am new to oracle which command do I use to set the file storage in oracle? I learnt the we have the option of specifying the storage pattern as per our queries.

View 2 Replies View Related

SQL & PL/SQL :: Generate Command To Rename Log File From ASM To Non-ASM

Apr 9, 2013

I am in the process of recovering a database from an ASM environment to a non-ASM environment using RMAN. I've got a query to generate the command to RENAME the file:

SELECT 'ALTER DATABASE RENAME FILE '''||MEMBER||''' TO '''||'/u01/data/dev'||
SUBSTR(MEMBER,
INSTR(MEMBER, '/', -1, 1),
INSTR(MEMBER, '.', 1, 1) - INSTR(MEMBER, '/', -1, 1)) ||
DECODE(SUBSTR (MEMBER, 1, INSTR(MEMBER, '/', 1, 1) -1), '+DATA', 'a', '+FRA', 'b', 'c') ||'.log'';'
FROM V$LOGFILE;

When I run the query, this is an example of the result I get:

ALTER DATABASE RENAME FILE '+FRA/db1/onlinelog/group_3.259.766075171' TO '/u01/data/dev/group_3b.log';
ALTER DATABASE RENAME FILE '+DATA/db1/onlinelog/group_1.262.766075829' TO '/u01/data/dev/group_1a.log';

But I want to replace the "group" with "redo" and get the below result:

ALTER DATABASE RENAME FILE '+FRA/db1/onlinelog/group_3.259.766075171' TO '/u01/data/dev/redo_3b.log';
ALTER DATABASE RENAME FILE '+DATA/db1/onlinelog/group_1.262.766075829' TO '/u01/data/dev/redo_1a.log';

View 7 Replies View Related

SQL & PL/SQL :: BFILENAME / Unable To Get The File Using The Command?

Oct 16, 2012

i am using a SQL statement as below but unable to get the file using the command :

SELECT bfilename('$APPLCSF/out','XXMSPOSTD_3798178_1.pdf') FROM dual;

View 6 Replies View Related

SQL & PL/SQL :: Redirect Output Of A Command To Variable Or File?

Jun 18, 2010

I have a command which get the versions of the schema's for which I dont have access to. It is a utility.

the command goes:

SQL>EXEC ite_dta_tool.dta_open_utl.get_db_version('HH2_SGH21_SS')
DATABASE_VERSION_ID
-----------------------
hh2_ax_db_0.8.1.2.0
Elapsed: 00:00:00.25
SQL>

'HH2_SGH21_SS' is a schema I dont have access to. I have a whole bunch of schemas like this and would like to get versions of all those schemas putting it in a loop in pl/sql.

1: whats the best way get this output to a variable.

2: whats the best way to get the output to a file.

View 8 Replies View Related

Data Guard :: ORA-01354 / Supplemental Log Data Must Be Added To Run This Command

May 2, 2012

I configure logical standby online .when I execute dbms_logstdby.buid,first

SQL> EXECUTE DBMS_LOGSTDBY.BUILD;

it was blcoked by other sesson,then i kill the holding session,but no work.then i cancel this step and execute it again . the error is

SQL> EXECUTE DBMS_LOGSTDBY.BUILD;
BEGIN DBMS_LOGSTDBY.BUILD; END;
*
ERROR at line 1:
ORA-01354: Supplemental log data must be added to run this command
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 3669
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 3755
ORA-06512: at "SYS.DBMS_LOGMNR_D", line 12
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_INTERNAL_LOGSTDBY", line 370
ORA-06512: at "SYS.DBMS_LOGSTDBY", line 157

[code]....

View 3 Replies View Related

Inserting Restriction By Existing Data

Nov 8, 2010

In my organization, I have a table and in that there is a column named "code".I want to restrict some insertion to that particular column. suppose that code column values are 12 and 1245 then i cant insert the value 12,1245, 1 ,124 and so on but i can insert 2 ,123,15,12456 and so on.

that means the new values should not be any substring of the existing data from left. making that column primary key and then I had a logic to compare the existing value which are longer than the new value and then to perform this.But dont know how to make it happen correctly.

View 2 Replies View Related

Server Utilities :: Load / Unload Csv File Using Sql Command?

Apr 5, 2010

load/unload csv file using sql command

View 1 Replies View Related

Windows :: How Search Specific String In PDF File From Command Prompt

Nov 21, 2012

I have a requirement in which i have list pdf files(from thousands of pdf files) having particular string from a command prompt.I have tried find command but that has some limitation. its working upto 3 digit string only.how can i acheive this.remember i have to do this through command prompt only.

View 1 Replies View Related

Backup & Recovery :: 11g R2 - How To Update Control File With Switch Command

Oct 3, 2011

I have restored all datafile to new location (that is ASM) earlier it was on file system using set new name command (RMAN). Now when i'm trying to update control file with swicth command it is prompting error. Version is 11g R2.

RMAN> SWITCH DATAFILE ALL;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "all": expecting one of: "double-quoted-string, integer, single-quoted-string"
RMAN-01007: at line 1 column 17 file: standard input

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved