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