dbread

dbread —

Synopsis

#define             DB_DESCRIP_LEN
enum                db_error_codes;
enum                CompactMethod;
typedef             dbnumber;
typedef             dbwrapper;
typedef             SERIESINFO;
typedef             ODBC_info;
#define             ODBC_MAXCOLS
int                 get_native_db_data                  (const char *dbbase,
                                                         SERIESINFO *sinfo,
                                                         double **Z);
int                 get_remote_db_data                  (const char *dbbase,
                                                         SERIESINFO *sinfo,
                                                         double **Z);
int                 get_pcgive_db_data                  (const char *dbbase,
                                                         SERIESINFO *sinfo,
                                                         double **Z);
int                 get_rats_db_data                    (const char *fname,
                                                         SERIESINFO *sinfo,
                                                         double **Z);
dbwrapper *         read_rats_db                        (FILE *fp);
dbwrapper *         read_pcgive_db                      (FILE *fp);
dbwrapper *         dbwrapper_new                       (int n);
void                dbwrapper_destroy                   (dbwrapper *dw);
double *            compact_db_series                   (const double *src,
                                                         SERIESINFO *sinfo,
                                                         int target_pd,
                                                         CompactMethod method);
double *            expand_db_series                    (const double *src,
                                                         SERIESINFO *sinfo,
                                                         int target_pd);
int                 set_db_name                         (const char *fname,
                                                         int filetype,
                                                         PRN *prn);
const char *        get_db_name                         (void);
int                 set_odbc_dsn                        (const char *line,
                                                         PRN *prn);
int                 db_set_sample                       (const char *s,
                                                         DATAINFO *pdinfo);
