test23.ec
上传用户:dgyhgb
上传日期:2007-01-07
资源大小:676k
文件大小:3k
源码类别:

SQL Server

开发平台:

Unix_Linux

  1. /*
  2.  * $Id$
  3.  *
  4.  * This file is a part of GNU SQL Server
  5.  *
  6.  * Copyright (c) 1996, Free Software Foundation, Inc
  7.  * Developed at Institute of System Programming of Russian Academy of Science
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify it under
  10.  * the terms of the GNU General Public License as published by the Free
  11.  * Software Foundation; either version 2 of the License, or (at your option)
  12.  * any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful, but WITHOUT
  15.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  17.  * more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License along with
  20.  * this program; if not, write to the Free Software Foundation, Inc.,
  21.  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  *
  23.  * Contacts: gss@ispras.ru
  24.  */
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include "tests.h"
  28. int
  29. main(void)
  30. {
  31.   char tabname[100],owner[100],credate[100],cretime[100];
  32.   char tabtype[5];
  33.   int untabid,tabd,primindid,nrows;
  34.   short segid,ncols;
  35.   int i = 8;
  36.   EXEC SQL
  37.   DECLARE CURS1 CURSOR FOR
  38.   (
  39.     SELECT TABNAME, OWNER, UNTABID
  40.            --MIN (TABNAME), MAX (OWNER), MIN (UNTABID)
  41.            ,SEGID,PRIMINDID,
  42.            TABTYPE,TABD,CREDATE,CRETIME,NCOLS,NROWS
  43.     FROM DEFINITION_SCHEMA.SYSTABLES
  44. --    WHERE 
  45. --      TABTYPE = '0'
  46. --      TABNAME>='SYSV'
  47. --    AND
  48. --      OWNER = 'dkv'
  49. --     NOT
  50. --      UNTABID BETWEEN 7 AND 10
  51. --      UNTABID = 5
  52.    )
  53.     ORDER BY OWNER, TABNAME, 3 , NROWS
  54.   
  55. ;
  56.   $ WHENEVER SQLERROR GOTO errexit;
  57.   $ WHENEVER NOT FOUND GOTO exit;
  58.   $ open CURS1;
  59.   printf("  owner , tabname , untabid, nrows n");
  60.   while(1)
  61.     {
  62.       $ fetch CURS1 into :tabname,:owner,:untabid ,:segid,:primindid,
  63.                          :tabtype,:tabd,:credate,:cretime,:ncols,:nrows 
  64.                          ;
  65.       printf(" %8s, %15s, %5d, %5dn",owner, tabname , untabid, nrows);
  66. #if 0      
  67.       PRINT_S (tabname, "tabname");
  68.       PRINT_S (owner, "owner");
  69.       PRINT_D (untabid, "untabid");
  70.       PRINT_D (segid, "segid");
  71.       PRINT_D (primindid, "primindid");
  72.       PRINT_D (tabd, "tabd");
  73.       PRINT_S (tabtype, "tabtype");
  74.       PRINT_S (credate, "credate");
  75.       PRINT_S (cretime, "cretime");
  76.       PRINT_D (ncols, "ncols");
  77.       PRINT_D (nrows, "nrows");
  78.       PRINT_END;
  79. #endif
  80.     }
  81.  exit:
  82.   fprintf(stderr,"End of Table SYSTABLESn");
  83.   $ close CURS1;
  84.   $ commit work;
  85.   return 0;
  86. errexit:
  87.   return 0;
  88. }