;+
; Project     :	SOHO - CDS
;
; Name        :	FIX_SERIES_ID()
;
; Purpose     :	Updates series_id database with block of new series tables.
;
; Explanation : Enters block of new series tables into series_id database.
;
; Use         : <fix_series_id, tables>
;
; Inputs      : tables = structure array containing series tables info.
;                 tags used :
;                    .cdhsid = the internal CDHS ID used to reference the table
;                    .vs     = character string indicating the software version
;                              of the code used to create the table.
;                    .id     = integer planning database ID for the table.
;                    .var    = integer planning database variation for the table.
;                    .reus   = a character indicating whether the table is re-usable 
;                    .sft    = a character indicating whether solar feature tracking
;                              is to be used. 
;                    .istate = structure containing initial state of study information.
;                    .rpt    = character indicating whether series is to be repeated 
;                              indefinitely.
;                    .repn   = integer giving no. of times to repeat last raster
;                              and IEF flags.
;                    .range  = integer giving acceptable range from home position
;                              of mirror and slit pointing adjustments
;                    .dsolx  = deferred solar x pointing for study
;                    .dsoly  = deferred solar y pointing for study
;                    .flagst = character indicating whether flag study or not
;                    .nextst = cdhs id of next study
;
; Opt. Inputs : None.
;
; Outputs     : None.
;
; Opt. Outputs:	None.
;
; Keywords    : None.
;
; Calls       :	dbopen, dbbuild, dbclose, get_utc.
;                
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	None.
;
; Category    :	Command preparation.
;
; Prev. Hist. :	Adapted from get_series_id.
;
; Written     :	Version 0.0, Martin Carter, RAL, 9/10/96
;
; Modified    :	None.
;
; Version     :	Version 0.0, 9/10/96
;-
;**********************************************************

PRO fix_series_id, tables

  ; set priviledge to update database

  !PRIV = 2

  ; open table ID database for updating

  dbopen, 'dseries_id', 1

  ; Get current utc time in string format

  get_utc, timenow, /ECS

  ; create new entries in database

  dbbuild, REPLICATE(timenow, N_ELEMENTS(tables)), $
                    tables.vs, tables.cdhsid, tables.id, tables.var,                     $
                    tables.reus, tables.sft, tables.istate.solarx, tables.istate.solary, $
                    tables.istate.slitn, tables.istate.gsetid, tables.rpt, tables.repn,  $
                    tables.range, tables.dsolx, tables.dsoly, tables.nextst, tables.flagst, $
                    /SILENT

  ; close table ID database

  dbclose, 'dseries_id'

  ; reset priviledges

  !PRIV = 1  

END


