Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
ecpg-concept.html52 linesDownload Raw Back to html
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>36.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 Vsnapshot" /><link rel="prev" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C" /><link rel="next" href="ecpg-connect.html" title="36.2. Managing Database Connections" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">36.1. The Concept</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Up</a></td><th width="60%" align="center">Chapter 36. <span class="application">ECPG</span> — Embedded <acronym class="acronym">SQL</acronym> in C</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-connect.html" title="36.2. Managing Database Connections">Next</a></td></tr></table><hr /></div><div class="sect1" id="ECPG-CONCEPT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">36.1. The Concept <a href="#ECPG-CONCEPT" class="id_link">#</a></h2></div></div></div><p>3   An embedded SQL program consists of code written in an ordinary4   programming language, in this case C, mixed with SQL commands in5   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 it7   to an ordinary C program (<code class="filename">*.c</code>), and afterwards it can be processed by a C8   compiler.  (For details about the compiling and linking see <a class="xref" href="ecpg-process.html" title="36.10. Processing Embedded SQL Programs">Section 36.10</a>.)9   Converted ECPG applications call functions in the libpq library10   through the embedded SQL library (ecpglib), and communicate with11   the PostgreSQL server using the normal frontend-backend protocol.12  </p><p>13   Embedded <acronym class="acronym">SQL</acronym> has advantages over other methods14   for handling <acronym class="acronym">SQL</acronym> commands from C code. First, it15   takes care of the tedious passing of information to and from16   variables in your <acronym class="acronym">C</acronym> program.  Second, the SQL17   code in the program is checked at build time for syntactical18   correctness.  Third, embedded <acronym class="acronym">SQL</acronym> in C is19   specified in the <acronym class="acronym">SQL</acronym> standard and supported by20   many other <acronym class="acronym">SQL</acronym> database systems.  The21   <span class="productname">PostgreSQL</span> implementation is designed to match this22   standard as much as possible, and it is usually possible to port23   embedded <acronym class="acronym">SQL</acronym> programs written for other SQL24   databases to <span class="productname">PostgreSQL</span> with relative25   ease.26  </p><p>27   As already stated, programs written for the embedded28   <acronym class="acronym">SQL</acronym> interface are normal C programs with special29   code inserted to perform database-related actions.  This special30   code always has the form:31</p><pre class="programlisting">32EXEC 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 the36   global level or within a function.37  </p><p>38   Embedded39   <acronym class="acronym">SQL</acronym> statements follow the case-sensitivity rules of40   normal <acronym class="acronym">SQL</acronym> code, and not those of C. Also they allow nested41   C-style comments as per the SQL standard. The C part of the42   program, however, follows the C standard of not accepting nested comments.43   Embedded <acronym class="acronym">SQL</acronym> statements likewise use SQL rules, not44   C rules, for parsing quoted strings and identifiers.45   (See <a class="xref" href="sql-syntax-lexical.html#SQL-SYNTAX-STRINGS" title="4.1.2.1. String Constants">Section 4.1.2.1</a> and46   <a class="xref" href="sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS" title="4.1.1. Identifiers and Key Words">Section 4.1.1</a> respectively.  Note that47   ECPG assumes that <code class="varname">standard_conforming_strings</code>48   is <code class="literal">on</code>.)49   Of course, the C part of the program follows C quoting rules.50  </p><p>51   The following sections explain all the embedded SQL statements.52  </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg.html" title="Chapter 36. ECPG — Embedded SQL in C">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-connect.html" title="36.2. Managing Database Connections">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 36. <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" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 36.2. Managing Database Connections</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai