NAME:
  sc_region

 PURPOSE:
  Extract a region of a star catalog about some location.

 DESCRIPTION:
  Generates a temporary table in the database of stars that are in a
  region of the sky centered on the input coordinates.  Also generates a new
  field tangsep in the table that is the distance in radians from the
  point specified by ra/dec to the object in the given record.

 CATEGORY:
  Database

 CALLING SEQUENCE:
  sc_region, db, ra, dec, radius, tmptbl

 INPUTS:
  db     - handle to an open mysql ddatabase
  ra     - ra of serach location  (radians)
  dec    - dec of serach location  (radians)
  radius - maximum disance from ra/dec to look (radians)

 OPTIONAL INPUT PARAMETERS:

 KEYWORD INPUT PARAMETERS:
  MAG_MIN - faint limit of star magnitude to return (eg. 12.0)
  MAG_MAX - bright limit of star magnitude to return (eg. -3.0)
  SCLASS  - Spectral classification, as a regexp
               (eg. [ab]0 for a0 and b0 class)
               default is to return all types.
  TBLNAME - Name of table to query in the DB, default='ppm_catalog'

 OUTPUTS:
  tmptbl - name of temporary table that was created  

 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
  Send 'DROP TABLE '+tmptbl+';' to mysql to close the table when you
   are done with it.  The temporary table will disappear once the handle 
   to the database is droped.
 MODIFICATION HISTORY:
  2002/02/07, Writen by David Tucker
  2002/02/19, DT, expanded to sc_region and sc_nearest
  2014/02/18, MWB, fixed a long-standing problem with a small number of inputs