How to make comma seperated file
hi
I have a select statement that looks like below. I want to make comma seperated file for the selected columns. How to write it?
SELECT MM.DAL_NUMBER,
'19-NOV-2009' as WSS_CE,
CPN_INT,
TRADE_DATE,
MX_DATE "LAST_DATE",
CUSTOMER_SPECIF CUST_GID,
NAME_SHORT CUST_NAME_SHORT
from my_table;
if you could provide me with exact query.
Thanks
Slightly more generic approach...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required.
Similar Messages
-
9iJSP Report output to a comma seperated file
Hi,
Is it possible to create a comma seperated file with output data from a 9iJSP report. If yes, can anyone tell me how ??
thanks in advance
UnmeshHello Unmesh,
If your JSP report has a paper layout, then you can use Reports Builder or the client/servlet/runtime executables to generate the paper layout to CSV formatted output with the DESFORMAT=DELIMITEDDATA and DELIMITER=, command-line options. If you have only a web layout , it will generate its output only in HTML format.
You can add a paper/web layout to your JSP report, if it already doesn't have one, by opening it in Reports Builder, and inserting a report block in the paper layout view/web source view. This JSP report can then be used both to generate to CSV format using rwservlet, and to the web when deployed as a JSP.
Thanks,
The Oracle Reports Team. -
I am trying to read in data from a .CSV file.
The CSV file contains a list of questions and answers in the
format;
Question, option1, option2,option3,option4, correct answer
My problem is that I can get the whole line into an array but
I can't find a way of getting each element of the comma seperated
file into a multi dimensioned array.
I need to be able to use MyArray[1,1] is equal to
Question and MyArray[1,2] is equal to
option1 etc etc
Hope this makes sense
PaulIn your routine you have two loops.
Either one will work on thier own but as soon i nest them
then it just stops working........
The below data is stored as a Data.csv file (Obviously it
contains a lot more these are the first 3 records.) **Can't count =
4 records lol)
,,B,,,,Lorry,,,,,X,,,,,CC5001 ,Mark one answer,,under 7.5
tonnes maximum authorised mass,over 7.5 tonnes maximum authorised
mass,over 7.5 metres overall height,under 7.5 metres overall
height,,,1111,This sign means no entry for goods
vehicles,TS4619.eps,CC5001.gif ,Vehicle Weights and Dimensions
,,B,,,,Lorry,,,,,X,,,,,CC5002 ,Mark one answer,,either the
left-hand or middle lane,only the left-hand lane,only the middle
lane,any of the lanes,,,1111,Your lorry is over 7.5 tonnes maximum
authorised mass. This sign means you may use,TS4545.eps,CC5002.gif
,Vehicle Weights and Dimensions
,,C,,,,Lorry,,,,,,X,,,,CC5003,Mark one answer,,30 mph,40
mph,50 mph,60 mph,,,1111,You are driving a lorry with a maximum
authorised mass of 7 tonnes. What is the maximum speed limit on a
single carriageway?,,,Vehicle Weights and Dimensions
,,B,,,,Lorry,,,,,X,,,,,CC5004,Mark one answer,,30 mph,40
mph,50 mph,60 mph,,,1111,What is the national speed limit on a
single carriageway road for a rigid lorry weighing more than 7.5
tonnes maximum authorised mass?,,,Vehicle Weights and
Dimensions -
Create datastore for complex comma seperated file
I am trying to integrate a comma seperated file to an Oracle database. The files contain multiple record types each of which have different number of fields and a different order of datatypes within those fields. The order that the records types are listed in the file determines the relationship between them, e.g.
The file could contained the following record types in the order shown:
Segment
Fixture
Position
Position
Segment
Segment
Fixture
Position
Position
Position
So there is a parent-child relationship between the Segement record and the Fixture record that immediately follows it and similarly the position records are child records to the Fixture record.
How can I create datastores that represents this relationship when there is no parent field in the child record types?I dont think ODI would be able to help you much with Out of the box functionality. You will need to modify the LKM (SQLLDR) to achieve this.
The following entry illustrates the logic:
[http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7526680049479]
Hope that helps -
Comma seperated file uploading
Hi ,
i want to upload comma seperated file into sap.
iam using 'GUI_UPLOAD' fm.
problem is flat file currency field it is also contains comma.
i can't change file type comma to tab.
How can i upload currency fields with comma.
Regards,
Suresh.You can upload your file into a string table. Now split it:
split uploadtab at ',' into table items.
if you have
a,b,c,11,d,e,f
your tables items contains 7 elements now.
if you have
a,b,c,11,22,d,e,f
your table contains 8 elements now. In that case you now that you have splitted a number with a comma and need to do some actions, e.g. merge elements 4 and 5 together to get 11,22 again and shift the 6th to 5th, the 7th to 5th and the 8th to 7th element.
After that you number is again in item 4.
An easier way is to enforce you customer to put values into apostrophes or quotes. If this is not possible, you have to check if an unwanted split was taken in place and act as shown above.
But: this will work only if one item with a comma in between. If oyu have more components you can not evaulate where the unwanted split is in effect. -
Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.The Oracle documentation has a good overview of the options available
Generating XML Data from the Database
Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
You can also find some information in XML DB FAQ -
How to make a jar file from a java file?
how to make a jar file from a java file, is there any one tht can help me thank you;
You can study this.
http://java.sun.com/docs/books/tutorial/jar/basics/index.html -
Generate an Upload the current table to a comma seperated file
Hi Freaks,
i want to generate a comma seperated file from the current table (which was modified in the current Apex Window) and also upload the file to a file server.
What is the best practice?
Thanks a lot
WolleHello Wolle,
In the APEX SQL Workshop -> Object browser, when you select a table, and select the Data tab. There's a link at the bottom of the table, "Download". This will automatically generate a csv file for you.
Alternatively you can use a client like toad or sql developer to generate a csv.
Greetings,
Rutger
http://rutgerderuiter.blogspot.com/
===============================================================================
You can reward this reply by marking it as either Helpful or Correct ;-) -
Is there a way that I can bring a comma seperated file into an oracle table?
If you are using Oracle 9i and above, you may also want to consider using external tables.
http://download-west.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90192/ch11.htm#1656 -
How to make a .sda file?
I remember that I read somewhere about how to make a .sda file
from other files. But I cannot recall.
Would you please give some hint? Thanks!Thanks!
I am referring to note 897289. Please have a look, thanks!
Seems that you can rename the generated zip file to sda file. Is that true?
About inolving portal: how to you export some files sitting on your folder?
Please explain more.
Regards! -
Hi dear
i have a JSp file Now problem is that my server dosent support JSP file
So i ahve to make a WAR file
So can u tell me how to make a WAR file.
i am using TOMCAT 5.5.9 & Orion serveruse an ide and deploy the webapp
like
- netbeans
- Jbuilder
- eclipse
- sun one studio
or google like :
http://www.google.com.au/search?hl=en&q=creating+war+%2B+jsp&btnG=Search&meta=
and get as first hit
http://access1.sun.com/techarticles/simple.WAR.html
regs
g00fy -
Send mail as comma seperated file from abap
Hi,
i need to send mail from my program...as a comma seperated file...can u help me out.
regards
shankarSee function module SO_NEW_DOCUMENT_ATT_SEND_API1, there is an example in the documentation. The example is for a .BMP file but you should be able to use the similar code for a text file (you might need to use object RAW). The content of comma-separated file must be in an internal table when you'll call this function module.
There are also lots of examples available all over the Internet, use search by FM name. -
How to make a PDF file short ( with less memory)?
How to make a PDF file short ( with less memory)?
@nalinss
There are two ways: "Save as.." usually optimises size, but there is also "Optimize PDF" in the menu with many options what to exclude and to reduce in quality. Be careful here, as pictures can become very bad.
A note: the size of a PDF vastly depends on from what source it is created. For example, if you draw some vector graphics in Visio and print to Adobe Printer, the resulting PDF is usually quite small in file size. Opening it in Illustrator and saving it again after you, let's say, just moved one line, can make it 10x as big. This is due to big overhead, Illustrator creates and this can not be reduced anymore in Acrobat later on. Sometimes it helps to convert or "save as" such an inflated PDF to a different format like EPS or HTML and print or convert again to PDF.
So, if you created the PDF yourself and you still have the source, you may adjust settings in the export/print dialog to make it smaller. -
Hai Sir,
I am facing one problme in weblogic8.1 while depolying the .EAR FILE.
Please help me sir.
Case1) 1) I am using the struts and log4j frameworks and 3rd party jar files with
weblogic8.1.
2) I make the ejbs,webapplications and 3rdparty jar files, ear file the following
dir structure .And i mentioned the Class-path including all jar files in the MANIFEST
OF EAR FILE.
While deploying the ear file it is giving following error.If log4j.jar does not
mention in the Weblogic script file
java.lang.NoClassDefFoundError: org/apache/log4j/Priority
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:1494)
at java.lang.Class.getDeclaredFields(Class.java:1073)
at weblogic.ejb20.deployer.EJBModule.disableImplClassLoader(EJBModule.java:1082)
at weblogic.ejb20.deployer.EJBModule.setupEJBToImplClassDependencies(EJBModule.jav
a:982)
at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:419)
at weblogic.j2ee.J2EEApplicationContainer.prepareModule(J2EEApplicationContainer.j
ava:2792)
at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.
java:1478)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:11
36)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:97
5)
at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareCon
tainer(SlaveDeployer.java:2571)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(Sla
veDeployer.java:2523)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeploy
er.java:2453)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer
.java:820)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:
536)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java
:494)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:
25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
Please provide the soluation without mentioning classpath in the weblogic script
.How to make the EAR file incliding ejbjar,webapplication and 3rd party jar files.
Thanks & Regards,
ASHOK SAMRAT
[email protected]Refer to the section
Handling Utility classes
http://dev2dev.bea.com/products/wlserver/articles/musser.jsp
thanks,
Deepak
"Ashok Samrat" <[email protected]> wrote:
>
Hai Sir,
I am facing one problme in weblogic8.1 while depolying the .EAR FILE.
Please help me sir.
Case1) 1) I am using the struts and log4j frameworks and 3rd party jar
files with
weblogic8.1.
2) I make the ejbs,webapplications and 3rdparty jar files, ear file
the following
dir structure .And i mentioned the Class-path including all jar files
in the MANIFEST
OF EAR FILE.
While deploying the ear file it is giving following error.If log4j.jar
does not
mention in the Weblogic script file
java.lang.NoClassDefFoundError: org/apache/log4j/Priority
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:1494)
at java.lang.Class.getDeclaredFields(Class.java:1073)
at weblogic.ejb20.deployer.EJBModule.disableImplClassLoader(EJBModule.java:1082)
at weblogic.ejb20.deployer.EJBModule.setupEJBToImplClassDependencies(EJBModule.jav
a:982)
at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:419)
at weblogic.j2ee.J2EEApplicationContainer.prepareModule(J2EEApplicationContainer.j
ava:2792)
at weblogic.j2ee.J2EEApplicationContainer.prepareModules(J2EEApplicationContainer.
java:1478)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:11
36)
at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContainer.java:97
5)
at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.prepareCon
tainer(SlaveDeployer.java:2571)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.createContainer(Sla
veDeployer.java:2523)
at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.prepare(SlaveDeploy
er.java:2453)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer
.java:820)
at weblogic.management.deploy.slave.SlaveDeployer.prepareDelta(SlaveDeployer.java:
536)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java
:494)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:
25)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
Please provide the soluation without mentioning classpath in the weblogic
script
How to make the EAR file incliding ejbjar,webapplication and 3rd party
jar files.
Thanks & Regards,
ASHOK SAMRAT
[email protected] -
How to store Comma Seperated Value in a File with Jsp
Hai friends,
I need to get all the filed values like Empname,salary ,location..........
and at the end of jsp page i have to put a browse button when i choose a file using theis browse button the total content in the form shoud store in that file as comma seperated values.1. Create JSP
2. When you click the button call the event that saves the data in CSV format
Your question is so broad, I don't have exact answer for you.
What have you done so far?
The man with blues.
Maybe you are looking for
-
Highlighting text box for multiple choice presentation.
I'm making a multiple choice presentation and need help highlighting the correct answers. I'm using Keynote v5.3 and here is the format of my slides: Text box - Question Text box - (A) Answer A Text box - (B) Answer B Text box - (C) Answer C Text box
-
Internal order and its Position ID
Hello, After creating an Internal Order (IO) we will assign in IM22 (like Specified, clubbed, project. Now i want to know which IO is assigned to which node any table for that?
-
I am having trouble figuring out how to create a horizontal scrollbar component either by itself or nested inside a data list component that will have it's thumb centered in the track when running and reveal content from either the right or left side
-
Error 1335 Installing Acrobat XI on Bootcamp Macbook Air
I have tried the solutions on the Adobe web site and none work. I am unable to get the Akami downloader to work, so I use the alternative downloader (I have downloaded 6 different times). Every time get the file downloaded, and then run the setup,
-
This is likely a very basic question.... I've got a new Cisco ASA5505 and I'm trying to see some logs at console level. Currently when I do a sh logging I simply get the below. I was expecting or I have seen on other PIX/ASA's system messages. Any id