xref: /PHP-5.6/ext/oci8/tests/coll_019.phpt (revision c7a8bd6a)
1--TEST--
2Test collection Oracle error handling collections and numbers (2)
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7?>
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require(dirname(__FILE__).'/skipif.inc');
10?>
11--FILE--
12<?php
13
14require dirname(__FILE__)."/connect.inc";
15
16$ora_sql = "DROP TYPE ".$type_name;;
17$statement = oci_parse($c,$ora_sql);
18@oci_execute($statement);
19
20
21echo "Test 0\n";
22$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF BLOB";
23$statement = oci_parse($c,$ora_sql);
24oci_execute($statement);
25
26$coll1 = oci_new_collection($c, $type_name);
27
28var_dump($coll1->append('a long string'));              // invalid type for append
29var_dump($coll1->assignElem(1, 'a long string')); 	// invalid type for assignelem()
30var_dump($coll1->getElem(0));
31
32require dirname(__FILE__)."/drop_type.inc";
33
34echo "Test 1\n";
35$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER";
36$statement = oci_parse($c,$ora_sql);
37oci_execute($statement);
38
39$coll1 = oci_new_collection($c, $type_name);
40
41var_dump($coll1->assignElem(1, null));			// invalid location for null
42var_dump($coll1->getElem(0));
43
44echo "Test 2\n";
45var_dump($coll1->assignElem(1, 1234));  		// invalid location for number
46var_dump($coll1->getElem(0));
47
48require dirname(__FILE__)."/drop_type.inc";
49
50echo "Test 3\n";
51$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR2(1)";
52$statement = oci_parse($c,$ora_sql);
53oci_execute($statement);
54
55$coll1 = oci_new_collection($c, $type_name);
56
57var_dump($coll1->assignElem(1, 'abc')); 		// invalid location for string
58var_dump($coll1->getElem(0));
59
60require dirname(__FILE__)."/drop_type.inc";
61
62echo "Test 4\n";
63$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE";
64$statement = oci_parse($c,$ora_sql);
65oci_execute($statement);
66
67$coll1 = oci_new_collection($c, $type_name);
68
69var_dump($coll1->append(1));                   		// invalid date format
70var_dump($coll1->assignElem(1, '01-JAN-06'));  		// invalid location for date
71var_dump($coll1->getElem(0));
72
73require dirname(__FILE__)."/drop_type.inc";
74
75echo "Done\n";
76
77?>
78--EXPECTF--
79Test 0
80
81Notice: OCI-Collection::append(): Unknown or unsupported type of element: 113 in %s on line %d
82bool(false)
83
84Notice: OCI-Collection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d
85bool(false)
86bool(false)
87Test 1
88
89Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
90bool(false)
91bool(false)
92Test 2
93
94Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
95bool(false)
96bool(false)
97Test 3
98
99Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
100bool(false)
101bool(false)
102Test 4
103
104Warning: OCI-Collection::append(): OCI-01840: input value not long enough for date format in %s on line %d
105bool(false)
106
107Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
108bool(false)
109bool(false)
110Done
111