Professional Web Applications Themes

SQLJ columns names - IBM DB2

I have a SQLJ stored procedure that returns a result set. On the client side I have a application using ODBC to walk through the resultset. When I call the stored procedure, open the cursor, but instead of appear the columns names, appear 1 2 3 ...(columns position) as columns name. I need the column name, not the position of columns. This not happen when I use JDBC instead of SQLJ. Any idea. Thanks. Orlando...

  1. #1

    Default SQLJ columns names

    I have a SQLJ stored procedure that returns a result set. On the
    client side I have a application using ODBC to walk through the
    resultset.
    When I call the stored procedure, open the cursor, but instead of
    appear the columns names, appear 1 2 3 ...(columns position) as
    columns name. I need the column name, not the position of columns.

    This not happen when I use JDBC instead of SQLJ.

    Any idea. Thanks.



    Orlando
    Orlando Irrazabal Guest

  2. #2

    Default Re: SQLJ columns names

    Have you tried modifying your queries to use the "AS" clause?

    For example, if you execute this query:

    select count(*), sum(salary) from my.table

    the result column names will typically be "1" and "2" respectively.

    However, if you write the query this way:

    select count(*) as NUM, sum(salary) as TOTAL from my.table

    the result column names should be "NUM" and "TOTAL".


    A couple of tips to remember about using the "AS" clause:
    - If I remember correctly, the name that you use in the AS clause can't
    exceed 30 characters
    - If you want embedded blanks in the new column name, you need to put that
    name in quotes ("), not apostrophes. For example:

    select count(*) as "NUMBER OF ROWS IN TABLE" from my.table


    I suggest that you try adding the AS clause to a couple of the queries that
    you are executing via ODBC to ensure that this technique works before you
    start changing all of your programs. I haven't written an ODBC or SQLJ
    program in a while so I don't want to waste your time in case this doesn't
    work.

    Rhino

    "Orlando Irrazabal" <oirraza> wrote in message
    news:5015b881.0306271400.eb524a0posting.google.co m...
    > I have a SQLJ stored procedure that returns a result set. On the
    > client side I have a application using ODBC to walk through the
    > resultset.
    > When I call the stored procedure, open the cursor, but instead of
    > appear the columns names, appear 1 2 3 ...(columns position) as
    > columns name. I need the column name, not the position of columns.
    >
    > This not happen when I use JDBC instead of SQLJ.
    >
    > Any idea. Thanks.
    >
    >
    >
    > Orlando

    Rhino Guest

Similar Threads

  1. Class::DBI::Loader. knowing table names and columns
    By Javier M Mora (jamarier) in forum PERL Modules
    Replies: 1
    Last Post: November 29th, 01:15 PM
  2. length of columns names
    By Ph. Chantry in forum Informix
    Replies: 3
    Last Post: November 22nd, 03:40 AM
  3. Array inserts from SQLJ
    By efiryago@profitlogic.com in forum IBM DB2
    Replies: 0
    Last Post: September 8th, 09:17 PM
  4. Problem with SQLJ and Java
    By gianluca in forum IBM DB2
    Replies: 0
    Last Post: August 22nd, 01:25 PM
  5. Performance Issue using SQLJ
    By klh in forum IBM DB2
    Replies: 3
    Last Post: July 31st, 06:50 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139