PODBC Class Reference

PODBC Class The Main ODBC class. More...

`#include <podbc.h>`

Inheritance diagram for PODBC:

## Classes

class | ConnectData
| This class is a multipurpose use class for storing parameters when initiating connection to DataSource. More...
class | Field
class | Row
| This class functions as a simple wrapper of the PODBCStmt class to fetch/Save data to the Datasource. More...
class | Table
| PODBC::Table This is the main Class to access Data returned by a Select Query. More...

## Public Types

Enumerators
enum | FieldTypes { LongVarChar =-1, Binary =-2, VarBinary =-3, LongVarBinary =-4, BigInt =-5, TinyInt =-6, Bit =-7, Guid =-11, Unknown = 0, Char = 1, Numeric = 2, Decimal = 3, Integer = 4, SmallInt = 5, Float = 6, Real = 7, Double = 8, DateTime = 9, VarChar =12, Date =91, Time =92, TimeStamp =93 }
| Raw SQL data type codes Refer <sql.h> SQL_* This list is not inclusive. More...
enum | PwType { oPString, oBOOL, ochar, oshort, oint, olong, odouble, oPBYTEArray, oPInt64, oPTime, oPGUID }
| Converted Pwlib Field Types. More...
enum | DataSources { mySQL, MSSQL, Oracle, IBM_DB2, DBASE, Paradox, Excel, Ascii, Foxpro, MSAccess, postgreSQL }
| Datasources that are supported by this implementation used in the PODBC::DataSource Function. More...
enum | MSSQLProtocols { MSSQLNamedPipes, MSSQLWinSock, MSSQLIPX, MSSQLBanyan, MSSQLRPC }
| MSSQL protocols.If your interested? More...
Public Types inherited from PObject
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...

## Public Member Functions

Constructor/Deconstructor
| PODBC ()
| Constructor. More...
| ~PODBC ()
| Deconstructor. More...
Data Queries
Table | LoadTable (PString table)
| Load a specified Table/Stored Query or General 'SELECT' SQL Query. More...
PBoolean | Query (PString Query)
| Added Information to the DataSource. More...
DataSource Access
PBoolean | DataSource (DataSources Source, ConnectData Data)
| DataSource This is the main function to call to contact a DataSource. More...
virtual PBoolean | Connect (LPCTSTR svSource)
| General Connect Function Custom connection strings should call this to connect Don't ask why its LPCTSTR! More...
PBoolean | Connect_DB2 (PFilePath DBPath)
| Connect to IBM DB2 DataSource. More...
PBoolean | Connect_XLS (PFilePath XLSPath, PString DefDir="")
| Connect to MS Office excel spreadsheet. More...
PBoolean | Connect_TXT (PFilePath TXTPath)
| Connect to an ascii text or cvs file. More...
PBoolean | Connect_FOX (PFilePath DBPath, PString User="", PString Pass="", PString Type="DBF", PBoolean Exclusive=false)
| Connect to a Foxpro dataSource. More...
PBoolean | Connect_MDB (PFilePath MDBPath, PString User="", PString Pass="", PBoolean Exclusive=false)
| Connect to a MS Access *.mdb DataSource. More...
PBoolean | Connect_PDOX (PDirectory DBPath, PDirectory DefaultDir, int version=5)
| Connect to a paradox database datastore. More...
PBoolean | Connect_Oracle (PString Server, PString User="", PString Pass="")
| Connect to an Oracle Datasource. More...
PBoolean | Connect_DBASE (PDirectory DBPath)
| Connect to a DBase DataStore. More...
PBoolean | Connect_MSSQL (PString User="", PString Pass="", PString Host="(local)", PBoolean Trusted=true, MSSQLProtocols Proto=MSSQLNamedPipes)
| Connect to a MS SQL Server. More...
PBoolean | Connect_mySQL (PString User="", PString Pass="", PString Host="localhost", int Port=3306, int Option=0)
| Connect to a mySQL Server. More...
PBoolean | ConnectDB_mySQL (PString DB, PString User="", PString Pass="", PString Host="localhost", int Port=3306, int Option=0)
| Connect to a mySQL Server's specified DataBase. More...
PBoolean | Connect_postgreSQL (PString DB, PString User, PString Pass, PString Host, int Port=5432, int Option=0)
| Connect to a postgreSQL Server. More...
void | Disconnect ()
| General Disconnect from DataSource. More...
Utilities
PStringArray | TableList (PString option="")
| Retrieve a List of Tables in the Datasource use the option field to specify the type of data to access. More...
PBoolean | NeedLongDataLen ()
| Check whether their is a limit to Datalength when obtaining Long Data. More...
virtual void | OnSQLError (PString RetCode, PString RetString)
| OnSQL Error. More...
void | SetPrecision (int Digit)
| Set the Number of Decimal places to round to By Default it is 4. More...
void | SetTimeFormat (PTime::TimeFormat tformat)
| Set the Time Display Format. More...
| operator HDBC ()
| Operator Handle DataBase Connection. More...
Public Member Functions inherited from PObject
virtual | ~PObject ()
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
virtual Comparison | Compare (const PObject &obj) const
| Compare the two objects and return their relative rank. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Public Attributes

