SQLLDR: (CTL file) How to ONLY load 1 record of the CSV file
Hello,
We are in 11g, and we get CSV data.
I'd like to know if there is a way in the CTL file to specify that I only want to load first row ?
I know how to do it if there is a common unique value in the first row (WHEN myColumn = 'value1' )
BUT, in that case, first row doesn't hold any specific value, and I think that I have to tell the loader to take only first row.
I hope it is clear.
Here is the CTL, in the case we can get a specific value for first row:
LOAD DATA
CHARACTERSET WE8ISO8859P1
APPEND
CONTINUEIF LAST != ";"
INTO TABLE IMPORT_FIRST_LINES
WHEN COL_3 = 'firstRowValue'
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
( COL_1 CHAR
, COL_2 CHAR
, COL_3 CHAR)
{code}
So, I think I need to change the *WHEN clause*.
I hope it is clear enough for you to understand.
Thanks in advance,
Olivier
just change the control file like this,
LOAD DATA
CHARACTERSET WE8ISO8859P1
APPEND
CONTINUEIF LAST != ";"
INTO TABLE IMPORT_FIRST_LINES
WHEN COL_3 = 'firstRowValue'
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
( COL_1 CHAR
----------- if you only want to load 1st column of csv file to first column in table.
Similar Messages
-
To create 5 different files in target for each record in the sender file
Hi SapAll,
i have got a a requirement where pi need to create 5 different files with data of each record from the sender side.
Its an file to file scenario
suppose there are 5 rows in a file , then in target side i need to create 5 diff with each one record in it.
Can we do it without using 3 comm channels
Thanks®ards,
SaiHey,
As a more generic solution, can you try using MultiMapping. It is supposed to generate multiple instances of messages on receiver side.
/people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
You just need to put a simple logic in Message Mapping to generate new Node for every occurence of source field.
Thanks
Aamir -
How to asssign output value in the CSV file for the specific header
Hi,
I am using OpenScript 9.10. The problem I am facing is that, to Write the Output value captured from the application, When i am trying to use the methods "Appen String to File" i am unable to write / assign the out put value below the specific header. Can any one please look into this and post the methods related to Write the output vaues in to the CSV files under specific headers.
Thanks in Advance.
Thanks.,
SivaHi Alex,
Thanks for your reply.I need to write the output value under specified parameter name.
for example after creating the sales order,the order number have to write in the CSV file under
OrderNumber column.I tried with appendStringtofille() method,by using this able to write the value under
first column.But i need to write output value under specified columnname(means Header name in the cSV
file).can u please give a reply for the above problem.
Note: In that Csv file i am taking the input vales and also need to write the output values under
specified column(header)
Thanks,
Siva Thota. -
SQLLOADER fails to load space from the CSV file
Hello,
-- I am using sqlloader to load tables(Release 10.2.0.4.0)
--- I have actual spaces in my CSV files, which i want to load as it is in the tables.
--- However, sqlloader loads "nulls" instead.
--- Please help.Vishal,
Use this and you should be able do this, I am attaching a working example based your input data
Table: Layout
create table layout (
col1 varchar2(10),
col2 varchar2(100),
col3 varchar2(10)
);# Control file: layout.ctl
LOAD DATA
REPLACE PRESERVE BLANKS INTO TABLE KLONDIKE.LAYOUT
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
col1 char(10),
col2 char(100),
col3 char(10)
{code}
Loading from command line
{code}
C:. sqlldr username/password control=layout.ctl data=layout.txt log=layout.log
{code}
Verfiy using following sql that data loaded with one white single whitespace
{code}
select layout.* , length(col2) from layout;
{code}
Regards
Edited by: OrionNet on Mar 28, 2009 12:09 PM -
File Adapter - Multiple fixed length records in the same file
Hi
I am developing a BPEL process that "Sync Read" a file. The file is a flat file comprising of multiple records and each record is of fixed length. There are no delimiters in the file. I got the xsd associated to this flat file and each element is defined with some fixed length and starting position. The xsd is valid.
When I execute the BPEL Process, I get the following error - I verified the file structure and the position of the fields map correctly. Remember this is not an xml file just a plain text file. Can BPEL process such files or should I always provide an "xml" file?
<bpelFault><faultType>0</faultType><bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="detail"><detail>Start of root element expected.</detail></part><part name="summary"><summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'SynchRead' failed due to: Error while translating. Translation exception. Error occured while translating content from file /tmp/inputDir/VDA1.txt ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary></part><part name="code"><code>null</code></part></bindingFault></bpelFault>
Thanks
Shanthihi,
see you actually read a XML file and when you read it it is verified by a XSD the location of the XSD is in the XML file it self,
<tns:abc xmlns:tns="http://xmlns.int.aaa.co.uk/xmlns/BPELXXX"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.int.aaa.co.uk/xmlns/BPELXXX *c:/aaa/bbb/ccc/XSD/abc.xsd*">
if the file you are reading is valid then it is read, other wise not, I am not sure about sys read, but in empty BPEL process, if the XML is not validated with the XSD, then the XML is not read, I am still not sure what is the meaning of flat file, are you doing a opaque read?
Yatan -
How to read some records from a text file into java(not all records)
hello,
how to read text files into java. i need only few records from the text file not all records at a time.
If any one knows plz reply me
my id is [email protected]this snipet reads a text file line by line from line 1 to 3
try {
FileReader fr = new FileReader(directory);
BufferedReader br = new BufferedReader(fr);
int counter = 0;
while ((dbconn = br.readLine()) != null) {
switch(counter){
case 0:
status = dbconn;
break;
case 1:
userName = dbconn;
break;
case 2:
apword = dbconn;
break;
counter++;
br.close();
}catch(IOException e){
} -
How to write the JTables Content into the CSV File.
Hi Friends
I managed to write the Database records into the CSV Files. Now i would like to add the JTables contend into the CSV Files.
I just add the Code which Used to write the Database records into the CSV Files.
void exportApi()throws Exception
try
PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
System.out.println("Connected");
stexport=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rsexport=stexport.executeQuery("Select * from IssuedBook ");
ResultSetMetaData md = rsexport.getMetaData();
int columns = md.getColumnCount();
String fieldNames[]={"No","Name","Author","Date","Id","Issued","Return"};
//write fields names
String rec = "";
for (int i=0; i < fieldNames.length; i++)
rec +='\"'+fieldNames[i]+'\"';
rec+=",";
if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
writing.println(rec);
//write values from result set to file
rsexport.beforeFirst();
while(rsexport.next())
rec = "";
for (int i=1; i < (columns+1); i++)
try
rec +="\""+rsexport.getString(i)+"\",";
rec +="\""+rsexport.getInt(i)+"\",";
catch(SQLException sqle)
// I would add this System.out.println("Exception in retrieval in for loop:\n"+sqle);
if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
writing.println(rec);
writing.close();
}With this Same code how to Write the JTable content into the CSV Files.
Please tell me how to implement this.
Thank you for your Service
JofinHi Friends
I just modified my code and tried according to your suggestion. But here it does not print the records inside CSV File. But when i use ResultSet it prints the Records inside the CSV. Now i want to Display only the JTable content.
I am posting my code here. Please run this code and find the Report.csv file in your current Directory. and please help me to come out of this Problem.
import javax.swing.*;
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
public class Exporting extends JDialog implements ActionListener
private JRadioButton rby,rbn,rbr,rbnore,rbnorest;
private ButtonGroup bg;
private JPanel exportpanel;
private JButton btnExpots;
FileReader reading=null;
FileWriter writing=null;
JTable table;
JScrollPane scroll;
public Exporting()throws Exception
setSize(550,450);
setTitle("Export Results");
this.setLocation(100,100);
String Heading[]={"BOOK ID","NAME","AUTHOR","PRICE"};
String records[][]={{"B0201","JAVA PROGRAMING","JAMES","1234.00"},
{"B0202","SERVLET PROGRAMING","GOSLIN","1425.00"},
{"B0203","PHP DEVELOPMENT","SUNITHA","123"},
{"B0204","PRIAM","SELVI","1354"},
{"B0205","JAVA PROGRAMING","JAMES","1234.00"},
{"B0206","SERVLET PROGRAMING","GOSLIN","1425.00"},
{"B0207","PHP DEVELOPMENT","SUNITHA","123"},
{"B0208","PRIAM","SELVI","1354"}};
btnExpots= new JButton("Export");
btnExpots.addActionListener(this);
btnExpots.setBounds(140,200,60,25);
table = new JTable();
scroll=new JScrollPane(table);
((DefaultTableModel)table.getModel()).setDataVector(records,Heading);
System.out.println(table.getModel());
exportpanel= new JPanel();
exportpanel.add(btnExpots,BorderLayout.SOUTH);
exportpanel.add(scroll);
getContentPane().add(exportpanel);
setVisible(true);
public void actionPerformed(ActionEvent ae)
Object obj=ae.getSource();
try {
PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
if(obj==btnExpots)
for(int row=0;row<table.getRowCount();++row)
for(int col=0;col<table.getColumnCount();++col)
Object ob=table.getValueAt(row,col);
//exportApi(ob);
System.out.println(ob);
System.out.println("Connected");
String fieldNames[]={"BOOK ID","NAME","AUTHOR","PRICE"};
String rec = "";
for (int i=0; i <fieldNames.length; i++)
rec +='\"'+fieldNames[i]+'\"';
rec+=",";
if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
writing.println(rec);
//write values from result set to file
rec +="\""+ob+"\",";
if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
writing.println(rec);
writing.close();
catch(Exception ex)
ex.printStackTrace();
public static void main(String arg[]) throws Exception
Exporting ex= new Exporting();
}Could anyone Please modify my code and help me out.
Thank you for your service
Cheers
Jofin -
How to write the char value as is in the CSV file
Hi Everyone,
I am creating csv files which contains inventory details for all the products. I am able to create the csv file with utl file concepts. My problem starts after the csv file is being created.
some of the product numbers(Though I am saying Product number, it is varchar2 data type in the table) is like this 3E-12, 3E-54 and so on. I have totally 23 product numbers like this.
When the user opens the csv file it is changing to numbers like this 3.00E-12, 3.00E-54. I want to keep the product number as it is like char value. I tried many quoting and concat methods.
But none of them works for me.
I am using oracle 9i.
Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production
Please help me to solve this problem.
Thanks in advance,
Vimal...Hi Friends,
Thanks for the immediate response. Here is my code.
CREATE OR REPLACE PROCEDURE DATA_TO_CSV_FILE
IS
l_file_ptr UTL_FILE.file_type;
l_hdr_text VARCHAR2 (4000);
l_dynamic_sql_str VARCHAR2 (4000);
TYPE l_dynamic_sql IS REF CURSOR;
l_dynamic_cursor l_dynamic_sql;
l_org_id_select VARCHAR2 (200);
l_master_org_id NUMBER;
l_category VARCHAR2 (40);
l_itemno VARCHAR2 (40);
l_description VARCHAR2 (240);
l_brand VARCHAR2 (240);
l_organization_id NUMBER;
l_oh NUMBER;
l_status apps.mtl_system_items.inventory_item_status_code%TYPE;
BEGIN
l_file_ptr := UTL_FILE.fopen ('CSV_DIR', 'inventory.csv', 'w');
l_dynamic_sql_str :=
'SELECT mc.segment2 CATEGORY, itm.segment1 itemno '
|| 'itm.description description, LOG.brand brand,'
|| 'NVL (m.oh, 0) oh'
|| '(select msi.inventory_item_status_code from apps.mtl_system_items msi'
|| ' where msi.inventory_item_id = itm.inventory_item_id'
|| ' and msi.organization_id = '
|| l_master_org_id
|| ' ) status '
|| ' FROM xxx_custom_table m,'
|| ' apps.mtl_item_categories ic,'
|| ' apps.mtl_categories_b mc,'
|| ' apps.mtl_system_items itm,'
|| ' xxx_custom_table1 LOG,'
|| ' xxx_custom_table2 cap'
|| ' WHERE m.item_id(+) = itm.inventory_item_id'
|| ' AND m.org_id(+) = itm.organization_id'
|| ' AND itm.segment1 = cap.itemno(+)'
|| ' AND itm.inventory_item_id = ic.inventory_item_id'
|| ' AND itm.organization_id = ic.organization_id'
|| ' AND ic.category_id = mc.category_id'
|| ' AND mc.segment2 IS NOT NULL'
|| ' AND itm.inventory_item_id = LOG.inventory_item_id'
|| l_org_id_select
|| ' GROUP BY mc.segment2,'
|| ' itm.segment1,itm.inventory_item_id,itm.description,'
|| ' LOG.brand,LOG';
OPEN l_dynamic_cursor FOR l_dynamic_sql_str;
LOOP
FETCH l_dynamic_cursor
INTO
l_category, l_itemno, l_description, l_brand, l_status,l_oh;
EXIT WHEN l_dynamic_cursor%NOTFOUND;
UTL_FILE.put_line (
l_file_ptr,
l_CATEGORY
|| ','
|| l_itemno
|| ','
|| l_description
|| ','
|| l_status
|| ','
|| l_brand
|| ','
|| l_oh
END LOOP;
UTL_FILE.fclose (l_file_ptr);
END;
Hey damorgan,
Can you please give me little more detail about your workaround method. I think I did the ODBC Connection Once for MS ACCESS database. I
hope you are taking about the same method.
Thanks
Vimal.... -
Need to take a value from the csv file and query in a OAF page.
Hello,
I have a requirement to take the list of employee numbers in a csv file and display its corresponding job on the page.
I have created a item 'MessageFileupload' where the user will upload the csv file containing the employee number and a Button 'Display Jobs' which will display the corresponding jobs on the page.
Any idea how to take the values from the csv file and query it?
Regards,
den123.Hi ,
Check
http://oraclearea51.com/contribute/post-a-blog-article/csv-file-upload-for-oa-framework.html
http://www.roseindia.net/jsp/upload-insert-csv.shtml
Below code works from above blogs.
package xx.oracle.apps.pa.Lab.webui;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// import java.io.*;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.jbo.domain.BlobDomain;
import oracle.cabo.ui.data.DataObject;
import oracle.jbo.Row;
* Controller for ...
public class deptCsvUploadCO extends OAControllerImpl
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
// Code Addition Started for CSV upload
OAApplicationModule am = (OAApplicationModule) pageContext.getApplicationModule(webBean);
OAViewObjectImpl vo = (OAViewObjectImpl) am.findViewObject("deptCsvVO1");
//if ("GoBtn".equals(pageContext.getParameter(EVENT_PARAM)))
if (pageContext.getParameter("GoBtn") != null)
System.out.println("Button Pressed");
DataObject fileUploadData =(DataObject)pageContext.getNamedDataObject("FileUploadItem");
String fileName = null;
String contentType = null;
Long fileSize = null;
Integer fileType = new Integer(6);
BlobDomain uploadedByteStream = null;
BufferedReader in = null;
try
fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
contentType =(String)fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, fileName);
in = new BufferedReader(new InputStreamReader(uploadedByteStream.getBinaryStream()));
fileSize = new Long(uploadedByteStream.getLength());
System.out.println("fileSize"+fileSize);
catch(NullPointerException ex)
throw new OAException("Please Select a File to Upload", OAException.ERROR);
try{
//Open the CSV file for reading
String lineReader="";
long t =0;
String[] linetext;
while (((lineReader = in.readLine()) !=null) )
//Split the deliminated data and
if (lineReader.trim().length()>0)
System.out.println("lineReader"+lineReader.length());
linetext = lineReader.split(",");
t++;
//Print the current line being
if (!vo.isPreparedForExecution())
vo.setMaxFetchSize(0);
vo.executeQuery();
System.out.println("Trimmed "+ linetext[1].replace("\"", ""));
Row row = vo.createRow();
row.setAttribute("Deptno", linetext[0].trim());
row.setAttribute("Dname",linetext[1].trim().replace("\"", ""));
row.setAttribute("Loc",linetext[2].trim().replace("\"", ""));
//row.setAttribute("Column4", linetext[3].trim());
vo.last();
vo.next();
vo.insertRow(row);
catch (IOException e)
throw new OAException(e.getMessage(),OAException.ERROR);
//else if (pageContext.getParameter("Upload") != null)
am.getTransaction().commit();
throw new OAException("Uploaded SuccessFully",OAException.CONFIRMATION);
}Thanks,
Jit -
How we can load external html or php file in flash?
Hi there,
I want to show my php's file desing in flash..
i m getting data through database in php file and it has
table... so I want to show that data in my flash movie...
Please help me ..
How can I load external html or php file in flash?
If any other way is there then plz tell me.....
thanxNo. Flash can only display html content in textfields and only supports a very limited number of html tags (look up the htmlText property of TextFields). So to display an html/php file is not possible.
-
My iTunes store works on my windows 7 pc. However when I click on the iTunes store it only loads halfway and the screen just says iTunes store. How do I fix this?
Close your iTunes,
Go to command Prompt -
(Win 7/Vista) - START/ALL PROGRAMS/ACCESSORIES, right mouse click "Command Prompt", choose "Run as Administrator".
In the "Command Prompt" screen, type in
netsh winsock reset
Hit "ENTER" key
Restart your computer.
Now launch your iTunes and see if it is working now. -
How do I load microsoft office and pdf files onto an Ipad
How do I load microsoft office and pdf files onto an Ipad?
You can email them, you can use DropBox, SugarSync or another cloud service or you can use iOS file sharing.
But in all cases you need an app on the iPad that will open and save those types of files. iBooks, Adobe Readers, Good Reader and Save 2 PDF will all save PDF files.
Documents to Go, Quick Office Pro and the Apple iWorks apps will open and save the MS office files. You can Google - "iPad apps that are compatible with Microsoft Office files" and you will find other alternatives - or search the app store for more.
You can read this as well for some instruction on getting those files onto an iPad.
http://online.wsj.com/article/SB10001424052748703899704576204564046912604.html -
How do I create a pdf file that is only part of an existing pdf file??
How do I create a pdf file that is only part of an existing pdf file??
Use Adobe Acrobat. ExportPDF does not do this, or claim to do this.
-
How to automate loading data from a text file ?
Hi,
I need to load a data form a text file automatically. (for example: every day at 6.p.m) .
It is possible to use DBMS_SCHEDULER with SQL LOADER ? or maybe u have others idea ?
regards,assuming that the text file resides at the machine where the database is installed at you can create a procedure that use the built-in UTL_FILE package to read and load the data to the oracle tables. then create a job that use the DBMS_JOB or DBMS_SCHEDULER to create an automated schedule to run the job that calls the procedure you have created.
or assuming that the text file resides or at the local/client machine (example c:\ drive) on a windows xp platform. create a batch file that do a ftp to transfer the text file to the oracle database server and create a schedule job using the windows scheduler. also create a procedure that use the built-in UTL_FILE package to read and load the data to the oracle tables. then create a job that use the DBMS_JOB or DBMS_SCHEDULER to create an automated schedule to run the job that calls the procedure you have created. -
SQL* Loader Loading specific column from CSV file to the table
Dear All,
Iam Loading specific column from .CSV file to the oracle table.
Could pls help how i can load only that cols into the table
Eg: CSV file having id, Frst_name,Last_name, Address,Phone,Insurance etc
out of this I want to load only Frst_name,Last_name columns to oracle table say fname and lname.
Thanks in Adv.
JunuLily,
I made some changes to your table def but you will get the idea
-- Table EMPLOYEE
CREATE TABLE EMPLOYEE
EMPID NUMBER NOT NULL,
EMPNICKNAME VARCHAR2(10 BYTE) NULL,
FNAME VARCHAR2(20 BYTE) NOT NULL,
MI VARCHAR2(20 BYTE) NULL,
LNAME VARCHAR2(20 BYTE) NOT NULL,
FULLNAME VARCHAR2(20 BYTE) NOT NULL,
HIREDATE DATE DEFAULT SYSDATE NOT NULL
-- data file employee.dat
1,amy,b,amy b
2,cindy,d,cindy d
3,eric,f,eric f
4,gary,h,gary
-- Control file : Employee.ctl ( you can use truncate, replace or append , see sqlldr for more options)
load data
Truncate into table employee
fields terminated by ","
optionally enclosed by '"'
TRAILING NULLCOLS
empId INTEGER EXTERNAL,
FName char(20),
LName char(20),
FullName char(30)
now to load use following or you can speicify infile in control fle
sqlldr username/passowrd control=employee.ctl data=employee.dat log=employee.log
{code}
Hope this help.
Regards
Maybe you are looking for
-
Hello everyone, Here is my situation. I had a dual boot setup on my toshiba S855D (Win 8/Ubuntu 12.10). After a few months my win 8 install was giving me strange errors. I decided to do a full reinstall using the recovery USB I made. (I had reinst
-
Linking my imac to macbook bro
hi there i'm a student and i would love to connect my imac to my laptop ( macbook bro) ... what i mean by this is to have the same files, safari fav ... etc on both so when i go to university with my laptop i will have the same info from last night s
-
Daughters iPad stolen can't find serial number
Four days ago, she registered it in her apple ID number, but did not yet register it in iCloud. It is not seen by iCloud. Is there a way to pull the serial number from apple at all so we can register it? I cant even get through to Apple Support witho
-
DNS addresses (master and slave) + personalizing the url address
Hello. My name is Fernando and I published my site using MobileMe (www.fernandoingles.com). It's working already really well. But since I'm from Brazil, I built one in Portuguese as well. And since the common site endings here are .br I'm trying to p
-
Adobe Acrobat DC customization and deployment
I have customized copy of Adobe Acrobat DC with the serial number, suppressing the agreement, and installing in silent mode. But so far after deploying the customized copy using SCCM to all our client, it is still asking them to enter a serial number