ecpg �λȤ���

13) This section describes how to use the egpc tool.

���Υ��������Ǥ� ecpg �ġ���λȤ�������⤷�ޤ���

�ץ�ץ����å�

15) The preprocessor is called ecpg. After installation it resides in the Postgres bin/ directory.

�ץ�ץ����å��� ecpg �Ȥ���̾���Ǥ��� ���󥹥ȡ��뤹��� Postgres �� bin/ �ǥ��쥯�ȥ���֤���ޤ���

�饤�֥��

17) The ecpg library is called libecpg.a or libecpg.so. Additionally, the library uses the libpq library for communication to the Postgres server so you will have to link your program with -lecpg -lpq.

ecpg �Υ饤�֥��� libecpg.a ���뤤�� libecpg.so �Ȥ���̾���Ǥ��� �ä��Ƥ��Υ饤�֥��� Postgres �����ФȤ��̿��� libpq �饤�֥���Ȥ��Τǡ� �ץ������Υ�󥯤� -lecpg -lpq ����ꤷ�ʤ���Фʤ�ޤ���

18) The library has some methods that are "hidden" but that could prove very useful sometime.

�饤�֥��Ϥ����Ĥ�����̩�Ρץ᥽�åɤ���äƤ��ޤ����� ���줬���Ȥ���������Ω�Ĥ��Ȥ��狼��Ϥ��Ǥ���

���顼����

23) To be able to detect errors from the Postgres server you include a line like

exec sql include sqlca;
in the include section of your file. This will define a struct and a variable with the name sqlca as following:

Postgres ����Υ��顼�򸡽ФǤ���褦�ˤ���ˤϡ�

exec sql include sqlca;
�Τ褦�ʹԤ򥽡����ե�����Υ��󥯥롼����ʬ������Ƥ����ޤ��� ����ϲ��Τ褦�� sqlca �Ȥ���̾���ι�¤�Τ��ѿ���������ޤ���
struct sqlca
{
 char sqlcaid[8];
 long sqlabc;
 long sqlcode;
 struct
 {
  int sqlerrml;
  char sqlerrmc[70];
 } sqlerrm;
 char sqlerrp[8];
 long sqlerrd[6];

24)
 /* 0: empty                                         */
 /* 1: empty                                         */
 /* 2: number of rows processed in an INSERT, UPDATE */
 /*    or DELETE statement                           */
 /* 3: empty                                         */
 /* 4: empty                                         */
 /* 5: empty                                         */
 /* 0: ��                                             */
 /* 1: ��                                             */
 /* 2: INSERT, UPDATE, DELETE ʸ�ǽ������줿�Կ�      */
 /* 3: ��                                             */
 /* 4: ��                                             */
 /* 5: ��                                             */
 char sqlwarn[8];

25)
 /* 0: set to 'W' if at least one other is 'W'       */
 /* 1: if 'W' at least one character string	     */
 /*    value was truncated when it was               */
 /*    stored into a host variable.                  */
 /* 2: empty                                         */
 /* 3: empty                                         */
 /* 4: empty                                         */
 /* 5: empty                                         */
 /* 6: empty                                         */
 /* 7: empty                                         */
 /* 0: ¾�����Ǥ� 'W' �Ǥ���� 'W' �����åȤ���ޤ�   */
 /* 1: 'W' �Ǥ���С��ۥ����ѿ���ʸ���������������� */
 /*    ���ʤ��Ȥ�ҤȤĤ��ͤ�;ʬ���ڤ���Ȥ���Ƥ��� */
 /*    ��                                             */
 /* 2: ��                                             */
 /* 3: ��                                             */
 /* 4: ��                                             */
 /* 5: ��                                             */
 /* 6: ��                                             */
 /* 7: ��                                             */
 char sqlext[8];
} sqlca;

26) If an error occured in the last SQL statement then sqlca.sqlcode will be non-zero. If sqlca.sqlcode is less that 0 then this is some kind of serious error, like the database definition does not match the query given. If it is bigger than 0 then this is a normal error like the table did not contain the requested row. �� if sqlca.sqlcode is less that 0 then �� ..less than 0 then..

ľ���� SQL ʸ�ǥ��顼��ȯ������� sqlca.sqlcode �� 0 �ʳ����ͤˤʤ�ޤ��� �⤷ sqlca.sqlcode �� 0 ��꾮�����ͤǤ���С� �ǡ����١����������Ϳ����줿�䤤��碌�ȹ��פ��ʤ��Ȥ��ä����餫�ο���ʥ��顼�Ǥ��� 0 �����礭���ͤǤ���С� �ơ��֥뤬�׵ᤷ���Ԥ�ޤ�Ǥ��ʤ��ʤɤ����̤Υ��顼�Ǥ���

