Open topic with navigation

TIBCO® Patterns 6.1.2

# Reading a Database From a File in Small Chunks (lkt_open_dbfile)

    The dbread command reads an entire database file, but there might be times when it is desirable to open a file and only read a handful of records at a time.
    dvkerr_t lkt_open_dbfile( lpar_t file, lpar_t parameters,
                              lpar_t *filehandle, lpar_t *dbpars );

`lkt_open_dbfile` is called like `lkt_dbread` but instead of reading records, it creates a special block lpar called a file handle. The contents of this lpar must never be altered directly, but can be passed to lkt_read_records to do the actual reading.

The input lpars for `lkt_open_dbfile` are identical to those of lkt_dbread, with the exception is that LPAR_INT_BATCHSIZE is not supported.

Open files are closed when the associated file handle lpar is destroyed with `lpar_destroy`.

## Input

## host file (required)

is the name of a file from which the database should be read. This must be either an LPAR_STR_CSVFILE or an LPAR_STR_FWFFILE for comma separated value or fixed width field files respectively.

## parameters (optional)

is a list of parameters which describe the file contents. It might contain any of the following lpars (see Reading a Database From a File (lkt_dbread) for descriptions):

| • | LPAR_STR_ENCODING

| • | LPAR_INTARR_RECSRCHFLDS

| • | LPAR_INT_DBNUMFIELDS

| • | LPAR_BOOL_LEADINGKEY

| • | LPAR_INT_KEYFIELD

| • | LPAR_STR_KEYFIELD

| • | LPAR_INT_INITIALKEY

| • | LPAR_BOOL_FNAMESFIRST

| • | LPAR_BOOL_FTYPESFIRST

| • | LPAR_BOOL_DOMAXWORK

| • | LPAR_INT_PARENT_KEYFIELD

| • | LPAR_STR_PARENT_KEYFIELD

## Output

## filehandle (required)

is an opaque block lpar to be used with `lkt_read_records`.

## dbpars (optional)

is a list of database parameters determined from reading the file. These parameters are intended to be passed to the `lkt_dbload` command as the dbpars parameter. Extra parameters can be added to the list as necessary.

Error codes and items returned by lkt_open_dbfile

ARRAYLEN | item that has the wrong length
EXPECTLIST | item that should have been a list type lpar
FILEFORMAT | a line from the file which could not be parsed
IOERROR | LPAR_STR_SYSERROR describing error
PARAMVAL | lpar that contains an illegal value
PARAMCONFLICT | lpar in conflict with an earlier lpar

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO® Patterns

Copyright © 2010-2025. Cloud Software Group, Inc. All Rights Reserved.