Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

look::DbExport Class Reference

This class is the meat of the dbexport utility. More...

#include <dbexport.h>

List of all members.

Public Types

enum  SuppressionMode { SUPPRESS_NONE = 0, SUPPRESS_TABLENAME = 1, SUPPRESS_COLUMNNAMES = 2 }
 What header lines want supressing. More...

enum  TextConversionMode { NO_CONVERT = 0, CONVERT_NORMAL, CONVERT_TO_QE }
 How shall we deal with control characters. More...


Public Methods

 DbExport (const LookString &theTableName)
 Constructor. More...

 ~DbExport ()
 Destructor.

void AddOtherTable (const LookString &theTableName)
 Add another table for the select. More...

void SetWhereClause (const LookString &theWhereClause)
 Set a where clause. More...

void SetOrderClause (const LookString &theOrderClause)
 Set an order clause. More...

void SetFloatPrecision (int thePrecision)
 Set the floating point precision. More...

void SetSuppressionMode (int theSuppressionMode)
 Set header lines suppression.

void SetNULLString (const LookString &theString)
 Set string to use as NULL marker (default is "]^NULL^[").

void SetTextConversionMode (TextConversionMode theConversionMode)
 Set control character conversion mode.

void SetDOSLineEnds (bool useCRLF)
bool DoExport (const LookString &theFileName)
 Actually do the export. More...

long GetNRowsExported (void)
 How many rows were exported?


Protected Methods

LookString GenerateSelectString (void)
LookString GetExportString (const DbField *theField)

Protected Attributes

LookString itsTableName
LookStringList itsOtherTables
LookString itsWhereClause
LookString itsOrderClause
int itsFloatPrecision
bool itHasFloatPrecision
int itsHeaderSuppressionMode
TextConversionMode itsTextConversionMode
LookString itsNULLString
LookString itsLFString
DbDescribeTable::ColumnInfoList itsTableColumns
long itsNRowsExported


Detailed Description

This class is the meat of the dbexport utility.

As such, it might not belong here. The intention was to allow other things (eg applications) use the import/export.

This creates a file and puts some data in it. The basic file format is

	TABLENAME\tSQL statement
	Col1\tcol2\tcol3
	r1c1\tr1c2\tr1c3
	r2c1\tr2c2\tr2c3
	

where \t means 'tab'. It is in unix form, ie lines separated by \n.

This is configurable to an extent.

The manual page for dbexport explains quite a lot.


Member Enumeration Documentation

enum look::DbExport::SuppressionMode
 

What header lines want supressing.

These can be ORed together.

If you do suppress any of the header lines, dbimport won't be able to read the file again.

Enumeration values:
SUPPRESS_NONE   Don't suppress
SUPPRESS_TABLENAME   Suppress the tablename line
SUPPRESS_COLUMNNAMES   Suppress the column names line

enum look::DbExport::TextConversionMode
 

How shall we deal with control characters.

If you use NO_CONVERT, dbimport may not be able to read the file.

Enumeration values:
NO_CONVERT   Leave control characters as they were
CONVERT_NORMAL   Tab goes to \t, cr to \r, lf to \n, \ to \
CONVERT_TO_QE   Any string with a control character is wrapped in ", and internal " are converted to "". This is a common windows format.


Constructor & Destructor Documentation

look::DbExport::DbExport ( const LookString & theTableName )
 

Constructor.

This doesn't actually do anything except set up the table name.

Parameters:
theTableName   Table (or view) to export


Member Function Documentation

void look::DbExport::AddOtherTable ( const LookString & theTableName )
 

Add another table for the select.

If you want to do a join in the select statement used for the export, you'll need to add in the table too for the from clause.

Parameters:
theTableName   Either a table or table with an alias Eg "PERIODS" or "PERIODS PD".

bool look::DbExport::DoExport ( const LookString & theFileName )
 

Actually do the export.

Set up everything else first!

Parameters:
theFileName   File name
Returns:
true for success. DbError will be set in case of failure.

void look::DbExport::SetDOSLineEnds ( bool useCRLF ) [inline]
 

Parameters:
useCRLF   true if you want to make the export file have cr/lf (DOS) line ends, false for lf (unix).

void look::DbExport::SetFloatPrecision ( int thePrecision )
 

Set the floating point precision.

Parameters:
thePrecision   The precision to be used when converting floating point numbers retrieved from the database into strings.

void look::DbExport::SetOrderClause ( const LookString & theOrderClause )
 

Set an order clause.

Note that on some databases the order by needs to be in the select list, and so you can't use it.

Parameters:
theOrderClause   This is the order by clause of the select statement used. Nothing clever happens - the string is just used as is.

void look::DbExport::SetWhereClause ( const LookString & theWhereClause )
 

Set a where clause.

Parameters:
theWhereClause   This is the where clause of the select statement used. Nothing clever happens - the string is just used as is. Note it can contain quite complicated bits, eg subselects.


The documentation for this class was generated from the following files:
Generated at Thu Jan 17 12:53:07 2002 for liblookdb by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001