Annotation of embedaddon/php/ext/oci8/tests/edition_1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Basic test for setting Oracle 11gR2 "edition" attribute
        !             3: --SKIPIF--
        !             4: <?php 
        !             5: if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
        !             6: require(dirname(__FILE__)."/connect.inc");
        !             7: if (strcasecmp($user, "system") && strcasecmp($user, "sys")) {
        !             8:     die("skip needs to be run as a DBA user");
        !             9: }
        !            10: if ($test_drcp) {
        !            11:     die("skip as Output might vary with DRCP");
        !            12: }
        !            13: if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== 1) {
        !            14:        die("skip expected output only valid when using Oracle 11gR2 or greater databases");
        !            15: } else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) {
        !            16:     die("skip test expected to work only with Oracle 11gR2 or greater version of client");
        !            17: }
        !            18: ?>
        !            19: --FILE--
        !            20: <?php
        !            21: 
        !            22: /* In 11.2, there can only be one child edition.  So this test will
        !            23:  * fail to create the necessary editions if a child edition exists
        !            24:  * already 
        !            25:  */
        !            26: 
        !            27: require(dirname(__FILE__)."/conn_attr.inc");
        !            28: 
        !            29: function select_fn($conn) {
        !            30:        $s = oci_parse($conn,"select * from view_ed");
        !            31:        oci_execute($s);
        !            32:        while ($row = oci_fetch_row($s)) {
        !            33:                var_dump($row);
        !            34:        }
        !            35: }
        !            36: /* Create a editon MYEDITION 
        !            37:    create a view view_ed in MYEDITION1.
        !            38:    create the same view 'view_ed' with a different definition in MYEDITION.
        !            39:    select from both the editions and verify the contents. */
        !            40: 
        !            41: set_edit_attr('MYEDITION');
        !            42: $conn = oci_connect('testuser','testuser',$dbase); 
        !            43: if ($conn === false) {
        !            44:     $m = oci_error();
        !            45:     die("Error:" . $m['message']);
        !            46: }
        !            47:     
        !            48: $stmtarray = array(
        !            49:     "drop table edit_tab",
        !            50:     "create table edit_tab (name varchar2(10),age number,job varchar2(50), salary number)",
        !            51:     "insert into edit_tab values('mike',30,'Senior engineer',200)",
        !            52:     "insert into edit_tab values('juan',25,'engineer',100)",
        !            53:     "create or replace editioning view view_ed as select name,age,job from edit_tab",
        !            54: );
        !            55: 
        !            56: oci8_test_sql_execute($conn, $stmtarray);
        !            57: 
        !            58: // Check the current edition of the DB and the contents of view_ed.
        !            59: get_edit_attr($conn);
        !            60: select_fn($conn);
        !            61: 
        !            62: // Create a different version of view_ed in MYEDITION1.
        !            63: set_edit_attr('MYEDITION1');
        !            64: $conn2 = oci_new_connect('testuser','testuser',$dbase); 
        !            65: $stmt = "create or replace editioning view view_ed as select name,age,job,salary from edit_tab";
        !            66: $s = oci_parse($conn2, $stmt);
        !            67: oci_execute($s);
        !            68: 
        !            69: // Check the current edition of the DB and the contents of view_ed.
        !            70: get_edit_attr($conn2);
        !            71: select_fn($conn2);
        !            72: 
        !            73: // Verify the contents in MYEDITION EDITION.
        !            74: echo "version of view_ed in MYEDITION \n";
        !            75: get_edit_attr($conn);
        !            76: select_fn($conn);
        !            77: 
        !            78: clean_up($c);
        !            79: 
        !            80: oci_close($conn);
        !            81: oci_close($conn2);
        !            82: echo "Done\n";
        !            83: 
        !            84: ?>
        !            85: --EXPECTF--
        !            86: The value of edition has been successfully set
        !            87: The value of current EDITION is MYEDITION
        !            88: array(3) {
        !            89:   [0]=>
        !            90:   %unicode|string%(%d) "mike"
        !            91:   [1]=>
        !            92:   %unicode|string%(%d) "30"
        !            93:   [2]=>
        !            94:   %unicode|string%(%d) "Senior engineer"
        !            95: }
        !            96: array(3) {
        !            97:   [0]=>
        !            98:   %unicode|string%(%d) "juan"
        !            99:   [1]=>
        !           100:   %unicode|string%(%d) "25"
        !           101:   [2]=>
        !           102:   %unicode|string%(%d) "engineer"
        !           103: }
        !           104:  The value of edition has been successfully set
        !           105: The value of current EDITION is MYEDITION1
        !           106: array(4) {
        !           107:   [0]=>
        !           108:   %unicode|string%(%d) "mike"
        !           109:   [1]=>
        !           110:   %unicode|string%(%d) "30"
        !           111:   [2]=>
        !           112:   %unicode|string%(%d) "Senior engineer"
        !           113:   [3]=>
        !           114:   %unicode|string%(%d) "200"
        !           115: }
        !           116: array(4) {
        !           117:   [0]=>
        !           118:   %unicode|string%(%d) "juan"
        !           119:   [1]=>
        !           120:   %unicode|string%(%d) "25"
        !           121:   [2]=>
        !           122:   %unicode|string%(%d) "engineer"
        !           123:   [3]=>
        !           124:   %unicode|string%(%d) "100"
        !           125: }
        !           126: version of view_ed in MYEDITION 
        !           127: The value of current EDITION is MYEDITION
        !           128: array(3) {
        !           129:   [0]=>
        !           130:   %unicode|string%(%d) "mike"
        !           131:   [1]=>
        !           132:   %unicode|string%(%d) "30"
        !           133:   [2]=>
        !           134:   %unicode|string%(%d) "Senior engineer"
        !           135: }
        !           136: array(3) {
        !           137:   [0]=>
        !           138:   %unicode|string%(%d) "juan"
        !           139:   [1]=>
        !           140:   %unicode|string%(%d) "25"
        !           141:   [2]=>
        !           142:   %unicode|string%(%d) "engineer"
        !           143: }
        !           144: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>