diff options
author | Antony Dovgal <tony2001@php.net> | 2005-12-13 21:43:36 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2005-12-13 21:43:36 +0000 |
commit | 6c65d6df5919f38382d94d6961bd3a8c33f8014d (patch) | |
tree | 4e25af353081fa323f2e1ca770325d8b5a7a7371 | |
parent | 3ce27140dc2a038795dab4e45cd9ea7b77582714 (diff) | |
download | php-git-6c65d6df5919f38382d94d6961bd3a8c33f8014d.tar.gz |
add new test
-rw-r--r-- | ext/oci8/tests/cursor_bind.phpt | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/ext/oci8/tests/cursor_bind.phpt b/ext/oci8/tests/cursor_bind.phpt new file mode 100644 index 0000000000..b89646b340 --- /dev/null +++ b/ext/oci8/tests/cursor_bind.phpt @@ -0,0 +1,97 @@ +--TEST-- +bind and fetch cursor from a statement +--FILE-- +<?php + +require dirname(__FILE__)."/connect.inc"; + +$drop_table = "DROP TABLE ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $drop_table))) { + die("oci_parse(drop) failed!\n"); +} + +@oci_execute($s); + +$create_table = "CREATE TABLE ".$schema.$table_name." (id NUMBER, value VARCHAR(20))"; + +if (!($s = oci_parse($c, $create_table))) { + die("oci_parse(create) failed!\n"); +} + +if (!oci_execute($s)) { + die("oci_execute(create) failed!\n"); +} + +$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)"; + +if (!($s = oci_parse($c, $insert_sql))) { + die("oci_parse(insert) failed!\n"); +} + +for ($i = 0; $i<3; $i++) { + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } +} + +if (!oci_commit($c)) { + die("oci_commit() failed!\n"); +} + + +$sql = " +DECLARE +TYPE curtype IS REF CURSOR; +cursor_var curtype; +BEGIN + OPEN cursor_var FOR SELECT id, value FROM ".$schema.$table_name."; + :curs := cursor_var; +END; +"; + +$stmt = oci_parse($c, $sql); + +$cursor = oci_new_cursor($c); +oci_bind_by_name($stmt, ":curs", $cursor, -1, OCI_B_CURSOR); + +oci_execute($stmt); + +oci_execute($cursor); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); +var_dump(oci_fetch_row($cursor)); + +echo "Done\n"; + +$drop_table = "DROP TABLE ".$schema.$table_name.""; + +if (!($s = oci_parse($c, $drop_table))) { + die("oci_parse(drop) failed!\n"); +} + +@oci_execute($s); + +?> +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} +bool(false) +Done |