xref: /PHP-8.0/ext/oci8/tests/lob_002.phpt (revision ff66e494)
1--TEST--
2oci_lob_write() and friends (with errors)
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');
12
13// Initialization
14
15$stmtarray = array(
16    "drop table lob_002_tab",
17    "create table lob_002_tab (id number, b1 BLOB)",
18);
19
20oci8_test_sql_execute($c, $stmtarray);
21
22$statement = oci_parse($c, "insert into lob_002_tab (id, b1) values (1, empty_blob()) returning b1 INTO :v_blob ");
23$blob = oci_new_descriptor($c,OCI_D_LOB);
24oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
25oci_execute($statement, OCI_DEFAULT);
26
27var_dump($blob);
28
29var_dump($blob->write("test", -1));
30var_dump($blob->write("test", 1000000));
31var_dump($blob->write(str_repeat("test", 10000), 1000000));
32var_dump($blob->tell());
33var_dump($blob->flush());
34
35oci_commit($c);
36
37$select_sql = "select b1 from lob_002_tab where id = 1";
38$s = oci_parse($c, $select_sql);
39oci_execute($s);
40
41$row = oci_fetch_array($s, OCI_RETURN_LOBS);
42
43var_dump(strlen($row[0]));
44
45// Cleanup
46
47$stmtarray = array(
48    "drop table lob_002_tab"
49);
50
51oci8_test_sql_execute($c, $stmtarray);
52
53?>
54--EXPECTF--
55object(OCILob)#%d (1) {
56  ["descriptor"]=>
57  resource(%d) of type (oci8 descriptor)
58}
59int(0)
60int(4)
61int(40000)
62int(40004)
63bool(false)
64int(40004)
65