type.pgc

来自「postgresql8.3.4源码,开源数据库」· PGC 代码 · 共 81 行

PGC
81
字号
#include <stdio.h>#include <stdlib.h>EXEC SQL include ../regression;EXEC SQL typedef long mmInteger;EXEC SQL typedef char mmChar;EXEC SQL typedef short mmSmallInt;exec sql type string is char[11];typedef char string[11];exec sql type c is char reference;typedef char* c;EXEC SQL BEGIN DECLARE SECTION;struct TBempl{  mmInteger idnum;  mmChar name[21];  mmSmallInt accs;};EXEC SQL END DECLARE SECTION;intmain (void){  EXEC SQL BEGIN DECLARE SECTION;  struct TBempl empl;  string str;  c ptr = NULL;  struct varchar_vc  {  	int len;	char text[10];  } vc;  EXEC SQL END DECLARE SECTION;  EXEC SQL var vc is varchar[10];  ECPGdebug (1, stderr);  empl.idnum = 1;  EXEC SQL connect to REGRESSDB1;  if (sqlca.sqlcode)    {      printf ("connect error = %ld\n", sqlca.sqlcode);      exit (sqlca.sqlcode);    }  EXEC SQL create table empl    (idnum integer, name char(20), accs smallint, string1 char(10), string2 char(10), string3 char(10));  if (sqlca.sqlcode)    {      printf ("create error = %ld\n", sqlca.sqlcode);      exit (sqlca.sqlcode);    }  EXEC SQL insert into empl values (1, 'user name', 320, 'first str', 'second str', 'third str');  if (sqlca.sqlcode)    {      printf ("insert error = %ld\n", sqlca.sqlcode);      exit (sqlca.sqlcode);    }  EXEC SQL select idnum, name, accs, string1, string2, string3	into :empl, :str, :ptr, :vc	from empl	where idnum =:empl.idnum;  if (sqlca.sqlcode)    {      printf ("select error = %ld\n", sqlca.sqlcode);      exit (sqlca.sqlcode);    }  printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);  EXEC SQL disconnect;  free(ptr);  exit (0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?