A中的数据如果过多呢,这样不太好控制,Pro*C能不能同时连接两个数据库,同时操作

解决方案 »

  1.   

    用database link吗?我没试过.
      

  2.   

    这样子毕竟是折衷的办法,难道同时打开两个数据库,同时操作对Pro*C而言是做不到的吗
      

  3.   

    找到了Multiple Explicit Connections 
    You can use the AT db_name clause for multiple explicit connections, just as you can for a single explicit connection. In the following example, you connect to two non-default databases concurrently: /* declare needed host variables */ 
    char  username[10]   = "scott"; 
    char  password[10]   = "tiger"; 
    char  db_string1[20] = "NYNON1"; 
    char  db_string2[20] = "CHINON"; 
    ... 
    /* give each database connection a unique name */ 
    EXEC SQL DECLARE DB_NAME1 DATABASE; 
    EXEC SQL DECLARE DB_NAME2 DATABASE; 
    /* connect to the two non-default databases */ 
    EXEC SQL CONNECT :username IDENTIFIED BY :password 
       AT DB_NAME1 USING :db_string1; 
    EXEC SQL CONNECT :username IDENTIFIED BY :password 
       AT DB_NAME2 USING :db_string2; 
    The identifiers DB_NAME1 and DB_NAME2 are declared and then used to name the default databases at the two non-default nodes so that later SQL statements can refer to the databases by name. Alternatively, you can use a host variable in the AT clause, as the following example shows: /* declare needed host variables */ 
    char  username[10]   = "scott";
    char  password[10]   = "tiger";
    char  db_name[20];
    char  db_string[20];
    int   n_defs = 3;    /* number of connections to make */
    ...
    for (i = 0; i < n_defs; i++)
    {
        /* get next database name and Net8 string */
        printf("Database name: ");
        gets(db_name);
        printf("Net8) string: ");
        gets(db_string);
        /* do the connect */
        EXEC SQL CONNECT :username IDENTIFIED BY :password
            AT :db_name USING :db_string;
    }
    You can also use this method to make multiple connections to the same database, as the following example shows: strcpy(db_string, "NYNON");
    for (i = 0; i < ndefs; i++)
    {
        /* connect to the non-default database */
        printf("Database name: ");
        gets(db_name);
        EXEC SQL CONNECT :username IDENTIFIED BY :password 
           AT :db_name USING :db_string;
    }
    ... 
    You must use different database names for the connections, even though they use the same Net8 string. However, you can connect twice to the same database using just one database name because that name identifies the default and non-default databases.