ÈçºÎʹÓàecpg

±¾½ÚÌÖÂÛÈçºÎʹÓàecpg ¹¤¾ß£®

Ô¤±àÒëÆ÷

Ô¤±àÒëÆ÷½Ð ecpg£®ÔÚ°²×°¹ýºóËü´æ·ÅÔÚ Postgres bin/ Ŀ¼ÏÂÃ森

¿â

ecpg ¿â½Ð×ö libecpg.a »ò libecpg.so£®ÁíÍ⣬¸Ã¿âÓÃÁË libpq ¿âÓë Postgres ·þÎñÆ÷ͨѶ£¬ËùÒÔÄãÒª½«ÄãµÄ³ÌÐòÓëÕâÁ½¸ö¿âÁ´½Ó£º -lecpg -lpq£®

¿âÀïÃæÓÐһЩ·½·¨ÊÇ"Òþ²Ø"µÄ£¬µ«ÊÇÓÐʱºòÕâЩ·½·¨¿ÉÄÜÌṩ·Ç³£ÓÐÓõÄÐÅÏ¢£®

´íÎó¿ØÖÆ

ÒªÏë¼ì²â´Ó 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];
 /* 0: empty                                         */
 /* 1: OID of processed tuple if applicable          */
 /* 2: number of rows processed in an INSERT, UPDATE */
 /*    or DELETE statement                           */
 /* 3: empty                                         */
 /* 4: empty                                         */
 /* 5: empty                                         */
 char sqlwarn[8];
 /* 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                                         */
 char sqlext[8];
} sqlca;
Èç¹û×îºóÒ»¸öSQL Óï¾ä·¢ÉúÁË´íÎó£¬ÄÇô sqlca.sqlcode ½«ÊÇ·ÇÁãÖµ£®Èç¹û sqlca.sqlcode СÓÚ 0 ÄÇô¾ÍÊÇ·¢ÉúÁËijÖÖÑÏÖصĴíÎó£¬ÏóÊý¾Ý¿â¶¨ÒåÓë²éѯ¶¨Òå²»Ò»Öµȣ®Èç¹û´óÓÚ 0 ÔòÊÇͨ³£µÄ´íÎó£¬Ïó±í²»°üÀ¨ËùÒªÇóµÄÐеȣ®

sqlca.sqlerrm.sqlerrmc ½«°üº¬Ò»¸ö×Ö·û´®ÃèÊö¸Ã´íÎ󣮸Ã×Ö·û´®ÒÔÔ´ÎļþµÄÐкŽáβ¡£

¿ÉÄÜ·¢ÉúµÄ´íÎóÁÐ±í£º
 
