コンセプト

8) You write your program in C with some special SQL things. For declaring variables that can be used in SQL statements you need to put them in a special declare section. You use a special syntax for the SQL queries.

C のプログラム作成には少し独特な SQL を使います. 変数を SQL 文の中で使えるよう宣言するには, その変数を特別な宣言セクションに置かなければなりません. また SQL の問い合わせに関しても特別な文法を使います.

9) Before compiling you run the file through the embedded SQL C preprocessor and it converts the SQL statements you used to function calls with the variables used as arguments. Both variables that are used as input to the SQL statements and variables that will contain the result are passed.

まずコンパイルに先立って,ファイルを埋め込み SQL C プリプロセッサに通します.このプリプロセッサは使われている SQL 文を,変数を引数にした関数呼び出しに変換します. ここでは SQL 文への入力に使われている変数と, 結果を格納する変数の両方が渡されます.

10) Then you compile and at link time you link with a special library that contains the functions used. These functions (actually it is mostly one single function) fetches the information from the arguments, performs the SQL query using the ordinary interface (libpq) and puts back the result in the arguments dedicated for output.

次にコンパイルを実行します. リンクする時には使用する関数を含む専用ライブラリをリンクします. これらの関数は(実際には一つの関数だけなのがほとんどですが) 引数から情報を取り出し,通常のインターフェース(libpq) を使って SQL の問い合わせを実行し, 結果を出力用に割り当てた引数に戻します.

11) Then you run your program and when the control arrives to the SQL statement the SQL statement is performed against the database and you can continue with the result. ※ you can continue.. : you → your program と読み替え

続いてプログラムを実行します.制御が SQL 文に到達すると, データベース上で SQL 文が実行されます. プログラムはその結果に基づいて処理を続けてゆくことができます.