//**************************************************************************** // $Module type: Class // $Module name: cSQLBrowseConnect // $Author : Ben Weijers // Created : 2002-11-02 @ 11:34 // // Description : // // $Rev History: // 2002-11-02 Module header created //**************************************************************************** Use Windows Use CLI.pkg Global_Variable Integer ghoBrowseConnect #Replace ODBC_TABLETYPE 11 #Replace ODBC_TABLECOMMENT 12 //***************************************************************************** //*** ODBCEnumerateTables To *** //*** *** //*** Builds internal table array and returns the number of tables in the *** //*** DSN. *** //***************************************************************************** #COMMAND CLIEnumerateTables R R To R . Call_Driver 0 !1 Function ODBC_ENUMERATE_TABLES Callback 0 Passing !2 CLI$StrDummy CLI$IntDummy Result !4 #ENDCOMMAND //***************************************************************************** //*** ODBCTableName To *** //*** *** //*** Returns the name of the table. *** //***************************************************************************** #COMMAND CLITableName R R To R . Move (Repeat(Character(0), 255)) To !4 GetAddress Of !4 To CLI$IntDummy Call_Driver 0 !1 Function ODBC_TABLE0 Callback 0 Passing CLI$StrDummy CLI$StrDummy CLI$IntDummy Result CLI$IntDummy Call_Driver 0 !1 Function ODBC_TABLENAME Callback 0 Passing CLI$StrDummy CLI$StrDummy !2 Result CLI$IntDummy Get Cstring !4 To !4 #ENDCOMMAND //***************************************************************************** //*** ODBCSchemaName To *** //*** *** //*** Returns the schema name of the table. *** //***************************************************************************** #COMMAND CLISchemaName R R To R . Move (Repeat(Character(0), 255)) To !4 GetAddress Of !4 To CLI$IntDummy Call_Driver 0 !1 Function ODBC_TABLE0 Callback 0 Passing CLI$StrDummy CLI$StrDummy CLI$IntDummy Result CLI$IntDummy Call_Driver 0 !1 Function ODBC_TABLESCHEMA Callback 0 Passing CLI$StrDummy CLI$StrDummy !2 Result CLI$IntDummy Get Cstring !4 To !4 #ENDCOMMAND //*** Table type is a string that can have the following values: //*** "TABLE", //*** "VIEW" //*** "SYSTEM TABLE" //*** "GLOBAL TEMPORARY", //*** "LOCAL TEMPORARY" //*** "ALIAS" //*** "SYNONYM" #COMMAND CLITableType R R To R . Move (Repeat(Character(0), 255)) To !4 GetAddress Of !4 To CLI$IntDummy Call_driver 0 !1 Function ODBC_TABLE0 Callback 0 Passing CLI$StrDummy CLI$StrDummy CLI$IntDummy Result CLI$IntDummy Call_driver 0 !1 Function ODBC_TABLETYPE Callback 0 Passing CLI$StrDummy CLI$StrDummy !2 Result CLI$IntDummy Get Cstring !4 To !4 #ENDCOMMAND #COMMAND CLITableComment R R To R . Move (Repeat(Character(0), 255)) To !4 GetAddress Of !4 To CLI$IntDummy Call_driver 0 !1 Function ODBC_TABLE0 Callback 0 Passing CLI$StrDummy CLI$StrDummy CLI$IntDummy Result CLI$IntDummy Call_driver 0 !1 Function ODBC_TABLECOMMENT Callback 0 Passing CLI$StrDummy CLI$StrDummy !2 Result CLI$IntDummy Get Cstring !4 To !4 #ENDCOMMAND //***************************************************************************** //*** ODBCNumberOfFields To *** //*** *** //*** Returns the number of fields. *** //***************************************************************************** #COMMAND CLIEnumerateFields R R R To R . Call_Driver 0 !1 Function ODBC_NUMBER_FIELDS Callback 0 Passing !2 !3 CLI$IntDummy Result !5 #ENDCOMMAND //***************************************************************************** //*** ODBCFieldName To *** //*** *** //*** Returns the name of the field. *** //***************************************************************************** #COMMAND CLIFieldName R R To R . Move (Repeat(Character(0), 255)) To !4 GetAddress Of !4 To CLI$IntDummy Call_Driver 0 !1 Function ODBC_FIELD_NAME0 Callback 0 Passing CLI$StrDummy CLI$StrDummy CLI$IntDummy Result CLI$IntDummy Call_Driver 0 !1 Function ODBC_FIELD_NAME Callback 0 Passing CLI$StrDummy CLI$StrDummy !2 Result CLI$IntDummy Get Cstring !4 To !4 #ENDCOMMAND Class cSQLBrowseConnect Is An Array Procedure Construct_Object Forward Send Construct_object Property String psDriver Public "" End_Procedure // Construct_Object Procedure End_Construct_Object Forward Send End_Construct_object End_Procedure // End_Construct_Object //*** //*** Function: BrowseConnect //*** Purpose : Call the driver's browse connect function Function BrowseConnect String sInConnStr Returns String String sDriver sOutConnStr Integer iArg iRetval Get psDriver To sDriver If (sDriver <> "") Begin Move (Repeat(" ", 8192)) To sOutConnStr Call_Driver 0 sDriver Function 10003 Callback 0 Passing sInConnStr sOutConnStr iArg Result iRetval End Function_Return sOutConnStr End_Function// BrowseConnect //*** //*** Procedure: ExtractList //*** Purpose : Extract the list from the out connect string. //*** Function ExtractList String sOutConnStr Returns Integer String sItem Integer iStart iEnd Send Delete_Data Move (Pos("{", sOutConnStr)) To iStart While (iStart > 0) Move (Right(sOutConnStr, Length(sOutConnStr) - iStart)) To sOutConnStr If (Left(sOutConnStr, 1) = "}") Move 0 To iStart Else Begin Move (Pos(",", sOutConnStr)) To iStart Move (Pos("}", sOutConnStr)) To iEnd If ((iStart = 0) Or (iEnd < iStart)) Move iEnd To iStart If (iStart > 0) Set Value Item (Item_Count(Self)) To (Left(sOutConnStr, iStart - 1)) If (iStart = iEnd) Move 0 To iStart End // Else Begin Loop Function_Return (Item_Count(Self)) End_Procedure // ExtractList Function DataSources Returns String String sDriver sDataSource sDescription Integer iLength iRetval Get psDriver To sDriver If (sDriver <> "") Begin Move 8192 To iLength Move (Repeat(" ", iLength)) To sDataSource Move (Repeat(" ", iLength)) To sDescription Call_Driver 0 sDRiver Function 10004 Callback 0 Passing sDataSource sDescription iLength Result iRetval End // If (sDriver <> "") Begin Function_Return (sDataSource + "," + sDescription) End_Function// DataSources End_Class // cSQLBrowseConnect Procedure PrintArrayItems Global Integer hoArray Integer iCount iNumItems Get Item_Count Of hoArray To iNumItems For iCount From 0 To (iNumItems - 1) Showln (Right(" " + String(iCount + 1), 3)) " - " (Value(hoArray, iCount)) Loop End_Procedure // PrintArrayItems //*** MSSQL Object oSQLBrowseConnect Is A cSQLBrowseConnect Move Self To ghoBrowseConnect End_Object // oSQLBrowseConnect