mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-25 17:32:07 +01:00
190 lines
4.9 KiB
XML
190 lines
4.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: ed6de1ae20ce16c0c7be0b3fef282b6065bebfac Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry xml:id="function.oci-parse" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>oci_parse</refname>
|
|
<refpurpose>Prépare une requête SQL avec Oracle</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>resource</type><type>false</type></type><methodname>oci_parse</methodname>
|
|
<methodparam><type>resource</type><parameter>connection</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>sql</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Prépare la requête <parameter>sql</parameter> en utilisant la connexion
|
|
<parameter>connection</parameter> et retourne l'identifiant de requête
|
|
qui pourra être utilisé avec les fonctions <function>oci_bind_by_name</function>,
|
|
<function>oci_execute</function>, etc..
|
|
</para>
|
|
<para>
|
|
Les identifiants de requête peuvent être libérés
|
|
en utilisant la fonction <function>oci_free_statement</function>
|
|
ou en définissant la variable correspondante à la valeur
|
|
&null;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>connection</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Un identifiant de connexion Oracle, retourné par la fonction
|
|
<function>oci_connect</function>,
|
|
<function>oci_pconnect</function> ou
|
|
<function>oci_new_connect</function>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>sql</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La requête SQL ou PL/SQL.
|
|
</para>
|
|
<para>
|
|
Les requêtes SQL <emphasis>ne doivent pas</emphasis>
|
|
se terminer par un point-virgule (";"). Les
|
|
requêtes PL/SQL <emphasis>doivent</emphasis> se terminer
|
|
par un point-virgule (";").
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retourne un gestionnaire de requête en cas de succès, ou &false;
|
|
si une erreur survient.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>oci_parse</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
|
|
|
|
// Analyse de la requête. Notez qu'il n'y a pas de point-virgule à la fin de la requête SQL
|
|
$stid = oci_parse($conn, 'SELECT * FROM employees');
|
|
oci_execute($stid);
|
|
|
|
echo "<table border='1'>\n";
|
|
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
|
|
echo "<tr>\n";
|
|
foreach ($row as $item) {
|
|
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "") . "</td>\n";
|
|
}
|
|
echo "</tr>\n";
|
|
}
|
|
echo "</table>\n";
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>oci_parse</function> et une requête PL/SQL</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
/*
|
|
Avant d'exécuter ce code PHP, vous devez créer une procédure stockée en
|
|
SQL*Plus ou SQL Developer:
|
|
|
|
CREATE OR REPLACE PROCEDURE myproc(p1 IN NUMBER, p2 OUT NUMBER) AS
|
|
BEGIN
|
|
p2 := p1 * 2;
|
|
END;
|
|
|
|
*/
|
|
|
|
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
|
|
if (!$conn) {
|
|
$e = oci_error();
|
|
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
|
|
}
|
|
|
|
$p1 = 8;
|
|
|
|
// Lors de l'analyse PL/SQL, il doit y avoir un point-virgule à la fin de la chaîne
|
|
$stid = oci_parse($conn, 'begin myproc(:p1, :p2); end;');
|
|
oci_bind_by_name($stid, ':p1', $p1);
|
|
oci_bind_by_name($stid, ':p2', $p2, 40);
|
|
|
|
oci_execute($stid);
|
|
|
|
print "$p2\n"; // affiche 16
|
|
|
|
oci_free_statement($stid);
|
|
oci_close($conn);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Cette fonction <emphasis>ne valide pas</emphasis> la requête
|
|
<parameter>sql</parameter>. La seule façon de savoir si la
|
|
requête <parameter>sql</parameter> est valide est de l'exécuter.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>oci_execute</function></member>
|
|
<member><function>oci_free_statement</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|