int                 db_get_series                       (char *line,
                                                         double ***pZ,
                                                         DATAINFO *datainfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 db_delete_series_by_name            (char *line,
                                                         PRN *prn);
int                 db_delete_series_by_number          (const int *list,
                                                         const char *fname);
void                get_db_padding                      (SERIESINFO *sinfo,
                                                         DATAINFO *pdinfo,
                                                         int *pad1,
                                                         int *pad2);
int                 db_range_check                      (SERIESINFO *sinfo,
                                                         DATAINFO *pdinfo);
int                 check_db_import                     (SERIESINFO *sinfo,
                                                         DATAINFO *pdinfo);
int                 compact_data_set                    (double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int newpd,
                                                         CompactMethod default_method,
                                                         int monstart,
                                                         int repday);
int                 expand_data_set                     (double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int newpd);

Description

Details

DB_DESCRIP_LEN

#define DB_DESCRIP_LEN 72  /* size of array to hold "# description" */


enum db_error_codes

typedef enum {
    DB_MISSING_DATA = E_MAX + 1,
    DB_NO_SUCH_SERIES,
    DB_PARSE_ERROR
} db_error_codes;


enum CompactMethod

typedef enum {
    COMPACT_NONE,
    COMPACT_SUM,
    COMPACT_AVG,
    COMPACT_SOP,
    COMPACT_EOP,
    COMPACT_WDAY,
    COMPACT_MAX
} CompactMethod; 


dbnumber

typedef float dbnumber;


dbwrapper

typedef struct dbwrapper_ dbwrapper;


SERIESINFO

typedef struct SERIESINFO_ SERIESINFO;


ODBC_info

typedef struct ODBC_info_ ODBC_info;


ODBC_MAXCOLS

#define ODBC_MAXCOLS 3


get_native_db_data ()

int                 get_native_db_data                  (const char *dbbase,
                                                         SERIESINFO *sinfo,
                                                         double **Z);

dbbase :
sinfo :
Z :
Returns :

get_remote_db_data ()

int                 get_remote_db_data                  (const char *dbbase,
                                                         SERIESINFO *sinfo,
                                                         double **Z);

dbbase :
sinfo :
Z :
Returns :

get_pcgive_db_data ()

int                 get_pcgive_db_data                  (const char *dbbase,
                                                         SERIESINFO *sinfo,
                                                         double **Z);

dbbase :
sinfo :
Z :
Returns :

get_rats_db_data ()

int                 get_rats_db_data                    (const char *fname,
                                                         SERIESINFO *sinfo,
                                                         double **Z);

Read the actual data values for a series from a RATS database.

fname : name of RATS 4.0 database to read from
sinfo : holds info on the given series (input)
Z : data matrix
Returns : 0 on successful completion, E_FOPEN if the data could not be read, and DB_MISSING_DATA if the data were found but there were some missing values.

read_rats_db ()

dbwrapper *         read_rats_db                        (FILE *fp);

Read the series info from a RATS 4.0 database: read the base block at offset 0 in the data file, and recurse through the directory entries.

fp : pre-opened stream (caller to close it)
Returns : pointer to a dbwrapper containing the series info, or NULL in case of failure.

read_pcgive_db ()

dbwrapper *         read_pcgive_db                      (FILE *fp);

Read the series info from a PcGive database, .in7 file

fp : pre-opened stream (caller to close it)
Returns : pointer to a dbwrapper containing the series info, or NULL in case of failure.

dbwrapper_new ()

dbwrapper *         dbwrapper_new                       (int n);

n :
Returns :

dbwrapper_destroy ()

void                dbwrapper_destroy                   (dbwrapper *dw);

dw :

compact_db_series ()

double *            compact_db_series                   (const double *src,
                                                         SERIESINFO *sinfo,
                                                         int target_pd,
                                                         CompactMethod method);

src :
sinfo :
target_pd :
method :
Returns :

expand_db_series ()

double *            expand_db_series                    (const double *src,
                                                         SERIESINFO *sinfo,
                                                         int target_pd);

src :
sinfo :
target_pd :
Returns :

set_db_name ()

int                 set_db_name                         (const char *fname,
                                                         int filetype,
                                                         PRN *prn);

fname :
filetype :
prn :
Returns :

get_db_name ()

const char *        get_db_name                         (void);

Returns :

set_odbc_dsn ()

int                 set_odbc_dsn                        (const char *line,
                                                         PRN *prn);

line :
prn :
Returns :

db_set_sample ()

int                 db_set_sample                       (const char *s,
                                                         DATAINFO *pdinfo);

s :
pdinfo :
Returns :

db_get_series ()

int                 db_get_series                       (char *line,
                                                         double ***pZ,
                                                         DATAINFO *datainfo,
                                                         gretlopt opt,
                                                         PRN *prn);

line :
pZ :
datainfo :
opt :
prn :
Returns :

db_delete_series_by_name ()

int                 db_delete_series_by_name            (char *line,
                                                         PRN *prn);

line :
prn :
Returns :

db_delete_series_by_number ()

int                 db_delete_series_by_number          (const int *list,
                                                         const char *fname);

list :
fname :
Returns :

get_db_padding ()

void                get_db_padding                      (SERIESINFO *sinfo,
                                                         DATAINFO *pdinfo,
                                                         int *pad1,
                                                         int *pad2);

sinfo :
pdinfo :
pad1 :
pad2 :

db_range_check ()

int                 db_range_check                      (SERIESINFO *sinfo,
                                                         DATAINFO *pdinfo);

sinfo :
pdinfo :
Returns :

check_db_import ()

int                 check_db_import                     (SERIESINFO *sinfo,
                                                         DATAINFO *pdinfo);

sinfo :
pdinfo :
Returns :

compact_data_set ()

int                 compact_data_set                    (double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int newpd,
                                                         CompactMethod default_method,
                                                         int monstart,
                                                         int repday);

Compact the data set from higher to lower frequency.

pZ : pointer to data array.
pdinfo : data information struct.
newpd : target data frequency.
default_method : code for the default compaction method.
monstart : FIXME add explanation.
repday : "representative day" for conversion from daily to weekly data (with method COMPACT_WDAY only).
Returns : 0 on success, non-zero error code on failure.

expand_data_set ()

int                 expand_data_set                     (double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         int newpd);

Expand the data set from lower to higher frequency: an "expert" option. This is supported at present only for expansion from annual to quarterly or monthly, or from quarterly to monthly.

pZ : pointer to data array.
pdinfo : data information struct.
newpd : target data frequency
Returns : 0 on success, non-zero error code on failure.