27) sqlca.sqlerrm.sqlerrmc will contain a string that describes the error. The string ends with the line number in the source file.

sqlca.sqlerrm.sqlerrmc �ˤϥ��顼����������ʸ���󤬴ޤޤ�ޤ��� ʸ����ϥ������ե�������γ������ֹ�ǽ����ޤ���

28) List of errors that can occur:

ȯ�������ǽ���Τ��륨�顼�Υꥹ�ȤǤ���

-12, Out of memory in line %d.�ʥ��꤬­��ޤ��󡧹��ֹ� %d.��

30) Does not normally occur. This is a sign that your virtual memory is exhausted.

�̾��ȯ�����ޤ��󡥤���ϲ��ۥ����Ȥ��Ԥ����Ƥ��ޤä����Ȥ򼨤���ΤǤ���

-200, Unsupported type %s on line %d. ��%s �ϥ��ݡ��Ȥ���Ƥ��ʤ����Ǥ������ֹ� %d.��

32) Does not normally occur. This is a sign that the preprocessor has generated something that the library does not know about. Perhaps you are running incompatible versions of the preprocessor and the library.

�̾��ȯ�����ޤ��� ����ϥ饤�֥����Τ�ʤ�������ץ�ץ����å��������������Ȥ򼨤���ΤǤ��� �����餯�ߴ����Τʤ��С������Υץ�ץ����å��ȥ饤�֥���Ȥä��ΤǤ��礦��

-201, Too many arguments line %d. �ʰ�����¿�����ޤ������ֹ� %d.��

34) This means that Postgres has returned more arguments than we have matching variables. Perhaps you have forgotten a couple of the host variables in the INTO :var1,:var2-list. �� matching variables �򼡹�ˤ��碌�ƥۥ����ѿ�������

������Ѱդ����ۥ����ѿ�����¿���ΰ����� Postgres ���֤������Ȥ��̣���ޤ��� �����餯 INTO :var1,:var2 �ꥹ�Ȥ���Υۥ����ѿ����Ȥ�˺��Ƥ��ޤä��ΤǤ��礦��

-202, Too few arguments line %d. �ʰ�����­��ޤ��󡧹��ֹ� %d.��

36) This means that Postgres has returned fewer arguments than we have host variables. Perhaps you have too many host variables in the INTO :var1,:var2-list.

������Ѱդ����ۥ����ѿ����⾯�ʤ������� Postgres ���֤������Ȥ��̣���ޤ��� �����餯 INTO :var1,:var2 �ꥹ�Ȥ����;ʬ�ʥۥ����ѿ����Ȥ�����ΤǤ��礦��

-203, Too many matches line %d. �ʥޥå������Τ�¿�����ޤ������ֹ� %d.��

38) This means that the query has returned several lines but the variables specified are no arrays. The SELECT you made probably was not unique.

������䤤��碌��ʣ���Ԥ��֤����������ꤷ���ѿ�������ǤϤʤ����Ȥ��̣���ޤ��� ���֤�ȯ�Ԥ��� SELECT ʸ����դˤʤ��ΤǤϤʤ��ä��ΤǤ��礦��

-204, Not correctly formatted int type: %s line %d. ���������ե����ޥåȤ��줿 int ���ǤϤ���ޤ��� : %s �����ֹ� %d.��

40) This means that the host variable is of an int type and the field in the Postgres database is of another type and contains a value that cannot be interpreted as an int. The library uses strtol for this conversion.

����ϥۥ����ѿ��η��� int �Ǥ���ˤ⤫����餺�� Postgres �ǡ����١����Υե�����ɤ�¾�η��Ǥ��ꡤ int �Ȥ��Ʋ��Ǥ��ʤ��ͤ��ޤޤ�Ƥ��뤳�Ȥ��̣���ޤ��� �饤�֥��Ϥ����Ѵ��� strtol ��Ȥ��ޤ���

-205, Not correctly formatted unsigned type: %s line %d. ���������ե����ޥåȤ��줿 unsigned ���ǤϤ���ޤ��� : %s �����ֹ� %d.��

42) This means that the host variable is of an unsigned int type and the field in the Postgres database is of another type and contains a value that cannot be interpreted as an unsigned int. The library uses strtoul for this conversion.

