C+ MCSDEMO_myCat_qry
C.
C.  Demo NOT using DIF functions to select sky regions.
C.  Use instead a C++ query builder function (via a wrapper) to build
C.  a query string for the actual table, NOT the VIEW created by DIF.
C.
C.  In this demo we assume the queried table has these columns:
C.
C.  htmID_6 RAcs DECcs
C.
C.  See "myCat_qry.cpp".
C.
C.  Optional input params are center and radius/side,
C.  and eventually catalogue.
C.
C. Note: set the "is_circle" variable to 1 to query on a cone rather
C.       then a square.
C.
C.  Example: ./mcsdemo_myCat_qry "20 30 6"
C.           ./mcsdemo_myCat_qry "10 20 16"
C.
C--   LN 24/06/2010: v. 0.1c

      PROGRAM MCSDEMO_myCat_qry
      IMPLICIT NONE

      INCLUDE 'mcs_usrlib.inc'
      INTEGER   status, is_circle, DBExec_qry
      CHARACTER*256 HTMQRY6
      CHARACTER*32 par, coords
      CHARACTER*16 idname, catname

      DATA c_user /'mpe'/, c_password /'mpe2014pass'/,
     .     c_dbname /'mpe2014'/,
     .     coords /'40.0 -80.0 12.0'/,
     .     catname /'UCAC_2orig'/
C--

C- Optional arguments: coords (in "") and catname
      CALL GETARG( 1, par )
      IF (par.NE.' ') THEN
        coords = par
        CALL GETARG( 2, par )
        IF (par.NE.' ') catname = par
      ENDIF
C- The MyCats/TOCats specific query builder (for square or circle)
      is_circle = 0  ! define if square or circle query
      c_query = htmqry6(coords,catname,is_circle)
      write(6,'("The query: "/,A)') c_query

      status = DBExec_qry('localhost')
      IF (status.EQ.0) STOP 'Error in DB operations.'

      CALL FieldInfo(1)

      CALL printValues()
      CALL DBFree

      END
