Professional Web Applications Themes

Change the database schema without changing the application? - IBM DB2

Hi, I'm writing a C++ application that needs to retrieve a whole row of data from a table, which has 148 columns, to be displayed on the GUI. So I need to declare 148 host variables (HVs) to hold them. If later I need to add more columns to that table, I would have to change both the database schema (to add more columns) and the C++ application (to add more host variables). Is there a way to avoid using HVs in such specific way, so when the db schema is changed, the application does not have to be changed? ...

  1. #1

    Default Change the database schema without changing the application?

    Hi,
    I'm writing a C++ application that needs to retrieve a whole row of
    data from a table, which has 148 columns, to be displayed on the GUI.
    So I need to declare 148 host variables (HVs) to hold them. If later I
    need to add more columns to that table, I would have to change both
    the database schema (to add more columns) and the C++ application (to
    add more host variables). Is there a way to avoid using HVs in such
    specific way, so when the db schema is changed, the application does
    not have to be changed? For example, if I can declare some 'generic'
    HVs (not tied to each column and its type), and define more HVs than I
    need, then I do not need to change the app when I add more columns to
    the table. The trouble is, I do not know what data types the new
    columns may be. Or should I not use HVs at all and use some other
    methods (which I cannot think of any)?

    Thanks in advance for any help.
    minjie Guest

  2. #2

    Default Re: Change the database schema without changing the application?

    minjie <minjieexcite.com> wrote:
    > Hi,
    > I'm writing a C++ application that needs to retrieve a whole row of
    > data from a table, which has 148 columns, to be displayed on the GUI.
    > So I need to declare 148 host variables (HVs) to hold them. If later I
    > need to add more columns to that table, I would have to change both
    > the database schema (to add more columns) and the C++ application (to
    > add more host variables). Is there a way to avoid using HVs in such
    > specific way, so when the db schema is changed, the application does
    > not have to be changed?
    Use an SQLDA instead of explicit host variables:

    EXEC SQL INCLUDE SQLDA;
    EXEC SQL PREPARE stmt FROM :select_stmt;
    EXEC SQL DESCRIBE stmt INTO :sqlda;

    or for insert/update/delete:

    EXEC SQL INCLUDE SQLDA;
    // ... fill SQLDA
    EXEC SQL EXECUTE stmt USING DESCRIPTOR :sqlda;

    --
    Knut Stolze
    Information Integration
    IBM Germany / University of Jena
    Knut Stolze Guest

  3. #3

    Default Re: Change the database schema without changing the application?

    Knut Stolze <stolzede.ibm.com> wrote in message news:<bekhci$408$1fsuj29.rz.uni-jena.de>...
    > minjie <minjieexcite.com> wrote:
    >
    > Use an SQLDA instead of explicit host variables:
    >
    > EXEC SQL INCLUDE SQLDA;
    > EXEC SQL PREPARE stmt FROM :select_stmt;
    > EXEC SQL DESCRIBE stmt INTO :sqlda;
    >
    > or for insert/update/delete:
    >
    > EXEC SQL INCLUDE SQLDA;
    > // ... fill SQLDA
    > EXEC SQL EXECUTE stmt USING DESCRIPTOR :sqlda;
    Thanks a lot for the reply. I was looking into SQLDA thinking that
    there might be something to help me with this question, but the 2nd
    paragragh in Appendix C of SQL Reference Vol 1 (by IBM), which states:
    "SQLDAs are supported for all languages, but predefined declarations
    are provided only for C, REXX, FORTRAN, and COBOL", scared me, because
    I'm using C++. But I guess they include C++ in the same category as C.

    You know everything about DB2. If it's not too much for you to answer,
    can you please recommend a book on DB2 UDB? Thanks.
    Minjie
    minjie Guest

  4. #4

    Default Re: Change the database schema without changing the application?

    minjie <minjieexcite.com> wrote:
    > Knut Stolze <stolzede.ibm.com> wrote in message
    > news:<bekhci$408$1fsuj29.rz.uni-jena.de>...
    >> minjie <minjieexcite.com> wrote:
    >>
    >
    >> Use an SQLDA instead of explicit host variables:
    >>
    >> EXEC SQL INCLUDE SQLDA;
    >> EXEC SQL PREPARE stmt FROM :select_stmt;
    >> EXEC SQL DESCRIBE stmt INTO :sqlda;
    >>
    >> or for insert/update/delete:
    >>
    >> EXEC SQL INCLUDE SQLDA;
    >> // ... fill SQLDA
    >> EXEC SQL EXECUTE stmt USING DESCRIPTOR :sqlda;
    >
    > Thanks a lot for the reply. I was looking into SQLDA thinking that
    > there might be something to help me with this question, but the 2nd
    > paragragh in Appendix C of SQL Reference Vol 1 (by IBM), which states:
    > "SQLDAs are supported for all languages, but predefined declarations
    > are provided only for C, REXX, FORTRAN, and COBOL", scared me, because
    > I'm using C++. But I guess they include C++ in the same category as C.
    C and C++ are practically the same, I'd say. Only minor differences--like
    "class" is a keyword in C++ and not in C--exist.

    What is important for you, however, is that C++ and C have a different name
    mangeling and DB2 expects the C style to be used. So you have to declare
    your C/C++ functions that are called as DB2 UDFs or procedures using
    'external "C"'.
    > If it's not too much for you to answer,
    > can you please recommend a book on DB2 UDB? Thanks.
    I usually refer to (a) the DB2 doentation itself, and (b) Chamberlin's
    book "A complete guide to DB2 Universal Database" (ISBN: 1-55860-482-0).
    The book is not quite up-to-date (it was when version 5 was out), but many
    of the basic concepts are still applicable.

    --
    Knut Stolze
    Information Integration
    IBM Germany / University of Jena
    Knut Stolze Guest

Similar Threads

  1. how to prep database schema
    By pallabi2k@gmail.com in forum MySQL
    Replies: 1
    Last Post: May 25th, 04:31 PM
  2. Configurable database schema
    By Brian G. in forum Coldfusion Database Access
    Replies: 2
    Last Post: November 22nd, 06:01 PM
  3. Dynamically changing Application height & width
    By Gajam in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: August 23rd, 04:05 PM
  4. Loading Database Schema
    By Scott*e in forum Dreamweaver AppDev
    Replies: 1
    Last Post: April 24th, 05:34 PM
  5. Looking for sample code and database schema
    By Jeff Cochran in forum ASP Database
    Replies: 3
    Last Post: February 23rd, 08:11 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