Sql query on csv file

hello,
I am looking for a code/package/driver for SQL queries on .csv files.
The driver should be able to deal with both local files and remote
files.
The best if it will be able to use stream/reader.
Does anyone familiar with something like that?
Thank you,
Asi

I think theirs an ODBC driver that supports this, but that's obviously a second-class solution at best.
The second closest thing to this is HSQLDB. It usually uses it's own format but can be used to reference other files as well IIRC

Similar Messages

  • How to query a csv file

    Hello I am new to cold fusion.
    I am wondering if there is a way to query a csv file using a read from cffile? Currently I have it setup as a cffile read and then I try to query the file using cffquery. Obviously this doesn't work because I have to set a datasource. Is there anyway to do this or any way to set a csv file as a data source? Any help or direction would be greatly appreciated.
    Thanks.

    You would have to read in the csv and create a query using QueryNew(). Once you have the csv in a query format, then you can perform query of queries to do most anything you want on the data. There is probably code already written out there to do the csv to query, you just need to find it. The query of queries is in the documentation. The only gotcha is that query of queries sorting and matching is case sensitive. Hope this helps.

  • Export query to csv file

    I am almost new to Oracle, been a decade since I last worked on it. I have query over multiple tables. I need to run the query daily and get a csv file out of it. How sure how to do it. Can anyone please help? In the csv file I need no headers etc. just comma separated rows.
    I found this link which is very helpful, however, no matter what I try, the output file shows the query too. How do I make sure the output file has just the data and not the query?
    http://stackoverflow.com/questions/643137/how-do-i-spool-to-a-csv-formatted-file-using-sqlplus
    Edited by: 857833 on May 10, 2011 9:00 AM

    This is getting very frustrating. Below is what I type in my sql plus window.
    set colsep ','
    set echo off
    set feedback off
    set linesize 1000
    set pagesize 0
    set sqlprompt ''
    set trimspool on
    set headsep off
    spool "FULLPATHTOOUTPUTFILE"
    @"FILEWITHQUERY.SQL"
    spool off
    This creates the output file, where first line is @"FILEWITHQUERY.SQL"
    then shows the result set rows, the last row in the file is "spool off"
    Can you please show me an example that works for you? I never imagined generating a text file from tables is this hard. :((

  • How to run sql query in bat file in task schedular at every 10 seconds

    This is my sql script :
    DECLARE @countRows INT,
    @currDate DATE,
    @checkForTasks INT,
    @created_by_id INT,
    @gst_ID int;
    SET @currDate = Getdate()
    SET @countRows = (SELECT Count(*)
    FROM [dbo].[sd_gst_effective_table]
    WHERE isapplied = 0)
    IF @countRows > 0
    -- Check for those GST''s who are not applied yet : if they are greater than 0 then perform next task
    BEGIN
    SET @checkForTasks = (SELECT Count(*)
    -- Check is current date equals to task date or not
    FROM [dbo].[sd_gst_effective_table]
    WHERE effect_date = @currDate AND isapplied = 0)
    IF @checkForTasks > 0
    -- If current date = task date then perform this task
    BEGIN
    SET @created_by_id = (SELECT TOP 1 createdby FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    SET @gst_ID = (SELECT gst_id FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
    -- STEP 1 :: InActivate the existing GST according to createdbyID
    UPDATE sd_gst_rate
    SET isactive = 0,
    inactivedate = Getdate()
    WHERE isactive = 1
    AND createdby = @created_by_id
    -- STEP 2 :: Activate the New GST according to implementation date and gstID
    UPDATE sd_gst_rate
    SET isactive = 1,
    activedate = Getdate()
    WHERE id = @gst_ID
    -- STEP 3 :: Inactivate the applied GST from sd_gst_effective_table
    UPDATE [dbo].[sd_gst_effective_table] SET isApplied = 1 WHERE gst_id = @gst_ID
    END
    END
    DECLARE @Text AS VARCHAR(100)
    DECLARE @Cmd AS VARCHAR(100)
    DECLARE @value nvarchar(1000);
    SET @value = (SELECT CONVERT(TIME,GETDATE()) AS HourMinuteSeconds);
    SET @Text = 'File Writed ' + @value
    SET @Cmd ='echo ' + @Text + ' > E:\AppTextFile.txt'
    EXECUTE Master.dbo.xp_CmdShell @Cmd
    This is resided in videos folder of windows , i have created a task schedular in windows 8.1 to run daily at every 10 seconds , but it is not working ... Please tell me how to deal with it.
    Please note : This sql query is running perfectly in sql server. Query have no errors. Please check whats wrong with my time schedular. I just want my schedular to run every 10 seconds regardless of date.

    Hi Emad,
    Is your script in a ".sql" file? May I know how you configure the schedule task action?
    Since you didn't mention how you configure the schedule task, can you confirm you have followed the below step correctly?
    Save your script in a ".sql" file.
    Create a ".bat" file and call the sql file above inside with
    sqlcmd.exe, you can reference
    here.
    Configure a schedule task to run the ".bat" file in a certain interval.
    Have you tried to run the script in you bat file in a standalone commandline window? Please post the script in your bat file, It can help to diagnose the issue.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Need help with query from .csv file

    I am trying to import a csv file with only 1 column in it.
    The column will only contain a 9 digit ID number. I want to read
    the file then use the contents to query a table to get the names
    and other information and display it. Here is what I have so far:
    <cffile action="read" file="#form.FiletoUpload#"
    variable="csvfile">
    <cfloop index="index" list="#csvfile#">
    <cfquery name="massimport" datasource="data1">
    SELECT * FROM IDTable
    WHERE CardNumber = ('#csvfile#')
    </cfquery>
    </cfloop>
    <cfoutput>#Name# #ID# #Site#</cfoutput>
    I get no errors but I am not getting any results. Just a
    blank page. Does anyone know how to query directly from a csv
    import? Thanks.

    You need to convert your file to a list somehow. Not sure if
    this is the most efficient way but, you can use the cfhttp tag to
    produce a query. Then your where clause becomes,
    where cardnumber in (#quotedvaluelist(query.column)#)
    and you won't need a loop.

  • JSP Servlet and convert the result set of an SQL Query To XML file

    Hi all
    I have a problem to export my SQL query is resulty into an XML file I had fixed my servlet and JSP so that i can display all the records into my database and that the goal .Now I want to get the result set into JSP so that i can create an XML file from that result set from the jsp code.
    thisis my servlet which will call the jsp page and the jsp just behind it.
    //this is the servlet
    import java.io.*;
    import java.lang.reflect.Array;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import javax.sql.*;
    public *class *Campaign *extends *HttpServlet
    *private* *final* *static* Logger +log+ = Logger.+getLogger+(Campaign.*class*.getName());
    *private* *final* *static* String +DATASOURCE_NAME+ = "jdbc/SampleDB";
    *private* DataSource _dataSource;
    *public* *void* setDataSource(DataSource dataSource)
    _dataSource = dataSource;
    *public* DataSource getDataSource()
    *return* _dataSource;
    *public* *void* init()
    *throws* ServletException
    *if* (_dataSource == *null*) {
    *try* {
    Context env = (Context) *new* InitialContext().lookup("java:comp/env");
    _dataSource = (DataSource) env.lookup(+DATASOURCE_NAME+);
    *if* (_dataSource == *null*)
    *throw* *new* ServletException("`" + +DATASOURCE_NAME+ + "' is an unknown DataSource");
    } *catch* (NamingException e) {
    *throw* *new* ServletException(e);
    protected *void *doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    Connection conn = *null*;
    *try* {
    conn = getDataSource().getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select post_id,comments,postname from app.posts");
    // out.println("Le r&eacute;sultat :<br>");
    ArrayList <String> Lescomments= *new* ArrayList<String>();
    ArrayList <String> Lesidentifiant = *new* ArrayList<String>();
    ArrayList <String> Lesnoms = *new* ArrayList <String>();
    *while* (rs.next()) {
    Lescomments.add(rs.getString("comments"));
    request.setAttribute("comments",Lescomments);
    Lesidentifiant.add(rs.getString("post_id"));
    request.setAttribute("id",Lesidentifiant);
    Lesnoms.add(rs.getString("postname"));
    request.setAttribute("nom",Lesnoms);
    rs.close();
    stmt.close();
    *catch* (SQLException e) {
    *finally* {
    *try* {
    *if* (conn != *null*)
    conn.close();
    *catch* (SQLException e) {
    // les param&egrave;tres sont corrects - on envoie la page r&eacute;ponse
    getServletContext().getRequestDispatcher("/Campaign.jsp").forward(request,response);
    }///end of servlet
    }///this is the jsp page called
    <%@ page import="java.util.ArrayList" %>
    <%
    // on r&eacute;cup&egrave;re les donn&eacute;es
    ArrayList nom=(ArrayList)request.getAttribute("nom");
    ArrayList id=(ArrayList)request.getAttribute("id");
    ArrayList comments=(ArrayList) request.getAttribute("comments");
    %>
    <html>
    <head>
    <title></title>
    </head>
    <body>
    Liste des campagnes here i will create the xml file the problem is to display all rows
    <hr>
    <table>
    <tr>
    </tr>
    <tr>
    <td>Comment</td>
    <td>
    <%
    for( int i=0;i<comments.size();i++){
    out.print("<li>" + (String) comments.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>nom</td>
    <td>
    <%
    for( int i=0;i<nom.size();i++){
    out.print("<li>" + (String) nom.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>id</td>
    <td>
    <%
    for( int i=0;i<id.size();i++){
    out.print("<li>" + (String) id.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    </table>
    </body>
    </html>
    This is how i used to create an XML file in a JSP page only without JSP/SERVLET concept:
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%
    // Identify a carriage return character for each output line
    int iLf = 10;
    char cLf = (*char*)iLf;
    // Create a new empty binary file, which will content XML output
    File outputFile = *new* File("C:\\Users\\user\\workspace1\\demo\\WebContent\\YourFileName.xml");
    //outputFile.createNewFile();
    FileWriter outfile = *new* FileWriter(outputFile);
    // the header for XML file
    outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
    try {
    // Define connection string and make a connection to database
    Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/SAMPLE","app","app");
    Statement stat = conn.createStatement();
    // Create a recordset
    ResultSet rset = stat.executeQuery("Select * From posts");
    // Expecting at least one record
    *if*( !rset.next() ) {
    *throw* *new* IllegalArgumentException("No data found for the posts table");
    outfile.write("<Table>"+cLf);
    // Parse our recordset
    // Parse our recordset
    *while*(rset.next()) {
    outfile.write("<posts>"+cLf);
    outfile.write("<postname>" + rset.getString("postname") +"</postname>"+cLf);
    outfile.write("<comments>" + rset.getString("comments") +"</comments>"+cLf);
    outfile.write("</posts>"+cLf);
    outfile.write("</Table>"+cLf);
    // Everything must be closed
    rset.close();
    stat.close();
    conn.close();
    outfile.close();
    catch( Exception er ) {
    %>

    Please state your problem that you are having more clearly so we can help.
    I looked at your code I here are a few things you might consider:
    It looks like you are putting freely typed-in comments from end-users into an xml document.
    The problem with this is that the user may enter characters in his text that have special meaning
    to xml and will have to be escaped correctly. Some of these characters are less than character, greater than character and ampersand character.
    You may also have a similiar problem displaying them on your JSP page since there may be special characters that JSP has.
    You will have to read up on how to deal with these special characters (I dont remember what the rules are). I seem to recall
    if you use CDATA in your xml, you dont have to deal with those characters (I may be wrong).
    When you finish writing your code, test it by entering all keyboard characters to make sure they are processed, stored in the database,
    and re-displayed correctly.
    Also, it looks like you are putting business logic in your JSP page (creating an xml file).
    The JSP page is for displaying data ONLY and submitting back to a servlet. Put all your business logic in the servlet. Putting business logic in JSP is considered bad coding and will cause you many hours of headache trying to debug it. Also note: java scriptlets in a JSP page are only run when the JSP page is compiled into a servlet by java. It does not run after its compiled and therefore you cant call java functions after the JSP page is displayed to the client.

  • Write sql query to a file

    I have a sql query:
    select * from XXWFS_CUSTOMER_EXT t2 where t2.rowid > (SELECT min(t1.rowid)
    FROM XXWFS_CUSTOMER_EXT t1
    WHERE t1.PARTY_ID=t2.PARTY_ID);
    I want to put this in a stored procedure and write it to a file to see what all the records i am getting in prod. How can we do this
    Thanks

    user10873676 wrote:
    I have a sql query:
    select * from XXWFS_CUSTOMER_EXT t2 where t2.rowid > (SELECT min(t1.rowid)
    FROM XXWFS_CUSTOMER_EXT t1
    WHERE t1.PARTY_ID=t2.PARTY_ID);
    I want to put this in a stored procedure and write it to a file to see what all the records i am getting in prod. How can we do this
    UTL_FILE can produce output text file.
    when all else fails, Read The Fine Manual
    http://www.oracle.com/pls/db112/search?remark=quick_search&word=utl_file&partno=
    Handle:     user10873676
    Status Level:     Newbie (10)
    Registered:     Jan 15, 2011
    Total Posts:     345
    Total Questions:     184 (133 unresolved)
    I extend my condolences to you since you rarely get answers to your questions here.

  • Saving result from query into CSV file

    Hi folks,
    in our application we're generating pages source using general packages (like htp, owa_util, ...). and in this part I'm a really beginner.
    I want to modify source one of our page, I want to add functionality to enable save result from query (cursor) into CSV file, to enable user choose place where generated file will be created and also change file name.
    I searched this forum and I found procedure, that could be useful:
    procedure p_getcsv is
    cursor cur is
           select 'a1' col1, 'b1' col2, 'c1' col3 from dual
       union  select 'a2' col1, 'b2' col2, 'c2' col3 from dual
       union  select 'a3' col1, 'b3' col2, 'c3' col3 from dual;
       begin
            -- Set the MIME type
            owa_util.mime_header( 'application/octet', FALSE );
            -- Set the name of the file
            htp.p('Content-Disposition: attachment; filename="test.csv"');
            -- Close the HTTP Header
            owa_util.http_header_close;
            -- Loop through all rows in EMP
            for x in cur
            loop
                -- Print out a portion of a row,
                -- separated by commas and ended by a CR
                 htp.prn(x.col1||','|| x.col2||','||x.col3|| chr(13));
            end loop;        
       end;What peace of code should I add to procedure that is generating web page to enable calling this procedure and whole saving process?
    Can anybody help me with this?
    Many thanks,
    Tomas
    Message was edited by:
    Tomeo

    Hi Marc,
    thanks for reply, problem is that I'm not using APEX application, I'm just generating web page code straight using oracle general packages.
    But I found this solution (maybe some tunning will be good):
    In page where I want to display Download i have
      begin
             htp.anchor2 (
                           curl  =>  ... .p_getcsv'||'?term=2005&crn=123,
                           ctext => 'Download Class List'
             HTP.br;
          end;
    ...si I'm calling p_getcsv procedure:
      procedure p_getcsv( term  IN stvterm.stvterm_code%TYPE DEFAULT NULL,
                           crn   IN sirasgn.sirasgn_crn%TYPE DEFAULT NULL) is
       v_length      NUMBER;
       v_file_name   VARCHAR2 (2000);
       temp_blob  blob;
       line RAW(32767);
       begin
             DBMS_LOB.CREATETEMPORARY(temp_blob, TRUE);
             FOR i IN 1..6  LOOP
                line := UTL_RAW.CAST_TO_RAW(i||','||term||','||crn||',AAA,BBB,CCC'||chr(10));
                DBMS_LOB.WRITEAPPEND(temp_blob, LENGTH(UTL_RAW.CAST_TO_VARCHAR2(line)), line);
             END LOOP;
              v_file_name := 'ClassList.csv';
              v_length  := DBMS_LOB.getlength (temp_blob);
              -- set up HTTP header
                 -- use an NVL around the mime type and
                 -- if it is a null set it to application/octect
                 -- application/octect may launch a download window from windows
               OWA_UTIL.mime_header (NVL ('csv', 'application/octet'), FALSE);
               -- set the size so the browser knows how much to download
               HTP.p ('Content-length: ' || v_length);
               -- the filename will be used by the browser if the users does a save as
               HTP.p (   'Content-Disposition:  attachment; filename="'
                  || REPLACE (REPLACE (SUBSTR (v_file_name,
                                               INSTR (v_file_name, '/') + 1
                                       CHR (10),
                                       NULL
                              CHR (13),
                              NULL
                  || '"'
                 -- close the headers
                 OWA_UTIL.http_header_close;
                -- download the BLOB
                 WPG_DOCLOAD.download_file (temp_blob);
                 -- release temporary blob
                 dbms_lob.freetemporary(temp_blob);  
       end;Regards,
    Tomas

  • Query to CSV file

    Hi,
    Is there a way to execute the query and save it in application server as csv format .  I've aleardy tried couple of the options -
    RSCRM_BAPI - due to complex restrictions in the query, the output is not consistant.
    Information Broadcasting - can either store in KM folder(portal) or email, not in application server.
    I have gone thro the couple of forum threads wr - abap to csv(Execute BW query using ABAP Part III), writequery, RRW3_GET_QUERY_VIEW_DATA ..   The abap with direct output to application server will be interested.
    Thanks
    Sreedh

    Hi,
    I hope it will help.
    Exporting as a CSV File 
    In order to process a query executed in a Web application further, you have to export the query as a CSV file or MS Excel 2000 file.
    Prerequisites
    ·        You have executed a query in your Web application and want to display it in a different format and continue processing the query.
    ·        To export the data to an Excel file, you have opened the BEx Analyzer
    Procedure..
           1.      From the context menu (left mouse-click on the text of a characteristic, characteristic value, structural component, description of exception, description of condition), choose Export As.... ® CSV File or Export As.... ® MS Excel 2000 File. The system exports the data into a CSV file or an MS Excel 2000 file.
    Export to MS Excel files from MS Excel 2000 is supported.
           2.      If you choose Export As...® CSV File, the query is displayed in CSV format (comma separated value). The numerical values of the query are displayed in a list that is separated with commas. The numerical values context, formatting (for example, displaying exceptions) and the filter data are available in the CSV file. You cannot navigate further with BW functions.
    Thanks
    Hema

  • LIKE operator is not working in SQL Query in XML file

    Hi Gurus,
    LIKE operator is not working in SQL query in XML template.
    I am creating a PDF report in ADF using Jdeveloper10g. The XML template is as follows
    <?xml version="1.0" encoding="WINDOWS-1252" ?>
    <dataTemplate name="catalogDataTemplate" description="Magazine
    Catalog" defaultPackage="" Version="1.0">
    <parameters>
    <parameter name="id" dataType="number" />
    <parameter name="ename" dataType="character" />
    </parameters>
    <dataQuery>
    <sqlStatement name="Q1">
    <![CDATA[
       SELECT ename, empno, job, mgr from EMP where deptno=:id and ename LIKE :ename || '%']]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="EmployeeInfo" source="Q1">
    <element name="EmployeeName" value="ename" />
    <element name="EMPNO" value="empno" />
    <element name="JOB" value="job"/>
    <element name="MANAGER" value="mgr" />
    </group>
    </dataStructure>
    </dataTemplate>
    if i pass the parameter value of :ename from UI, it doesn't filter. But if I give ename = :ename it retrieves the data. Can anyone help me why LIKE operator doesn't work here?
    Appreciate your help,
    Shyamal
    email: [email protected]

    Hi
    Well for a start, you are doing some very strange conversions there. For example...
    and to_char(a.msd, 'MM/DD/YYYY') != '11/11/2030'
    and to_char(a.msd, 'MM/DD/YYYY') != '10/10/2030'If a.msd is a date then you should e converting on the other side ie.
    and a.msd != TO_DATE('11/11/2030', 'MM/DD/YYYY')
    and a.msd != TO_DATE('10/10/2030', 'MM/DD/YYYY')Also, you may want to take into consideration nothing being input in :P2_ITEM_NUMBER like this...
    AND INSTR(a.item_number,NVL(:P2_ITEM_NUMBER,a.item_number)) > 0Is item number actually a number or char field? If it's a number, you want to explicitly convert it to a string for using INSTR like this...
    AND INSTR(TO_CHAR(a.item_number),NVL(TO_CHAR(:P2_ITEM_NUMBER),TO_CHAR(a.item_number))) > 0?
    Cheers
    Ben

  • SQL Query to Text file

    I need to dump a query out to files, the issue is that this
    query has to break by an specific code and then create the text
    file based on this code. But when I try to execute it I get a Jrun
    Server error "Jrun 500 Null".
    please take a look at the code and tell me what I'm doing
    wrong.

    ok some of these suggestions worked, I no longer get the Jrun
    Server 500 NUll error but the query still does not execute except
    for the last Master_IPA code.
    <!------Revised Code------>
    <cfsetting requesttimeout="500000">
    <cfparam name="form.data_var" default="0">
    <cfswitch expression="#form.data_var#">
    <cfcase value="1">
    <cfinvoke component="dataCOM" method="getCapdata"
    returnvariable="ipaList">
    <cfset List = #ValueList(ipaList.MASTER_IPA,",")#>
    <CFSET CRLF = chr(13) & chr(10)>
    <cfoutput>
    <cfloop index="curLine" list="#List#" delimiters =
    ",">
    <cfset fields = #TRIM(curLine)#>
    <cfset filePath =
    #GetDirectoryFromPath(ExpandPath("."))#&"downloads\"&#TRIM(curLine)#&"_capPremSpec_"&#Dat eFormat(NOW(),'mmddyyyy')#&".txt">
    <cffile action="write" file="#filePath#"
    output="WDW_PRODUCT|MASTER_IPA|WDW_IPA_ID|WDW_PCP_ID|EXTERNAL_PCP_ID|SEQ_MEMB_ID|ACTIVITY _DATE|ADJUSTMENT|FUNDING_AB|FUNDING_D|FUNDING_MEMBER_PREMIUM|GROSS_DC_ABOVE_ATTACH_PNT_AMT |IBNR|INST_CLAIM|IPA_CLAIM|IPA_DISBURSEMENTS|LOW_INCOME_COST_SHARING_AMT|MED_EXP_AB|MED_EX P_D|MEMBER_COUNT|MEMBER_PREMIUM|NET_AB|NET_PART_D|PART_D_INCLUDE_FLAG|PART_D_PREMIUM|PCP_C AP|PHARMACY|PLAN_DISBURSEMENTS|PREMIUM|PROF_CLAIM|REINSURANCE|RISK_CORRIDOR|RX_CLAIM_DOLLA RS|RX_STOP_LOSS|SPEC_CAP|SSC_AMT|STOP_LOSS|WDW_FUNDING_COUNTY|PLAN_CODE|PCP_LAST_NAME|PCP_ FIRST_NAME|WDW_INPUT_CHANNEL|WDW_COHORT|WDW_ELIG_CATEGORY|MASTER_DOB|MASTER_SEX|MEDICAID_N O|MEDICARE_NO|SUBSCRIBER_ID|LAST_NAME|FIRST_NAME|ADDRESS_LINE_1|ADDRESS_LINE_2|CITY|WDW_ST ATE|ZIP|RISK_SCORE_AB|RISK_SCORE_D|HOSPICE|ESRD|INSTITUTIONAL|NURSING_HOME_CERTIFIABLE|MED ICAID|MEDICAID_ADD_ON|PREVIOUS_DISABLE|PHONE|REGION|WDW_PRODUCT|MASTER_IPA|WDW_IPA_ID|WDW_ PCP_ID|EXTERNAL_PCP_ID|SEQ_MEMB_ID|ACTIVITY_DATE|ADJUSTMENT|FUNDING_AB|FUNDING_D|FUNDING_M EMBER_PREMIUM|GROSS_DC_ABOVE_ATTACH_PNT_AMT|IBNR|INST_CLAIM|IPA_CLAIM|IPA_DISBURSEMENTS|LO W_INCOME_COST_SHARING_AMT|MED_EXP_AB|MED_EXP_D|MEMBER_COUNT|MEMBER_PREMIUM|NET_AB|NET_PART _D|PART_D_INCLUDE_FLAG|PART_D_PREMIUM|PCP_CAP|PHARMACY|PLAN_DISBURSEMENTS|PREMIUM|PROF_CLA IM|REINSURANCE|RISK_CORRIDOR|RX_CLAIM_DOLLARS|RX_STOP_LOSS|SPEC_CAP|SSC_AMT|STOP_LOSS|WDW_ FUNDING_COUNTY|PLAN_CODE|PCP_LAST_NAME|PCP_FIRST_NAME|WDW_INPUT_CHANNEL|WDW_COHORT|WDW_ELI G_CATEGORY|MASTER_DOB|MASTER_SEX|MEDICAID_NO|MEDICARE_NO|SUBSCRIBER_ID|LAST_NAME|FIRST_NAM E|ADDRESS_LINE_1|ADDRESS_LINE_2|CITY|WDW_STATE|ZIP|RISK_SCORE_AB|RISK_SCORE_D|HOSPICE|ESRD |INSTITUTIONAL|NURSING_HOME_CERTIFIABLE|MEDICAID|MEDICAID_ADD_ON|PREVIOUS_DISABLE|PHONE|RE GION"
    addnewline="yes" />
    <cfquery name="textFiles" datasource="#request.dsn#">
    SELECT TOP 100
    WDW_PRODUCT,MASTER_IPA,WDW_IPA_ID,WDW_PCP_ID,EXTERNAL_PCP_ID,SEQ_MEMB_ID,ACTIVITY_DATE,
    ADJUSTMENT,FUNDING_AB,FUNDING_D,FUNDING_MEMBER_PREMIUM,GROSS_DC_ABOVE_ATTACH_PNT_AMT,IBNR, INST_CLAIM,
    IPA_CLAIM,IPA_DISBURSEMENTS,LOW_INCOME_COST_SHARING_AMT,MED_EXP_AB,MED_EXP_D,MEMBER_COUNT, MEMBER_PREMIUM,
    NET_AB,NET_PART_D,PART_D_INCLUDE_FLAG,PART_D_PREMIUM,PCP_CAP,PHARMACY,PLAN_DISBURSEMENTS,P REMIUM,PROF_CLAIM,
    REINSURANCE,RISK_CORRIDOR,RX_CLAIM_DOLLARS,RX_STOP_LOSS,SPEC_CAP,SSC_AMT,STOP_LOSS,WDW_FUN DING_COUNTY,PLAN_CODE,
    PCP_LAST_NAME,PCP_FIRST_NAME,WDW_INPUT_CHANNEL,WDW_COHORT,WDW_ELIG_CATEGORY,MASTER_DOB,MAS TER_SEX,MEDICAID_NO,
    MEDICARE_NO,SUBSCRIBER_ID,LAST_NAME,FIRST_NAME,ADDRESS_LINE_1,ADDRESS_LINE_2,CITY,WDW_STAT E,ZIP,RISK_SCORE_AB,
    RISK_SCORE_D,HOSPICE,ESRD,INSTITUTIONAL,NURSING_HOME_CERTIFIABLE,MEDICAID,MEDICAID_ADD_ON, PREVIOUS_DISABLE,
    PHONE,REGION,WDW_PRODUCT,MASTER_IPA,WDW_IPA_ID,WDW_PCP_ID,EXTERNAL_PCP_ID,SEQ_MEMB_ID,ACTI VITY_DATE,
    ADJUSTMENT,FUNDING_AB,FUNDING_D,FUNDING_MEMBER_PREMIUM,GROSS_DC_ABOVE_ATTACH_PNT_AMT,IBNR, INST_CLAIM,
    IPA_CLAIM,IPA_DISBURSEMENTS,LOW_INCOME_COST_SHARING_AMT,MED_EXP_AB,MED_EXP_D,MEMBER_COUNT, MEMBER_PREMIUM,
    NET_AB,NET_PART_D,PART_D_INCLUDE_FLAG,PART_D_PREMIUM,PCP_CAP,PHARMACY,PLAN_DISBURSEMENTS,P REMIUM,PROF_CLAIM,
    REINSURANCE,RISK_CORRIDOR,RX_CLAIM_DOLLARS,RX_STOP_LOSS,SPEC_CAP,SSC_AMT,STOP_LOSS,WDW_FUN DING_COUNTY,PLAN_CODE,
    PCP_LAST_NAME,PCP_FIRST_NAME,WDW_INPUT_CHANNEL,WDW_COHORT,WDW_ELIG_CATEGORY,MASTER_DOB,MAS TER_SEX,MEDICAID_NO,
    MEDICARE_NO,SUBSCRIBER_ID,LAST_NAME,FIRST_NAME,ADDRESS_LINE_1,ADDRESS_LINE_2,CITY,WDW_STAT E,ZIP,RISK_SCORE_AB,
    RISK_SCORE_D,HOSPICE,ESRD,INSTITUTIONAL,NURSING_HOME_CERTIFIABLE,MEDICAID,MEDICAID_ADD_ON, PREVIOUS_DISABLE,PHONE,REGION
    FROM dbo.CapPremSpecInload
    WHERE MASTER_IPA ='#TRIM(curLine)#'
    </cfquery>
    <cfset msg = "file"&#TRIM(curLine)#&"
    created!">
    #msg#<br />
    </cfloop>
    </cfoutput>
    <cfoutput>
    <cfloop query="textFiles">
    <cffile action="append" file="#filePath#"
    output="#WDW_PRODUCT#|#MASTER_IPA#|#WDW_IPA_ID#|#WDW_PCP_ID#|#EXTERNAL_PCP_ID#|#SEQ_MEMB_ ID#|#ACTIVITY_DATE#|#ADJUSTMENT#|#FUNDING_AB#|#FUNDING_D#|#FUNDING_MEMBER_PREMIUM#|#GROSS_ DC_ABOVE_ATTACH_PNT_AMT#|#IBNR#|#INST_CLAIM#|#IPA_CLAIM#|#IPA_DISBURSEMENTS#|#LOW_INCOME_C OST_SHARING_AMT#|#MED_EXP_AB#|#MED_EXP_D#|#MEMBER_COUNT#|#MEMBER_PREMIUM#|#NET_AB#|#NET_PA RT_D#|#PART_D_INCLUDE_FLAG#|#PART_D_PREMIUM#|#PCP_CAP#|#PHARMACY#|#PLAN_DISBURSEMENTS#|#PR EMIUM#|#PROF_CLAIM#|#REINSURANCE#|#RISK_CORRIDOR#|#RX_CLAIM_DOLLARS#|#RX_STOP_LOSS#|#SPEC_ CAP#|#SSC_AMT#|#STOP_LOSS#|#WDW_FUNDING_COUNTY#|#PLAN_CODE#|#PCP_LAST_NAME#|#PCP_FIRST_NAM E#|#WDW_INPUT_CHANNEL#|#WDW_COHORT#|#WDW_ELIG_CATEGORY#|#MASTER_DOB#|#MASTER_SEX#|#MEDICAI D_NO#|#MEDICARE_NO#|#SUBSCRIBER_ID#|#LAST_NAME#|#FIRST_NAME#|#ADDRESS_LINE_1#|#ADDRESS_LIN E_2#|#CITY#|#WDW_STATE#|#ZIP#|#RISK_SCORE_AB#|#RISK_SCORE_D#|#HOSPICE#|#ESRD#|#INSTITUTION AL#|#NURSING_HOME_CERTIFIABLE#|#MEDICAID#|#MEDICAID_ADD_ON#|#PREVIOUS_DISABLE#|#PHONE#|#RE GION#|#WDW_PRODUCT#|#MASTER_IPA#|#WDW_IPA_ID#|#WDW_PCP_ID#|#EXTERNAL_PCP_ID#|#SEQ_MEMB_ID# |#ACTIVITY_DATE#|#ADJUSTMENT#|#FUNDING_AB#|#FUNDING_D#|#FUNDING_MEMBER_PREMIUM#|#GROSS_DC_ ABOVE_ATTACH_PNT_AMT#|#IBNR#|#INST_CLAIM#|#IPA_CLAIM#|#IPA_DISBURSEMENTS#|#LOW_INCOME_COST _SHARING_AMT#|#MED_EXP_AB#|#MED_EXP_D#|#MEMBER_COUNT#|#MEMBER_PREMIUM#|#NET_AB#|#NET_PART_ D#|#PART_D_INCLUDE_FLAG#|#PART_D_PREMIUM#|#PCP_CAP#|#PHARMACY#|#PLAN_DISBURSEMENTS#|#PREMI UM#|#PROF_CLAIM#|#REINSURANCE#|#RISK_CORRIDOR#|#RX_CLAIM_DOLLARS#|#RX_STOP_LOSS#|#SPEC_CAP #|#SSC_AMT#|#STOP_LOSS#|#WDW_FUNDING_COUNTY#|#PLAN_CODE#|#PCP_LAST_NAME#|#PCP_FIRST_NAME#| #WDW_INPUT_CHANNEL#|#WDW_COHORT#|#WDW_ELIG_CATEGORY#|#MASTER_DOB#|#MASTER_SEX#|#MEDICAID_N O#|#MEDICARE_NO#|#SUBSCRIBER_ID#|#LAST_NAME#|#FIRST_NAME#|#ADDRESS_LINE_1#|#ADDRESS_LINE_2 #|#CITY#|#WDW_STATE#|#ZIP#|#RISK_SCORE_AB#|#RISK_SCORE_D#|#HOSPICE#|#ESRD#|#INSTITUTIONAL# |#NURSING_HOME_CERTIFIABLE#|#MEDICAID#|#MEDICAID_ADD_ON#|#PREVIOUS_DISABLE#|#PHONE#|#REGIO N#"
    addnewline="yes" />--->
    </cfloop>
    </cfoutput>
    </cfcase>
    </cfswitch>
    <!------Revised Code------>

  • SQL loader with *.csv file

    Good morning,
    I have a *.CVS file containing data like this:
    A123456789,Ah Tong Station,Jalan Dungun
    I would like insert the data into a table that returns 1 row for each value
    id outlet_name addr_1A123456789 Ah Tong Station Jalan Dungun
    etc
    In the stored procedure, SQL loader, I used
    Insert into XXXXX values
    (SUBSTR(input_buffer, 1, 10),
    SUBSTR(input_buffer, 11, 60),
    SUBSTR(input_buffer, 61, 110);
    but the problem is that insertion of the outlet_name and addr_1 will not follow the subcripts that provided. Instead in gave an output like that:
    id outlet_name addr_1
    A123456789 ,Ah Tong Station,Jalan Dungun NULL
    Hope to get some advice asap. Thanks. :)
    Pauline

    Why not use the SQL*Loader proper to load this in to your table? It will be significantly faster than anything you could do in PL/SQL, especially if your volumes increase. And it will take care of the parsing for you, as long as you tell it the field delimiter. You've already seen that you can't rely on fixed widths when using delimited data.
    Given this data...
    A123456789,Ah Tong Station,Jalan Dungun
    A234,Some Station,Some Place...the following SQL*Loader control file ( stored in a file called mytable.ctl ) will load your table ( note I've used truncate - you could also append )...
    load data
    infile 'mydata.csv'
    truncate
    into table mytable
    fields terminated by ','
    (  id
    ,  outlet_name
    ,  addr_1
    )This is invoked using the following:-
    sqlldr userid/password@tns control=mytable.ctlThe results are:-
    SQL> select * from mytable;
    ID                             OUTLET_NAME                    ADDR_1
    A123456789                     Ah Tong Station                Jalan Dungun
    A234                           Some Station                   Some PlaceYou will find this much easier. Of course, you could always avoid the database altogether if you don't need to actually store this data. You could just parse the source .csv ( if you are on UNIX this will be really easy using an awk one-liner ) and write it to an output file.
    Anyway, hope this helps.
    Regards
    Adrian

  • Sql query in separate file

    Hi All
    I am developing a small web app. I want to keep sql queries out of my java code.
    Question:
    Is there any place where I can get code which which shows how to do this, I still want to be able to use prepared statements etc.
    Thanks
    bib

    What do you mean "Keep sql queries out of my java code"?
    If you just want the SQL to be in a config file that you read in then sure, put it in a properties file and use java.util.Properties.load() or a java.util.PropertyResourceBundle.
    If you're looking for greater separation of the relatioal model from your code, you can look into an ORM tool like hibernate.
    http://www.hibernate.org

  • Run sql query through batch file

    how to create a batch file so that on running the batch file,
    I should get into the database using username and password and create the table and insert values inside that table

    kindly, if you are using windows you can create 2 files as following:
    a.bat
    b.sql
    put the files under spacific folder for example d:\bat folder
    -first file a.bat will contain the following:
    sqlplus apps/apps@yourdb @d:\bat\B.sql
    exit
    -second file b.sql will contain any sql statments you want as following:
    create table a (a1 number, a2 varchar2(100))
    insert into a (a1,a2) values(1,'Test')
    commit
    exit;
    hope this help you
    Regards ...
    Edited by: shedo76 on 28/04/2012 03:14 ص

  • How to get sql query data and write into csv file?

    I am writing to seek help, in how can I create bat. script which can execute the following logic:
    connection to the database
    run sql query
    create CSV file
    output query data, into CSV file
    save the CSV file
    osql
    -S 84.18.111.111
    -U adw
    -P rem
    -i "c:\query.sql"
    send ""
    sed -e 's/,\s\+/,/g' MCI_04Dec2014.csv > localNoSpaces.csv
    -o "c:\MCI_04Dec2014.csv"
    This what i have so far, and I am little struggling with the logic after creating CSV file. I am unable to get the above script to work, please advice further, where I may be going wrong. 
    Can you create if statement logic within window's script, to check for null parameters or data feeds?
    Any hints would be most appreciated. 

    Thank you for your reply. 
    Apology for posting the code irrelevant to the forum, as I am still novice scripting user.  
    My goal is to create window's script which can compute the above logic and send the final output file (csv), to FTP folder. 
    Can this logic be implemented via bat. script, if so, is there a example or tutorial i could follow, in order to achieve my task. 
    Any help would be much appreciated. 

Maybe you are looking for

  • Playing DivX movies in Quick Time Player 7 Pro in WinVista 64-bit

    Hello everyone, I am just a new comer here and recently purchased iPod Touch 2nd Gen. I would like to know how I can convert DVD movies and DivX Movies to iPod movies version. I just upgraded QuickTimePlayer to Pro, some movies can be converted and p

  • My Ipod touch isn't recognized by Win 7 computer or Itunes

    My computer doesn't do anything when I plug in my ipod. I've tried reinstalling Itunes 4x. It doesn't show up in my computer or device manager. The ipod charges when I plug it in but the computer still does nothing.

  • Itunes crashes every time I try to buy a song

    Every time I try to buy a song Itunes crashes. It always happens on the terms and conditions screen This is the error I get Date/Time: 2008-08-02 13:24:25 -0500 OS Version: 10.3.9 (Build 7W98) Report Version: 2 Command: iTunes Path: /Applications/iTu

  • Moving Songs

    Dumb question but I can't seem to be able to move songs within my playlist. For example I want to make song 300 song 315, etc. When I drag, it just goes back to its original place.

  • Error in CM Repository with FSDB mode

    Hi All, My objective is to connect to an external file system using CM repository Manager.Heres what I have done: Created CM repository Manager with persistence mode FSDB Specified Network path for file server But in Component Monitor i am getting fo