xref: /PHP-5.3/ext/oci8/tests/lob_020.phpt (revision c7a8bd6a)
1--TEST--
2oci_lob_write()/erase()/read() with CLOBs
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7?>
8--FILE--
9<?php
10
11require dirname(__FILE__).'/connect.inc';
12require dirname(__FILE__).'/create_table.inc';
13
14$ora_sql = "INSERT INTO
15                       ".$schema.$table_name." (Clob)
16                      VALUES (empty_Clob())
17                      RETURNING
18                               clob
19                      INTO :v_clob ";
20
21$statement = oci_parse($c,$ora_sql);
22$clob = oci_new_descriptor($c,OCI_D_LOB);
23oci_bind_by_name($statement,":v_clob", $clob,-1,OCI_B_CLOB);
24oci_execute($statement, OCI_DEFAULT);
25
26var_dump($clob);
27
28$str = "�����this is a biiiig faaat test string. why are you reading it, I wonder? =)";
29var_dump($clob->write($str));
30var_dump($clob->erase(10,20));
31
32oci_commit($c);
33
34$select_sql = "SELECT clob FROM ".$schema.$table_name." FOR UPDATE";
35$s = oci_parse($c, $select_sql);
36oci_execute($s, OCI_DEFAULT);
37
38var_dump($row = oci_fetch_array($s));
39
40var_dump($row[0]->read(2));
41var_dump($row[0]->read(5));
42var_dump($row[0]->read(50));
43
44var_dump($clob->erase());
45var_dump($clob->erase(-10));
46var_dump($clob->erase(10,-20));
47var_dump($clob->erase(-10,-20));
48var_dump($clob->erase(-10,-20, 1));
49
50var_dump(oci_lob_erase($clob));
51var_dump(oci_lob_erase($clob,-10));
52var_dump(oci_lob_erase($clob,10,-20));
53var_dump(oci_lob_erase($clob,-10,-20));
54var_dump(oci_lob_erase($clob,-10,-20, 1));
55
56unset($clob->descriptor);
57var_dump(oci_lob_erase($clob,10,20));
58
59require dirname(__FILE__).'/drop_table.inc';
60
61echo "Done\n";
62
63?>
64--EXPECTF--
65object(OCI-Lob)#%d (1) {
66  ["descriptor"]=>
67  resource(%d) of type (oci8 descriptor)
68}
69int(77)
70int(20)
71array(2) {
72  [0]=>
73  object(OCI-Lob)#%d (1) {
74    ["descriptor"]=>
75    resource(%d) of type (oci8 descriptor)
76  }
77  ["CLOB"]=>
78  object(OCI-Lob)#%d (1) {
79    ["descriptor"]=>
80    resource(%d) of type (oci8 descriptor)
81  }
82}
83string(2) "��"
84string(5) "���th"
85string(50) "is                     st string. why are you read"
86
87Warning: OCI-Lob::erase(): ORA-22990: LOB locators cannot span transactions in %s on line %d
88bool(false)
89
90Warning: OCI-Lob::erase(): Offset must be greater than or equal to 0 in %s on line %d
91bool(false)
92
93Warning: OCI-Lob::erase(): Length must be greater than or equal to 0 in %s on line %d
94bool(false)
95
96Warning: OCI-Lob::erase(): Offset must be greater than or equal to 0 in %s on line %d
97bool(false)
98
99Warning: OCI-Lob::erase() expects at most 2 parameters, 3 given in %s on line %d
100NULL
101
102Warning: oci_lob_erase(): ORA-22990: LOB locators cannot span transactions in %s on line %d
103bool(false)
104
105Warning: oci_lob_erase(): Offset must be greater than or equal to 0 in %s on line %d
106bool(false)
107
108Warning: oci_lob_erase(): Length must be greater than or equal to 0 in %s on line %d
109bool(false)
110
111Warning: oci_lob_erase(): Offset must be greater than or equal to 0 in %s on line %d
112bool(false)
113
114Warning: oci_lob_erase() expects at most 3 parameters, 4 given in %s on line %d
115NULL
116
117Warning: oci_lob_erase(): Unable to find descriptor property in %s on line %d
118bool(false)
119Done
120