����ϥۥ����ѿ��η��� unsigned int �Ǥ���ˤ⤫����餺�� Postgres �ǡ����١����Υե�����ɤ�¾�η��Ǥ��ꡤ unsigned int �Ȥ��Ʋ��Ǥ��ʤ��ͤ��ޤޤ�Ƥ��뤳�Ȥ��̣���ޤ��� �饤�֥��Ϥ����Ѵ��� strtoul ��Ȥ��ޤ���

-206, Not correctly formatted floating point type: %s line %d. ���������ե����ޥåȤ��줿��ư���������ǤϤ���ޤ��� : %s �����ֹ� %d.��

44) This means that the host variable is of a float type and the field in the Postgres database is of another type and contains a value that cannot be interpreted as an float. The library uses strtod for this conversion.

����ϥۥ����ѿ��η��� float �Ǥ���ˤ⤫����餺�� Postgres �ǡ����١����Υե�����ɤ�¾�η��Ǥ��ꡤ float �Ȥ��Ʋ��Ǥ��ʤ��ͤ��ޤޤ�Ƥ��뤳�Ȥ��̣���ޤ��� �饤�֥��Ϥ����Ѵ��� strtod ��Ȥ��ޤ���

-207, Unable to convert %s to bool on line %d. ��%s ���������ͤ��Ѵ��Ǥ��ޤ��󡧹��ֹ� %d.��

46) This means that the host variable is of a bool type and the field in the Postgres database is neither 't' nor 'f'.

����ϥۥ����ѿ��η��� bool �Ǥ���ˤ⤫����餺�� Postgres �ǡ����١����Υե�����ɤ� 't' �� 'f' �Τ�����Ǥ�ʤ����Ȥ��̣���ޤ���

-208, Empty query line %d. �ʶ����䤤��碌�ԤǤ������ֹ� %d.��

48) Postgres returned PGRES_EMPTY_QUERY, probably because the query indeed was empty.

Postgres �� PGRES_EMPTY_QUERY ���֤��ޤ����� �����餯�䤤��碌���ºݤˤ϶����ä��ΤǤ��礦��

-220, No such connection %s in line %d. ��%s �Ȥ�����³�Ϥ���ޤ��󡧹��ֹ� %d.��

50) The program tries to access a connection that does not exist.

�ץ�����ब¸�ߤ��ʤ���³�˥����������褦�Ȥ��ޤ�����

-221, Not connected in line %d. ����³����Ƥ��ޤ��󡧹��ֹ� %d.��

52) The program tries to access a connection that does exist but is not open.

�ץ�����ब�����������褦�Ȥ�����³��¸�ߤ��ޤ��������ץ�Ϥ���Ƥ��ޤ���

-230, Invalid statement name %s in line %d. ��̵����ʸ��̾���Ǥ� %s �����ֹ� %d��

54) The statement you are trying to use has not been prepared.

�ޤ����� (prepare) ���Ƥ��ʤ�ʸ��Ȥ����Ȥ��ޤ�����

-400, Postgres error: %s line %d. ��Postgres �Υ��顼 %s �����ֹ� %d.��

56) Some Postgres error. The message contains the error message from the Postgres backend.

Postgres �β��餫�Υ��顼�Ǥ��� ���Υ�å������ˤ� Postgres �Хå�����ɤ���Υ��顼��å�������ޤޤ�Ƥ��ޤ���

-401, Error in transaction processing line %d. �ʥȥ�󥶥�����������Υ��顼�����ֹ� %d.��

58) Postgres signalled to us that we cannot start, commit or rollback the transaction.

�ȥ�󥶥������Υ��ߥåȡ����뤤�ϥ�����Хå��򳫻ϤǤ��ʤ��� Postgres ���Τ餻�Ƥ��ޤ�����

-402, connect: could not open database %s. ��connect: �ǡ����١��� %s �򳫤��ޤ����

60) The connect to the database did not work.

�ǡ����١����ؤ���³��ư��ޤ���

100, Data not found line %d. �ʥǡ��������Ĥ���ޤ��󡧹��ֹ� %d.��

62) This is a "normal" error that tells you that what you are quering cannot be found or we have gone through the cursor.

������䤤��碌�򤷤���Τ����Ĥ���ʤ��� ���뤤�ϥ������뤬��ü���̤�᤮���Ȥ��ä������̤Ρץ��顼�Ǥ���