PODBC::DataSources | dbase

## Protected Attributes

SQLRETURN | m_nReturn
| Database Type connected to. More...
HENV | m_hEnv
HDBC | m_hDBC

## Additional Inherited Members

Static Public Member Functions inherited from PObject
static const char * | Class ()
| Get the name of the class as a C string. More...
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Detailed Description

PODBC Class The Main ODBC class.

This Class should be used in the there is not a preconfigured DSN setup in the MDAC. This class will use the applicable ODBC drivers to connect to a compliant Datasource. It Supports a wide variety of Datasources but others can added by simply creating your custom connection string and then calling PODBC::Connect. For Defined sources the PODBC::DataSource function should be used.

## Member Enumeration Documentation

enum PODBC::DataSources

Datasources that are supported by this implementation used in the PODBC::DataSource Function.

Enumerator
mySQL |
MSSQL |
Oracle |
IBM_DB2 |
DBASE |
Paradox |
Excel |
Ascii |
Foxpro |
MSAccess |
postgreSQL |

enum PODBC::FieldTypes

Raw SQL data type codes Refer <sql.h> SQL_* This list is not inclusive.

If an item is not listed or Unknown it is treated as a character string.

Enumerator
LongVarChar |
Binary |
VarBinary |
LongVarBinary |
BigInt |
TinyInt |
Bit |
Guid | Boolean.
Unknown |
Char |
Numeric |
Decimal |
Integer |
SmallInt |
Float |
Real |
Double |
DateTime |
VarChar |
Date |
Time | Structure.
TimeStamp | Structure.

enum PODBC::MSSQLProtocols

MSSQL protocols.If your interested?

Enumerator
MSSQLNamedPipes |
MSSQLWinSock |
MSSQLIPX |
MSSQLBanyan |
MSSQLRPC |

enum PODBC::PwType

Converted Pwlib Field Types.

Data is stored as a PString and the pwType enumerator indicates the conversion required on the PODBC::Field.

Enumerator
oPString |
oBOOL |
ochar |
oshort |
oint |
olong |
odouble |
oPBYTEArray |
oPInt64 |
oPTime |
oPGUID |

## Constructor & Destructor Documentation

PODBC::PODBC | ( |  | ) |

Constructor.

PODBC::~PODBC | ( |  | ) |

Deconstructor.

## Member Function Documentation

virtual PBoolean PODBC::Connect | ( | LPCTSTR | svSource | ) |

virtual

General Connect Function Custom connection strings should call this to connect Don't ask why its LPCTSTR!

PBoolean PODBC::Connect_DB2 | ( | PFilePath | DBPath | ) |

Connect to IBM DB2 DataSource.

PBoolean PODBC::Connect_DBASE | ( | PDirectory | DBPath | ) |

Connect to a DBase DataStore.

PBoolean PODBC::Connect_FOX | ( | PFilePath | DBPath,
|  | PString | User = `""`,
|  | PString | Pass = `""`,
|  | PString | Type = `"DBF"`,
|  | PBoolean | Exclusive = `false`
| ) |  |

Connect to a Foxpro dataSource.

PBoolean PODBC::Connect_MDB | ( | PFilePath | MDBPath,
|  | PString | User = `""`,
|  | PString | Pass = `""`,
|  | PBoolean | Exclusive = `false`
| ) |  |

