diff --git a/reference/oci8/examples.xml b/reference/oci8/examples.xml index b9cf618a20..8e83c0616d 100644 --- a/reference/oci8/examples.xml +++ b/reference/oci8/examples.xml @@ -2,32 +2,47 @@ &reftitle.examples; + + These examples connect as the HR user, which is + the sample "Human Resources" schema supplied with the + Oracle database. The account may need to be unlocked and the + password reset before you can use it. + + + + The examples connect to the XE database on your + machine. Change the connect string to your database before running + the examples. + + + + Basic query - Basic queries in oci8 use a prepare-execute-fetch sequence of steps. - - Basic query - + This shows querying and displaying results. Statements in OCI8 use + a prepare-execute-fetch sequence of steps. + + \n"; while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) { print "\n"; foreach ($row as $item) { - print " ".($item != null ? htmlentities($item) : " ")."\n"; + print " " . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "\n"; } print "\n"; } @@ -46,18 +61,17 @@ oci_close($conn); ?> ]]> - - - - + + + + Inserting with bind variables - Bind variables improve performance by allowing reuse of execution - contexts and caches. Bind variables improve security by - preventing some kinds of SQL Injection problems. - - Inserting with bind variables - + Bind variables improve performance by allowing reuse of execution + contexts and caches. Bind variables improve security by preventing + some kinds of SQL Injection problems. + + ]]> - - - - + + + + Inserting data into a CLOB column - For large data use binary long object (BLOB) or character long object (CLOB) types. - - Inserting data into a CLOB column - + For large data use binary long object (BLOB) or character long + object (CLOB) types. This example uses CLOB. + + save("A very long string"); oci_commit($conn); @@ -131,27 +146,27 @@ $query = 'SELECT myclob FROM mytable WHERE mykey = :mykey'; $stid = oci_parse ($conn, $query); oci_bind_by_name($stid, ":mykey", $mykey, 5); -oci_execute($stid, OCI_DEFAULT); +oci_execute($stid); print ''; while ($row = oci_fetch_array($stid, OCI_ASSOC)) { - $result = $row['MYCLOB']->load(); - print ''; + $result = $row['MYCLOB']->load(); + print ''; } print '
'.$result.'
'.$result.'
'; ?> ]]> -
-
- - + + + + Using a PL/SQL stored function - You can easily access stored PL/SQL functions and procedures. - - Using a stored function - + You must bind a variable for the return value and optionally for + any PL/SQL function arguments. + + '; $conn = oci_connect('hr', 'welcome', 'localhost/XE'); if (!$conn) { $e = oci_error(); - trigger_error(htmlentities($e['message']), E_USER_ERROR); + trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $p = 8; @@ -187,15 +202,15 @@ oci_close($conn); ?> ]]> - - - - + + + + Using a PL/SQL stored procedure - - Using a stored procedure - + With stored procedures, you should bind variables for any arguments. + + ]]> - - - + +