Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    93

    Red face Unanswered: table alias-renaming columns?

    I am selecting data from tables using table alias and using the ||','|| as I am want my files in CSV format, however when i do the following

    select productcode ||','|| as Station_name, productinfoa ||','|| productinfob
    from product_x;

    I get ora 00936 missing expression, if I leave out the 'as' it doesn't work...how can I rename the colum above so it becomes station name as opposed to product code?

    Cheers
    Cheers
    Etravels

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Code:
    SELECT productcode || ',' as Station_name, 
      productinfoa || ',' productinfob
      FROM product_x;
    You can't have concatenation operater with nothing behind it.

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    I assume that you are using spooling. If so, My select would look like the following.

    SELECT productcode || ','||productinfoa || ',' ||...
    FROM product_x;

    This would produce a single like that would go into the spooled file. This would be a variable length CSV file. If you use individual columns, you will produce a fixed length CSV file.

    If you are doing a select to produce the spooled file, why would you want to setup column aliases anyway. They are completely unnecessry.

    set echo off
    set pagesize 0
    set linesize 200
    set newpage 0
    set verify Off
    set feedback Off
    set trimspool on
    clear columns
    clear breaks
    clear computes

    spool c:\temp\stuff.txt

    SELECT productcode || ','||productinfoa || ',' ||...
    FROM product_x;

    spool off
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •