static function CreateTable()
TCDelFile('T1')
TCDelFile('T2')
TCDelFile('VIEW1')
DBCreate('T1', {{"FIELD_NAME", "C", 10, 0}, ;
{"FIELD_TYPE" , "C", 10, 0}}, 'TOPCONN')
DBCreate('T2', {{"FIELD_NAME", "C", 10, 0}, ;
{"FIELD_TYPE" , "C", 10, 0}, ;
{"FIELD_ID" , "N", 3, 0}}, 'TOPCONN')
TCViewOne("VIEW1", "T1")
return
user function example()
Local cT2 := "T2"
Local cView1 := "VIEW1"
TCLink()
CreateTable()
// Criação de Indice na Tabela
DBUseArea(.F., 'TOPCONN', cT2, (cT2), .F., .F.)
(cT2)->(DBCreateIndex('T2_IND', 'FIELD_NAME', { || 'FIELD_NAME' }))
IIF(TCCanOpen('T2', 'T2_IND'), CONOUT('TRUE'), CONOUT('FALSE')) // retorna .T., ou seja, tabela e índice existem
DBCloseArea()
// Criação de Indice na View
DBUseArea(.F., 'TOPCONN', cView1, (cView1), .F., .F.)
TCSetVIdx( .T. )
(cView1)->(DBCreateIndex('VIEW1_IND', 'FIELD_NAME'))
TCSetVIdx( .F. )
IIF(TCCanOpen('VIEW1', 'VIEW1_IND'), CONOUT('TRUE'), CONOUT('FALSE')) // retorna .T., ou seja, view e índice existem
DBCloseArea()
TCUnlink()
return