xref: /PHP-8.1/ext/oci8/tests/lob_042.phpt (revision 3e9b53f2)
1--TEST--
2Check various LOB error messages
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require(__DIR__.'/connect.inc');
14require(__DIR__.'/create_table.inc');
15
16$ora_sql = "INSERT INTO
17                       ".$schema.$table_name." (blob)
18                      VALUES (empty_blob())
19                      RETURNING
20                               blob
21                      INTO :v_blob ";
22
23$statement = oci_parse($c,$ora_sql);
24$blob = oci_new_descriptor($c,OCI_D_LOB);
25oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
26oci_execute($statement, OCI_DEFAULT);
27
28var_dump($blob);
29
30var_dump($blob->writeTemporary("test", OCI_D_LOB));
31
32$str = "string";
33var_dump($blob->write($str));
34var_dump($blob->truncate(1));
35var_dump($blob->truncate(1));
36var_dump($blob->truncate(2));
37var_dump($blob->read(2));
38
39var_dump($blob->import("does_not_exist"));
40var_dump($blob->saveFile("does_not_exist"));
41
42try {
43    var_dump($blob->truncate(-1));
44} catch (ValueError $e) {
45    echo $e->getMessage(), "\n";
46}
47
48require(__DIR__.'/drop_table.inc');
49
50echo "Done\n";
51
52?>
53--EXPECTF--
54object(OCILob)#%d (1) {
55  ["descriptor"]=>
56  resource(%d) of type (oci8 descriptor)
57}
58
59Warning: OCILob::writeTemporary(): Invalid temporary lob type: %d in %s on line %d
60bool(false)
61int(6)
62bool(true)
63bool(true)
64
65Warning: OCILob::truncate(): Size must be less than or equal to the current LOB size in %s on line %d
66bool(false)
67
68Warning: OCILob::read(): Offset must be less than size of the LOB in %s on line %d
69bool(false)
70
71Warning: OCILob::import(): Can't open file %s in %s on line %d
72bool(false)
73
74Warning: OCILob::saveFile(): Can't open file %s in %s on line %d
75bool(false)
76OCILob::truncate(): Argument #1 ($length) must be greater than or equal to 0
77Done
78