Table and Trigger are not create by "UpSize".
I learned that UpSize is
not required when adding tables to a PostGreSql database that is used by PGDBE.
The additional fields and tables added by DbfUpSize are only there for ISAM emulation, and an upsized table still performs badly in ISAM mode. Record numbers, Record count, etc. are not always reliable. If I were to create a new project using PostGreSql I think that PGDBE would be a fine database engine if only SQL was used.
I added a lot of tables to my 8.3 PostGreSql installation using the import routine of SqlQuery using the below procedure.
This procedure works with ADSDBE, ODBCDBE or PGDGE, whichever is bound to <oSession>. Try opening some of your tables in SQL mode and then ISAM mode. You can put the windows side by side. They will be opened in new threads. Then you can make comparisons. Press the Alt-D key to get a dot prompt so you can use database navigation commands.
Code: Select all
STATIC FUNCTION _ImportDBF( cTable, cTargetName, self )
LOCAL aStruct, aStructNew, i, aTableType, lGoodUse, bError, ;
oSession := ::sessionDict, cPath, cSavePath := DC_CurPath(), ;
GetList[0], oProgress, oDlg, nCount, nEvery, nRecCount, ;
cVia, lCancelled := .f.
aTableType := DC_DbeType(cTable)
IF 'DBF' $ aTableType[3]
cVia := 'DBFDBE'
ELSEIF 'ADS' $ aTableType[3]
DbeSetDefault('ADSDBE')
DbeInfo( COMPONENT_DATA, ADSDBE_TBL_MODE, ADS_CDX )
DbeInfo( COMPONENT_ORDER, ADSDBE_TBL_MODE, ADS_CDX )
DbeInfo( COMPONENT_DATA, ADSDBE_TABLENAME_IS_ALIAS, .f. )
cPath := DC_Path(cTable)
cVia := ::AdsSessionCreate(cPath)
cTable := DC_Path(cTable,.t.)
DC_ChDir(cPath)
ELSEIF 'FOX' $ aTableType[3]
cVia := 'FOXDBE'
ELSE
DC_WinAlert( 'Unknown Database Type' )
RETURN .f.
ENDIF
bError := ErrorBlock({|e|_Break(e)})
BEGIN SEQUENCE
lGoodUse := .f.
USE (cTable) ALIAS SOURCE EXCLUSIVE VIA (cVia)
lGoodUse := .t.
END SEQUENCE
ErrorBlock(bError)
IF !lGoodUse
DCMSGBOX 'Error opening file: ' + cTable FONT '10.Lucida Console' ;
OWNER AppDeskTop()
RETURN .f.
ENDIF
aStruct := DbStruct()
IF cTargetName = NIL
cTargetName := cTable
ENDIF
cTargetName := MakeSqlTableName(cTargetName)
aStructNew := AClone(aStruct)
IF ::type = 'ODBC'
AEval(aStructNew, {|e,i| aStructNew[i][1] := MakeSqlFieldName(aStructNew[i][1],oSession) })
AEval(aStructNew, {|e,i| aStructNew[i] := MakeSqlFieldType(aStructNew[i], oSession) })
ENDIF
bError := ErrorBlock({|e|_Break(e)})
BEGIN SEQUENCE
lGoodUse := .f.
DbCreate(cTargetName, aStructNew, oSession)
USE (cTargetName) EXCLUSIVE VIA (oSession) ALIAS TARGET NEW
lGoodUse := .t.
END SEQUENCE
ErrorBlock(bError)
IF !lGoodUse
DCMSGBOX 'Error creating table: ' + cTargetName FONT '10.Lucida Console' ;
OWNER AppDeskTop()
RETURN .f.
ENDIF
@ 0,0 DCSAY 'Creating table: ' + cTargetName
@ 2,0 DCPROGRESS oProgress SIZE 80,1 PERCENT COLOR GRA_CLR_CYAN, GRA_CLR_WHITE
@ 4,0 DCPUSHBUTTON CAPTION 'Cancel' SIZE 10,1.2 ;
ACTION {||lCancelled := .t.}
DCREAD GUI FIT TITLE 'Importing Data' PARENT @oDlg EXIT
nRecCount := SOURCE->(RecCount())
nEvery := Int(nRecCount/200)
IF nEvery > 5000
nEvery := 5000
ENDIF
nCount := 0
DO WHILE !SOURCE->(Eof()) .AND. !lCancelled
nCount++
IF nCount%100 == 0
DC_CompleteEvents()
ENDIF
IF nEvery > 0 .AND. nCount%nEvery == 0
DC_GetProgress(oProgress,nCount,nRecCount)
ENDIF
TARGET->(DbAppend())
FOR i:= 1 TO TARGET->(Fcount())
TARGET->(FieldPut(i, SOURCE->(FieldGet(i))))
NEXT
SOURCE->(dbSkip())
ENDDO
TARGET->(DbCommit())
SOURCE->(dbCloseArea())
TARGET->(dbCloseArea())
IF Valtype(cVia) == 'O'
cVia:disconnect()
ENDIF
IF !lCancelled
DCMSGBOX 'Done. ', ;
'Table: ' + cTargetName + ' was created in Database: ' + ::database ;
FONT '10.Lucida Console' OWNER AppDeskTop()
ENDIF
oDlg:destroy()
DC_ChDir(cSavePath)
RETURN .T.