Fixed Length records using SQL

hi , using the following code in a file that generates an output file with a fixed length 300 character lines.
SPOOL C:\PHONE_SAMPLE.OUT;
SET HEADING OFF;
SET PAGES 0;
SET ECHO OFF;
SELECT rpad(CONTACT_ID,15),rpad(PHONE1,15),rpad(PHONE2,15),rpad(PHONE3,15),rpad(PHONE4,15),rpad(PHONE5,15),rpad(PHONE6,15)
,rpad(CALLSEQ,6),rpad(NDCALLSEQ,6),rpad(LANG,3),rpad(FIRST,25),rpad(LAST,25),rpad(CONCODE,10),rpad(EMAIL,30),rpad(TXTMSG,20),rpad(WVEND,20),
rpad(APPTSTART,14),rpad(APPTEND,14),rpad(APPTTYPE,10),rpad(APPTLOCTION,10),rpad(FILLER,1)||'\n'
FROM PHONE_SAMPLE;
SPOOL OFF;
After I run this I get my data and the following below - my end of Character line, and then "22 rows selected" - How do I remove the 22 rows selected. and stop at \n. Any help appreciated.
Is it a set command I am missing ?
\n
22 rows selected.

Hi,
SET FEEDBACK OFF
And you don't need SET HEADING OFF when you have SET PAGES 0
And you don't need to end SET commands with ';' since they are SQL*Plus commands
Regards
Peter

