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