-12, Out of memory in line %d.
ͨ³£²»³öÏÖÕâ¸ö´íÎó¡£ÕâÊÇÄãµÄÐéÄâÄÚ´æºÄ¾¡µÄ±êÖ¾¡£
-200, Unsupported type %s on line %d.
ͨ³£²»³öÏÖÕâ¸ö´íÎó£®Õâ±íÃ÷Ô¤±àÒëÆ÷Éú³ÉÁËһЩ¿â£¨º¯Êý£©²»ÈϵõĶ«Î÷£®¿ÉÄÜÄãÔËÐеÄÔ¤±àÒëÆ÷ºÍµ±Ç°¿â²»¼æÈÝ£®
-201, Too many arguments line %d.
ÕâÒâζ×Å Postgres ·µ»ØÁ˱ÈÎÒÃǵÄÆ¥Åä±äÁ¿¸ü¶àµÄ²ÎÊý£®¿ÉÄÜÄã©Á˼¸¸öINTO :var1,:var2-ÁбíÀïµÄËÞÖ÷±äÁ¿£®
-202, Too few arguments line %d.
ÕâÒâζ×Å Postgres ·µ»ØÁ˱ÈÎÒÃǵĶÔÓ¦ËÞÖ÷±äÁ¿ÒªÉٵIJÎÊý£®¿ÉÄÜÄã¶àÊäÈëÁ˼¸¸öINTO :var1,:var2-ÁбíÀïµÄËÞÖ÷±äÁ¿£®
-203, Too many matches line %d.
ÕâÒâζ×Ųéѯ·µ»ØÁ˶à¸öÐУ¬µ«ÄãÉùÃ÷µÄ±äÁ¿²»ÊÇÊý×飮ÄãÖ´ÐÐµÄ SELECT ¿ÉÄܲ»ÊÇΨһµÄ£®
-204, Not correctly formatted int type: %s line %d.
ÕâÒâζ×ÅËÞÖ÷±äÁ¿ÊÇÒ»¸ö int ÀàÐͲ¢ÇÒ Postgres Êý¾Ý¿âÀïµÄ×Ö¶ÎÊÇÁíÒ»ÖÖÀàÐÍ£¬°üº¬×ÅÒ»¸ö²»ÄÜת»»³ÉÒ»¸ö int ÀàÐ͵ÄÊýÖµ£®¿â£¨º¯Êý£©Ê¹Óà strtol ×ö´ËÀàת»»£®
-205, Not correctly formatted unsigned type: %s line %d.
ÕâÒâζ×ÅËÞÖ÷±äÁ¿ÊÇÒ»¸ö unsigned int£¨ÎÞ·ûºÅÕûÊý£©ÀàÐͶøPostgres Êý¾Ý¿âÀïµÄ×Ö¶ÎÊÇÁíÍâÒ»ÖÖÀàÐͲ¢ÇÒ°üº¬Ò»¸ö²»ÄÜת»»³Éunsigned int µÄÊýÖµ£®¿â£¨º¯Êý£©Ê¹Óà strtoul ×öÕâÀàת»»£®
-206, Not correctly formatted floating point type: %s line %d.
ÕâÒâζ×ÅËÞÖ÷±äÁ¿ÊÇÒ»¸ö float £¨¸¡µã£©ÀàÐͶø Postgres Êý¾Ý¿âÀïµÄ×Ö¶ÎÊÇÁíÍâÒ»ÖÖÀàÐͲ¢ÇÒ°üº¬Ò»¸ö²»ÄÜת»»³Éfloat µÄÊýÖµ£®¿â£¨º¯Êý£©Ê¹Óà strtod ×öÕâÀàת»»£®
-207, Unable to convert %s to bool on line %d.
ÕâÒâζ×ÅËÞÖ÷±äÁ¿ÊÇÒ»¸ö bool £¨²¼¶û£©ÀàÐÍ£¬¶ø Postgres Êý¾Ý¿âÀïµÄ×Ö¶ÎÖµ¼È²»ÊÇ 't' Ò²²»ÊÇ 'f'¡£
-208, Empty query line %d.
Postgres ·µ»Ø PGRES_EMPTY_QUERY£¬¿ÉÄܵÄÔ­ÒòÊǸòéѯʵ¼ÊÉÏÊǿյġ£
-220, No such connection %s in line %d.
³ÌÐòÊÔͼ·ÃÎÊÒ»¸ö²»´æÔÚµÄÁª½Ó¡£
-221, Not connected in line %d.
³ÌÐòÊÔͼ·ÃÎÊÒ»¸ö´æÔڵģ¬µ«ÊÇûÓдò¿ªµÄÁª½Ó¡£
-230, Invalid statement name %s in line %d.
ÄãÊÔͼʹÓõÄÓï¾ä»¹Ã»×¼±¸ºÃ¡£
-400, Postgres error: %s line %d.
ijÖÖ Postgres ´íÎ󡣸ÃÏûÏ¢°üº¬À´×Ô Postgres ºó¶ËµÄÐÅÏ¢¡£
-401, Error in transaction processing line %d.
Postgres ¸øÎÒÃǵÄÐźţ¬±íÃ÷ÎÒÃÇÎÞ·¨¿ªÊ¼£¬Ìá½»»òÕ߻ؾí¸ÃÊÂÎñ¡£
-402, connect: could not open database %s.
ÓëÊý¾Ý¿âµÄÁª½ÓÎÞ·¨¹¤×÷¡£
100, Data not found line %d.
²