Connect to a MS Access *.mdb DataSource.

PBoolean PODBC::Connect_MSSQL | ( | PString | User = `""`,
|  | PString | Pass = `""`,
|  | PString | Host = `"(local)"`,
|  | PBoolean | Trusted = `true`,
|  | MSSQLProtocols | Proto = `MSSQLNamedPipes`
| ) |  |

Connect to a MS SQL Server.

PBoolean PODBC::Connect_mySQL | ( | PString | User = `""`,
|  | PString | Pass = `""`,
|  | PString | Host = `"localhost"`,
|  | int | Port = `3306`,
|  | int | Option = `0`
| ) |  |

Connect to a mySQL Server.

PBoolean PODBC::Connect_Oracle | ( | PString | Server,
|  | PString | User = `""`,
|  | PString | Pass = `""`
| ) |  |

Connect to an Oracle Datasource.

PBoolean PODBC::Connect_PDOX | ( | PDirectory | DBPath,
|  | PDirectory | DefaultDir,
|  | int | version = `5`
| ) |  |

Connect to a paradox database datastore.

PBoolean PODBC::Connect_postgreSQL | ( | PString | DB,
|  | PString | User,
|  | PString | Pass,
|  | PString | Host,
|  | int | Port = `5432`,
|  | int | Option = `0`
| ) |  |

Connect to a postgreSQL Server.

PBoolean PODBC::Connect_TXT | ( | PFilePath | TXTPath | ) |

Connect to an ascii text or cvs file.

PBoolean PODBC::Connect_XLS | ( | PFilePath | XLSPath,
|  | PString | DefDir = `""`
| ) |  |

Connect to MS Office excel spreadsheet.

PBoolean PODBC::ConnectDB_mySQL | ( | PString | DB,
|  | PString | User = `""`,
|  | PString | Pass = `""`,
|  | PString | Host = `"localhost"`,
|  | int | Port = `3306`,
|  | int | Option = `0`
| ) |  |

Connect to a mySQL Server's specified DataBase.

PBoolean PODBC::DataSource | ( | DataSources | Source,
|  | ConnectData | Data
| ) |  |

DataSource This is the main function to call to contact a DataSource.

Source specifies the Type of DataSource to contact and the Data parameter contain the relevent connection information. You can choose to call this function or use the specific Connection function.

void PODBC::Disconnect | ( |  | ) |

General Disconnect from DataSource.

Table PODBC::LoadTable | ( | PString | table | ) |

Load a specified Table/Stored Query or General 'SELECT' SQL Query.

This function will return a PODBC::Table for further analysis. Do Not Use this Function for any other SQL statements other than SELECT.

PBoolean PODBC::NeedLongDataLen | ( |  | ) |

Check whether their is a limit to Datalength when obtaining Long Data.

virtual void PODBC::OnSQLError | ( | PString | RetCode,
|  | PString | RetString
| ) |  |

inline virtual

OnSQL Error.

PODBC::operator HDBC | ( |  | ) |

inline

Operator Handle DataBase Connection.

References m_hDBC.

PBoolean PODBC::Query | ( | PString | Query | ) |

Added Information to the DataSource.

Use this function if you just want to use a SQL statement to add data to a datasource without retreiving the data itself. ie "UPDATE" "APPEND" "INSERT" queries.

void PODBC::SetPrecision | ( | int | Digit | ) |

Set the Number of Decimal places to round to By Default it is 4.

However if the field decimal places is less then Precision Value the field rounding will be used. This must be set prior to calling LoadTable()

void PODBC::SetTimeFormat | ( | PTime::TimeFormat | tformat | ) |

Set the Time Display Format.

PStringArray PODBC::TableList | ( | PString | option = `""` | ) |

Retrieve a List of Tables in the Datasource use the option field to specify the type of data to access.

ie "TABLE" or "VIEW" (further dev req'd)

## Member Data Documentation

PODBC::DataSources PODBC::dbase

HDBC PODBC::m_hDBC

protected

Referenced by operator HDBC().

HENV PODBC::m_hEnv

protected

SQLRETURN PODBC::m_nReturn

protected

Database Type connected to.

The documentation for this class was generated from the following file:

- podbc.h