Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: [Q] static data-members (C++) and "static" rows (Oracle)?

Re: [Q] static data-members (C++) and "static" rows (Oracle)?

From: Graham C Thornton <graham.thornton_at_ln.ssw.abbott.com>
Date: Thu, 24 Jun 1999 07:48:53 -0500
Message-ID: <7kt9fv$2n01@news.abbott.com>


Alex Vinokur wrote in message <7kqggn$4bt$1_at_nnrp1.deja.com>...
>
>
>
>Hi,
>
>Is there in Oracle tables something like
> static data-members in C++ classes?
>
>
>Example.
>Here is a C++ class.
>
>//===================================
>#include <string>
>class AAA
>{
> private :
> int a1;
> string a2;
> static int a3;
> static string a4;
>
> public :
> AAA (int a1_i, const string& a2_i)
> {
> a1 = a1_i;
> a2 = a2_i;
> }
> static void set_a3 (int a3_i)
> {
> a3 = a3_i;
> }
> static void set_a4 (const string& a4_i)
> {
> a4 = a4_i;
> }
> // omitted
>};
>int AAA::a1 (0);
>string AAA::a2;
>
>int main ()
>{
>AAA i1 (100, "Paris");
>AAA i2 (50, "London");
>AAA i2 (123, "Madrid");
>AAA i4 (100, "London");
>
> AAA::set_a3 (222);
> AAA::set_a4 ("USA");
>
>
>};
>// omitted
>//===================================
>
>Using Pro*C/C++ Precompiler I would like to create table that contains
> data of all instances of the AAA class and
> data of all static data-members.
>
>I can to create the following table :
>
> Table "AAA-instances"
>-------------------------------------
>| a1 | a2 | a3 | a4 |
>-------------------------------------
>| 100 | Paris | 222 | USA |
>| 50 | London | 222 | USA |
>| 123 | Madrid | 222 | USA |
>| 100 | London | 222 | USA |
>-------------------------------------
>
>But values in a3 and a4 columns are the same values in all tables
>(because a3 and a5 are static data members of the AAA class).
>
>Is there any possibility in Oracle
> not to store static data
> in each row of the "AAA-instances" table?
>
>=================================
>Server : Oracle8
>Development Platform : Pro*C/C++
>=================================
>
> Thanks in advance,
> Alex

Alex,

There is nothing in the table definition that means 'the value of this column
is always taken from the same memory/disk address', but you can emulate it quite effectively.....

You'll need two tables, one with the 'dynamic values', and one with the 'static
values'. A simple join between the two yields all of the possible tupples:

SQL> select * from static_values;

        A3 A4
---------- ----------

       222 USA SQL> select * from dynamic_values;

        A1 A2

---------- --------------------
       100 Paris
        50 London
       123 Madrid
       100 London

SQL> select dv.a1, dv.a2, sv.a3, sv.a4
  2 from dynamic_values dv, static_values sv   3 ;

        A1 A2                           A3 A4
---------- -------------------- ---------- ----------
       100 Paris                       222 USA
        50 London                      222 USA
       123 Madrid                      222 USA
       100 London                      222 USA

You can create a view to hold the above query if that makes it easier. You might also want to investigate a trigger that rejects inserts to the static table since multiple entries and this query would result in a cartesian product.

HTH Graham

--
Empowerment - delegating the responsibility but not the authority.


Opinions expressed do not necessarily reflect those of Abbott Laboratories. Received on Thu Jun 24 1999 - 07:48:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US