gooderp18绿色标准版
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

43 lignes
5.0KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>35.1. The Concept</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="ecpg.html" title="Chapter 35. ECPG - Embedded SQL in C" /><link rel="next" href="ecpg-connect.html" title="35.2. Managing Database Connections" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">35.1. The Concept</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg.html" title="Chapter 35. ECPG - Embedded SQL in C">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg.html" title="Chapter 35. ECPG - Embedded SQL in C">Up</a></td><th width="60%" align="center">Chapter 35. <span xmlns="http://www.w3.org/1999/xhtml" class="application">ECPG</span> - Embedded <acronym xmlns="http://www.w3.org/1999/xhtml" class="acronym">SQL</acronym> in C</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-connect.html" title="35.2. Managing Database Connections">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="ECPG-CONCEPT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">35.1. The Concept</h2></div></div></div><p>
  3. An embedded SQL program consists of code written in an ordinary
  4. programming language, in this case C, mixed with SQL commands in
  5. specially marked sections. To build the program, the source code (<code class="filename">*.pgc</code>)
  6. is first passed through the embedded SQL preprocessor, which converts it
  7. to an ordinary C program (<code class="filename">*.c</code>), and afterwards it can be processed by a C
  8. compiler. (For details about the compiling and linking see <a class="xref" href="ecpg-process.html" title="35.10. Processing Embedded SQL Programs">Section 35.10</a>).
  9. Converted ECPG applications call functions in the libpq library
  10. through the embedded SQL library (ecpglib), and communicate with
  11. the PostgreSQL server using the normal frontend-backend protocol.
  12. </p><p>
  13. Embedded <acronym class="acronym">SQL</acronym> has advantages over other methods
  14. for handling <acronym class="acronym">SQL</acronym> commands from C code. First, it
  15. takes care of the tedious passing of information to and from
  16. variables in your <acronym class="acronym">C</acronym> program. Second, the SQL
  17. code in the program is checked at build time for syntactical
  18. correctness. Third, embedded <acronym class="acronym">SQL</acronym> in C is
  19. specified in the <acronym class="acronym">SQL</acronym> standard and supported by
  20. many other <acronym class="acronym">SQL</acronym> database systems. The
  21. <span class="productname">PostgreSQL</span> implementation is designed to match this
  22. standard as much as possible, and it is usually possible to port
  23. embedded <acronym class="acronym">SQL</acronym> programs written for other SQL
  24. databases to <span class="productname">PostgreSQL</span> with relative
  25. ease.
  26. </p><p>
  27. As already stated, programs written for the embedded
  28. <acronym class="acronym">SQL</acronym> interface are normal C programs with special
  29. code inserted to perform database-related actions. This special
  30. code always has the form:
  31. </p><pre class="programlisting">
  32. EXEC SQL ...;
  33. </pre><p>
  34. These statements syntactically take the place of a C statement.
  35. Depending on the particular statement, they can appear at the
  36. global level or within a function. Embedded
  37. <acronym class="acronym">SQL</acronym> statements follow the case-sensitivity rules of
  38. normal <acronym class="acronym">SQL</acronym> code, and not those of C. Also they allow nested
  39. C-style comments that are part of the SQL standard. The C part of the
  40. program, however, follows the C standard of not accepting nested comments.
  41. </p><p>
  42. The following sections explain all the embedded SQL statements.
  43. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-connect.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 35. <span class="application">ECPG</span> - Embedded <acronym class="acronym">SQL</acronym> in C </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 35.2. Managing Database Connections</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1