Similar Messages

  • Exporting fixed length records in a .txt format

    Post Author: jnesbitt
    CA Forum: Crystal Reports
    How can I configure Crystal Report detail records so they can be exported in a fixed legth .txt record format?
    Using Crystal Reports 9.2.3.884

    Post Author: SKodidine
    CA Forum: Crystal Reports
    I have created CR detail records fixed length of 400 and then exported them to text.
    This is how I did it, there might be other ways and I even though I created them in CR XI, it should be similar in CR 9.
    Let us assume that your fixed length record needs to be 100 bytes long.  Create a formula with all the fields concatenated, that you would otherwise display in the details section.  Create a second formula that will use the space function to put trailing spaces.
    Here is an example for a fixed length record of 400:
    Here are my two fields in my record that have been concatenated.
    Formula 1: RecordType & totext(BatchNumber,"0000000");
    Formula 2: {@Formula1} & space(400 - length({@Formula1}));

  • Adapter file receiver - file with fix length record

    Hi everybody,
    In the file adapter receiver, I want to create a fixed length record file .
    Each record need to have the same size.
    How is it possible, because I have a file which contains variable legnth depending of the lenght of message?
    exemple:
    <mess>
       <row>1234567</row>
       <row>123456789A</row>
    </mess>
    give the file
    1234567<CR>
    123456789A<CR>
    <CR> means carriage return
    and I want a file like
    1234567   <CR>
    123456789A<CR>
    with the same lenth of record (10 in the example).
    Can anyone help me, ,please?
    Kind regards.
    E. Koralewski

    Hi Eric,
    Create a value user defined function with one input argument a and name it is inputpad. Then add the following code:
    Imports:  java.*;
    while (a.length()<Integer.parseInt("10"))
         a= a +" " ;
    return String;
    Here I am assuming your fixed length for the field is 10. If it is more or less then change the number. Now in your mapping do all your logic and then in the final add this like:
    input ---> your logic --> inputpad udf --> target.
    Regards,
    ---Satish

  • Help with FIXED LENGTH columns - using spool command

    Hi guys,
    I have a view I am trying to spool using fixed length columns, and the spacing is off. Ive tried numerous things such as specifiying the column width before running the query, using the rpad command, but nothing seems to work. I have to spool it to a text file in order for the users to import this file into another system. I would welcome any and all suggestions. Thanks so much. The following is the view:
    SELECT "EMPLOYEE_ID","FIRST NAME","INITIAL","LAST NAME","SUFFIX","TRAINING DATE","Course ID","Class ID", "We", "Make / Model", "Cali", "Barrell", "Serial Number", "Qualification", "Application", "SCORE", "Status", "Add Time", "Record Add ID","Record Add Date","Record Change ID","Record Change Date","RN" FROM
    (SELECT
    UPPER(RPAD(tbl.ssn,10)) AS "EMPLOYEE_ID",
    UPPER(RPAD('',12)) AS "FIRST NAME",
    UPPER(RPAD('',1)) AS "INITIAL",
    UPPER(RPAD('',20)) AS "LAST NAME",
    UPPER(RPAD('',5)) AS "SUFFIX",
    UPPER(RPAD(to_char(QUALDATE, 'mmddyyyy'),8)) AS "TRAINING DATE",
    UPPER(RPAD('P123',8)) AS "Course ID",
    UPPER(RPAD('',6)) AS "Class ID",
    UPPER(RPAD('P',4)) AS "We",
    UPPER(RPAD('',4)) AS "Make / Model",
    UPPER(RPAD('',4)) AS "Cali",
    UPPER(RPAD('',7)) AS "Barrell",
    UPPER(RPAD('',15)) AS "Serial Number",
    UPPER(RPAD('A',4)) AS "Qualification",
    UPPER(RPAD('D',4)) AS "Application",
    to_char((RAWSCORE/250)*100, 'fm000.00') AS "SCORE",
    UPPER(RPAD('PASS',4)) AS "Status",
    UPPER(RPAD('',8)) AS "Add Time",
    UPPER(RPAD('',8)) AS "Record Add ID",
    UPPER(RPAD('',8)) AS "Record Add Date",
    UPPER(RPAD('',8)) AS "Record Change ID",
    UPPER(RPAD('',8)) AS "Record Change Date",
    row_number()over(partition by firearms_scores.ID_NUMBER order by QUALDATE desc ) rn
    FROM FIREARMS_scores, TBL
    where scores.id_number=tbl.id_number
    and qualyear='2010' and coursecode='SA'
    order by employee_id)
    where rn =1

    Hi,
    You RPAD doesn't do anything, since they are same as:
    SQL> SELECT NULL AS "Record Add ID",
      2         NULL AS "Record Add Date",
      3         NULL AS "Record Change ID",
      4         NULL AS "Record Change Date" FROM DUAL;
    R R R R
    SQL>Can't see why COLUMN command shouldn't do what you want. Maybe you forgot the double quotes?
    SQL> COL "Record Add ID" FOR a18
    SQL> COL "Record Add Date" FOR a18
    SQL>
    SQL> SELECT NULL AS "Record Add ID",
      2         NULL AS "Record Add Date",
      3         NULL AS "Record Change ID",
      4         NULL AS "Record Change Date" FROM DUAL;
    Record Add ID      Record Add Date    R R
    SQL>P.S: You probably shouldn't set a column width which is smaller than the header length
    Regards
    Peter

  • Writing Fixed Length rows in SQL*Plus

    Hi all,
    I am trying to build an extract file for our external customer. Each row in the file must be fixed length of 82 characters. The last column in the table is a social security number.
    Since the social security column in the source table contains some bad or missing numbers, I must make sure to fix or at least force blank into the bad or missing ssn column.
    The social security column in the source file consists of the following problems:
    1)     No social security available
    2)     Social security number is not numeric
    3)     Social Security is less than 9 characters
    Of course if the social security is present and is numeric and contains 9 characters, I have no problem because, that row would have 82 characters. I have written a function that I use in the select statement in the SQL script. But when I run the script,if the ssn is missing, that row will be 73 characters. And if the ssn is numeric but less than 9 characters say for instance 7 characters, then that row would be 8 characters. Any ideas what I could do to ensure that each row consists of 82 characters?
    Here are the scripts:
    ======== script begin =========
    SET ECHO OFF
    SET LINESIZE 30000
    set pagesize 0
    SET ARRAYSIZE 1
    SET TRIMSPOOL ON
    SET COLSEP ""
    SET FEEDBACK OFF
    SET HEADING OFF
    SET TERMOUT OFF
    spool c:\temp\test_bad_ssn.dat
    select distinct empno
    , ename
    , job
    , mgr
    , hiredate
    , sal
    , comm
    , deptno
    , VALIDATE_ATG_SSN(SSN)
    from emp2;
    SPOOL OFF
    --quit
    ======== script end ==========
    ======== function begin =======
    CREATE OR REPLACE FUNCTION SEYEDGOL.VALIDATE_ATG_SSN( str IN VARCHAR2 )
    RETURN VARCHAR2
    IS
    NUM NUMBER;
    V_SSN VARCHAR2(9);
    V_NO_SSN VARCHAR2(9);
    BEGIN
    NUM := TO_NUMBER(str);
    V_NO_SSN := chr(32);
    V_NO_SSN := V_NO_SSN||chr(32)||chr(32)||chr(32)||chr(32)||
    chr(32)||chr(32)||chr(32)||chr(32);
    -- first see if the value is numeric
    FOR i IN 1 .. 9 LOOP
    if substr(str,i,1) NOT in ('0','1','2','3','4','5','6','7','8','9') THEN
    RETURN V_NO_SSN;
    END IF;
    END LOOP;
    IF LENGTH(NUM) = 9 THEN
    V_SSN := STR;
    ELSE
    V_SSN := LPAD(RPAD(STR,9,' '),9,' ');
    END IF;
    IF NUM is not null then
    RETURN V_SSN;
    ELSE
    RETURN V_NO_SSN;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN V_NO_SSN;
    END;
    ======== function end =======
    Thank you for your input,
    Seyed

    You really need to go through the SQL and PL/SQL guides in the Oracle documentation -
        V_SSN := LPAD(RPAD(STR,9,' '),9,' ');what's the point of using LPAD ?
    V_NO_SSN := V_NO_SSN||chr(32)||chr(32)||chr(32)||chr(32)||
                         chr(32)||chr(32)||chr(32)||chr(32);Oh c'mon, seriously ?
    If you are on 10g, you could use the power of regular expressions to simplify your work:
    test@ORA10G>
    test@ORA10G> @ver1
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> with t as (
      2    select '123456789' as ssn from dual union all
      3    select '123AB6789' from dual union all
      4    select 'ABC998888' from dual union all
      5    select '123~@5555' from dual union all
      6    select null        from dual union all
      7    select '12345'     from dual union all
      8    select 'ABC'       from dual)
      9  --
    10  select ssn,
    11         regexp_replace(ssn,'\d') as mod_ssn,
    12         case when regexp_replace(ssn,'\d') is not null
    13              then 'Not a number'
    14              when regexp_replace(ssn,'\d') is null and length(ssn) < 9
    15              then 'Numeric but less than 9 characters'
    16              when regexp_replace(ssn,'\d') is null
    17              then 'Null or Numeric and equal to 9 characters'
    18         end as msg
    19    from t;
    SSN       MOD_SSN   MSG
    123456789           Null or Numeric and equal to 9 characters
    123AB6789 AB        Not a number
    ABC998888 ABC       Not a number
    123~@5555 ~@        Not a number
                        Null or Numeric and equal to 9 characters
    12345               Numeric but less than 9 characters
    ABC       ABC       Not a number
    7 rows selected.
    test@ORA10G>
    test@ORA10G>There is a regular expression for SSN in the Oracle documentation as well, but I guess your case is a bit different as you want to rpad spaces to an invalid SSN like '12345'.
    HTH,
    isotope

  • Problem with added carrige returns in download of fixed length records.

    Hi,
    I'm hoping that someone can help me, I'm at a complete loss.
    I am downloading fixed length text records from our extranet via JSP. The problem is that 8 addtional carrige returns are being added to the records somewhere during this process, rendering the files useless. The following is the code I'm using
    <%
    FileInputStream fInputStream = null;
    String piccareD = "/usr/local/apache/tomcat/webapps/piccare/";
    String filePath = piccareD + "x/" + request.getRemoteUser() + "/dnload/";
    String fileName = request.getParameter("fileName");
    int ch;
    String dnloadFile = filePath + fileName;
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment;filename=" + dnloadFile);
    Connection con = ConnectionServlet.getConnection();
    try
      fInputStream = new FileInputStream(dnloadFile);
      while ( (ch = fInputStream.read() ) != -1)
          out.write(ch);
      log.logEvent(con, LogElement.DNLOAD, fileName);
      log.setRetrieved(con, fileName, tStamp.getStamp());
      if( ! (fileName.indexOf("archive/") > -1) )
           String proc = "mv " + dnloadFile + " " + filePath + "archive/" + fileName;
           Process mv  = Runtime.getRuntime().exec( proc );
           Thread.sleep(100);
           int ec = mv.exitValue();
           mv.destroy();
           System.err.println( ec );
           if( ec != 0 )
    } catch (Exception e) {
            System.err.println(e.getMessage());
            log.logEvent(con, LogElement.DNLOAD_ERR, fileName);
    %>Any help is sincerely appreciated.
    Thank you!
    [email protected]

    You might try setting the buffer size to 0 for the jsp page and see if that helps.

  • Exporting to fixed length text using Crystal Enterprise 10

    Post Author: adamsueryan
    CA Forum: Deployment
    I would like to know if it is possible to export from Crystal Enterprise 10 to a fixed length text file similar to the text exporting option using Crystal Reports 8.5.  From Enterprise 10 I see you can export to Rich Text Format but that is not really the same.
    Adam

    Post Author: hamish_sco
    CA Forum: Exporting
    I normally use these settings, which work pretty well; Excel Format:  CustomOptions:  Column width based on - Detailsthen the following boxes ticked;Export Object FormattingMaintain Relative Object PositionMaintain Column AlignmentExport Page Header and Footer CheersHamish

  • 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
    Shanthi

    hi,
    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 insert the records using sql query

    hi,
    i insert the record uisng sql query and DOTNET programme successfully and increase the doc num .ubut when i try to  add record using SAP B1 the old Doc no show.It means its not consider the docnums which are not inserted by sql query.
    how can i solve this problem?
    Regards,
    M.Thippa Reddy

    You are not support use Insert / Update / Delete on SAP Databases directly.
    SAP will not support any database, which is inconsistent, due to SQL-Queries, which modify datasets or the datastructure of the SAP Business One Database. This includes any update-, delete- or drop-statements executed via SQL-Server Tools or via the the query interface of SAP Business One
    Check SAP Note: 896891 Support Scope for SAP Business One - DB Integrity
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E&note_numm=896891]

  • Update record using SQL statement

    I have VB6.0 and Oracle 10G Express Edition in Windows 2000 Server. My procedure in VB 6.0 can't update record in the table using SQL statement, and the Error Message is " Missing SET keyword ".
    The SQL statement in VB6.0 look like this :
    General Declaration
    Dim conn as New ADODB.Connection
    Dim rs as New ADODB.Recordset
    Private Sub Command1_Click()
    dim sql as string
    sql = " UPDATE my_table " & _
    " SET Name = ' " & Text3.Text & " ' " & _
    " AND Unit = ' " & Text2.Text & " ' " & _
    " WHERE ID = ' " & Text1.Text & " ' "
    conn.Execute (sql)
    Private Sub Form Load()
    Set conn = New ADODB.Connection
    conn.Open "Provider=MSDASQL;" & "Data Source=my_table;"& "User ID =marketing;" & "Password=pass123;"
    I'm sorry about my language.
    What's wrong in my SQL statement, I need help ........ asap
    Best Regards,
    /Harso Adjie

    The syntax should be
    UPDATE TABLE XX
    SET FLD_1 = 'xxxx',
    FLD_2 = 'YYYY'
    WHERE ...
    'AND' is improperly placed in the SET.

  • Retrieving records using SQL Date Queries

    Hello,
    I am using Lab Windows CVI 8.5 and also SQL TOolkit for my project. I am using DBMapColumnToChar function for mapping Date to the database. And for retrieving records I am using SQL Query as follows:
    SELECT * FROM DBTable WHERE DATE_TABLE BETWEEN '%s' AND '%s'",cCurrentDate,cCurrentDate
    I have given a drop down for selecting dates.
    When I execute the query I am not getting the selected date values an instead I am getting some records for which the dates aren't selected...
    Quick help needed for this..Thanks in advance

    Depending on the database, the date/time structure can be completely different from the structure in CVI.  CVI uses the Windows format for time(), that is the number of seconds since 1900.  The tm struct can break this apart into a date and time structure that is usable.
    I am using MS Access for the databases and SQL toolkit.  I finally ended up replace the date field with an INT field format, and then store the CVI time (gotten with time()) as an INT value.
    Easy then to get a search range, store it a tm struct and then convert with mktime() to a calendar time to search with.
    Hope this helps.  The date/time thing is a never ending struggle.
    Regards, David E.

  • Fixed length retrieval using JDBC

    Hi All,
    I am wondering if there is an api where I can manipulate the result of a preparedstatement query.
    I am using a standard JDBC Connection to query against an oracle database. The particular column I retrieve is a decimal and can vary in length (i.e. 0.1, 125.005, 20.51..etc.) What I need is a fixed length of 12 places before the decimal, and 6 places after the decimal.
    So for my above examples:
    0.1 should be 000000000000.100000
    125.005 should be 000000000125.005000
    20.51 should be 000000000020.510000
    Is there an easy way of doing this after I get the result back? The result is a String. Any ideas would be much appreciated. Thanks

    So, you want to convert a number to a String. Use a DecimalFormat object to do that.

  • Insert a record using sql broker service

    Hi Guys,
    I need some samples to use sql broker service for creation of a record in other database in order to reduce the delay in creating number of records at the same time.

    Hello,
    In SQL Server Service Broker you can use the "Internal Activation" to start a stored procedure when a message comes in; in such a stored procedure you can do what ever you want to do, also inserting data into a table.
    See MSDN
    Service Broker Tutorials
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to combine records using SQL?

    If I have the following data:
    Table A
    order_no company_code
    O001 C001
    Table B
    order_no po_no
    O001 P001
    O001 P002
    O001 P003
    Now, I want to combine the data as:
    View A
    order_no company_code po_no
    O001 C001 P001, P002, P003
    If can it be realized using SQL?
    Thanks and Best Regards,
    Su Qian

    Hi Su Qian,
    To get the result like this you should write a function and call that in the select query.
    The function could be like this:
    CREATE OR REPLACE FUNCTION TEST(p_order_no IN B.order_no%TYPE ) RETURN VARCHAR2 IS
    v_po_no VARCHAR2(100);
    BEGIN
    FOR c IN (SELECT po_no FROM B WHERE order_no = p_order_no)
    LOOP
    IF v_po_no IS NULL THEN
    v_po_no := c.po_no;
    ELSE
    v_po_no := v_po_no||','||c.po_no;
    END IF;
    END LOOP;
    RETURN v_po_no;
    END;
    Now you issue the query like this:
    select order_no, company_code, test(order_no) po_no from a;
    This will return you what you want.
    Hope this will help you.
    Best Regards,
    Ramesh Rathi.
    OCP - DBA.
    Zensar Tech Ltd.
    [email protected]
    If I have the following data:
    Table A
    order_no company_code
    O001 C001
    Table B
    order_no po_no
    O001 P001
    O001 P002
    O001 P003
    Now, I want to combine the data as:
    View A
    order_no company_code po_no
    O001 C001 P001, P002, P003
    If can it be realized using SQL?
    Thanks and Best Regards,
    Su Qian

  • Split a ";" delimited record using SQL

    Post Author: GraemeG
    CA Forum: Data Connectivity and SQL
    I receive a string of semi-colon delimited data output by a third-party system. The idea is to drag this record into Crystal and match it up to some reference information in our database and then output it to a Crystal report. We have no programming resources available and don't want the users to have to drag it into Excel (or something similar) first as it would allow them to amend the data before it is reported on.
    So, our plan is to break the record up in a SQL statement, embed that into the report as a command in Database Expert and then do the joins to our database. I'm hoping some clever person on here can tell me how!
    The fields in the data string are variable length and looks something like this:
    W01.COMSTD;3503794;5003711;F01.ANNR;;0:00;;;0;280607;1103;280607;1103;280607;2359;0:00;...etc.
    I would really appreciate any assistance. I have looked at just using the split() command in Crystal but this makes my joins a nightmare.

    Post Author: GraemeG
    CA Forum: Data Connectivity and SQL
    Thanks Jagan. The portal we use (a Lawson embedded version of Infoview) has issues running subreports and Business Objects have acknowledged its a bug... which kinda means I won't have a fix for a while yet. With our new system going live 1 August, I can't afford to wait.
    I was hoping to find a clever SQL statement that would do the same as the split function that I could use to split my data in a DE Command. If there isn't one, I may be forced to take the old RPG book out of mothballs!

Maybe you are looking for

  • Use document as newsletter in email

    I know I can do this with Constant Contact or MailChimp but they don't offer me a lot of design options. What I'd like to do it with Pages in the design mode make a fantastic 1 page newsletter and somehow embed it in an email and send out to clients.

  • Audio to dolby digital surround AC3

    Regards, I have one test sequence in FCP,,, left channel is sound, and right is speech,, then exported separately to two mono channels,,, named SOUND and SPEECH,, I can hear each channel nice after that,, But, when I make AC3 file with compressor, I

  • Link comment to icons objects

    Is it possible to to link comments to objects that it is referring to such as shown in the figure.  This would allow the comment to be moved automatically when i drag the object itself.  I find it cumbersome to have to move the comment and the object

  • How to dismiss ignored spelling check.

    I am not a native English speaker, so you can imaging how I like the Global Spelling Check in MAC OS. I typed "avaliable", which is not right, then when I tried to use the spell correct, I accidently clicked on ingore spelling check on the word, appa

  • VFRB / Billing output issues

    When running retro billing VFRB, entries in NAST (Output) table  has been updated with entries even before the debit or credit documents have been created. So we have entries in NAST with object id  $000000001 and so on instead of the correct billing