• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Another One For You Budding Oracle Guru's

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Another One For You Budding Oracle Guru's

    I am creating some flat files extracting some data from Oracle using toad, however I would like to put in a header and a footer. Is there a way to add a header row and a footer row to your output ?

    Example of the format of SQL i'm using below:

    SELECT

    ''''field1''''||''''field2''''||''''field3'''' as flat_file

    FROM

    foo

    ORDER Y

    field1

    #2
    Originally posted by Ardesco
    I am creating some flat files extracting some data from Oracle using toad, however I would like to put in a header and a footer. Is there a way to add a header row and a footer row to your output ?

    Example of the format of SQL i'm using below:

    SELECT

    ''''field1''''||''''field2''''||''''field3'''' as flat_file

    FROM

    foo

    ORDER Y

    field1
    Depends what you want your header and footer to be? if it's just text cant you just do: -


    SELECT
    'my lovely header'
    ,''''field1''''||''''field2''''||''''field3''''
    ,'my lovely footer'
    as flat_file

    FROM

    foo

    ORDER Y

    field1
    The pope is a tard.

    Comment


      #3
      Ooops - no that wont work.

      Try
      SELECT
      'my lovely header' from dual
      UNION
      select ''''field1''''||''''field2''''||''''field3''''
      from whatever tables
      where whatever
      order by whatever
      UNION
      select 'my lovely footer' from dual
      as flat_file


      xxx
      The pope is a tard.

      Comment


        #4
        no, no, that wont work either......(I should really learn to think before I type).....
        The pope is a tard.

        Comment


          #5
          Originally posted by SallyAnne
          no, no, that wont work either......(I should really learn to think before I type).....
          Or learn Oracle before you think................

          Comment


            #6
            Originally posted by SallyAnne
            no, no, that wont work either......(I should really learn to think before I type).....
            And whilst you're on, can you explain the SQL92 joins to me? You know, UNION, LEFT, RIGHT, yadda, yadda, yadda...

            Never understood 'em
            The squint, the cocked eye and clenched first are the cornerstones of all Merseyside communication from birth to grave

            Comment


              #7
              It'd be really simple if you just stuck it in a pl/sql package...

              what about this?

              select 'my lovely header'||CHR(13) || CHR(10) from dual
              UNION ALL
              select DISTINCT my_fields
              from my_tables
              where whatever
              UNION ALL
              Select 'my lovely footer'||
              CHR(13) ||
              CHR(10) from dual

              (the CHR(13)||CHR(10) bit is a carriage return - but I dont know if you'll need that).
              The pope is a tard.

              Comment


                #8
                Originally posted by SallyAnne
                It'd be really simple if you just stuck it in a pl/sql package...

                what about this?

                select 'my lovely header'||CHR(13) || CHR(10) from dual
                UNION ALL
                select DISTINCT my_fields
                from my_tables
                where whatever
                UNION ALL
                Select 'my lovely footer'||
                CHR(13) ||
                CHR(10) from dual

                (the CHR(13)||CHR(10) bit is a carriage return - but I dont know if you'll need that).
                I would think run these statements individually without 'union all'

                Comment


                  #9
                  Originally posted by andy
                  I would think run these statements individually without 'union all'

                  I think he wanted to do quite a few without manually editting them.

                  Just plain lazy if you ask me
                  The pope is a tard.

                  Comment


                    #10
                    Originally posted by SallyAnne
                    I think he wanted to do quite a few without manually editting them.

                    Just plain lazy if you ask me
                    Cheers SA will try it out, and it is for a few scripts I can leave with a readme that says run this script and save the output as a flat file. That way others can't screw it up later on (Well OK they can, but it should be much harder...)

                    Comment

                    Working...
                    X