Sqlite3 function to retrieve total number of in ecah table fromthe same db sqlite3
Posted: Sun Jan 19, 2020 10:30 pm
Hello from Spain.
I need to know in each table in the db sqlite3 the total of columns and create a table that replies the format of elements like the columns (INTEGER, TEXT and BOOLEAN).
In DBF enviroment, I use...
local aValFields := {}
aValFields := facmov->( AinitFields( ) ) // Carga CAMPOS perfil
// AinitFields()
function AinitFields()
local nI := 1
local aDbfStr := {}
local aValLocal := {}
aDbfStr := DbStruct()
For nI = 1 to Len( aDbfStr )
cType := aDbfStr[nI][2]
nLen := aDbfStr[nI][3]
Aadd( aValLocal, FieldInit( cType, nLen ) )
Next
return( aValLocal )
// FieldInit( cType, nLen )
function FieldInit( cType, nLen )
local xVar
Do Case
Case cType == 'A'
xVar := {}
Case cType == 'C'
xVar := Replicate( chr(255), nLen )
Case cType == 'D'
xVar := Date()
Case cType == 'L'
xVar := .f.
Case cType == 'M'
xVar := space(1)
Case cType == 'N'
xVar := 0
Case cType == 'U'
Alert('Un campo mal Definido !!!')
xVar := nil
EndCase
return xVar
// Ainit( aArray )
function Ainit( aArray )
local nI := 1
for nI = 1 to Len( aArray )
aArray[ nI ] := VarInit( aArray [ nI ] )
next
return aArray
// VarInit( xVar )
function VarInit( xVar )
Do Case
Case ValType(xVar) == 'A'
xVar := {}
Case ValType(xVar) == 'B'
xVar := { || Cls() }
Case ValType(xVar) == 'C'
xVar := Replicate( space(1), Len( xVar) )
Case ValType(xVar) == 'D'
xVar := Date()
Case ValType(xVar) == 'L'
xVar := .f.
Case ValType(xVar) == 'M'
xVar := space(4096)
Case ValType(xVar) == 'N'
xVar := 0
Case ValType(xVar) == 'O'
xVar := {}
Case ValType(xVar) == 'U'
xVar := nil
EndCase
return xVar
I need to eval sqlite3 number of columns and type of data to create an array for each table.
Please,give some help about.
Thanks.
I need to know in each table in the db sqlite3 the total of columns and create a table that replies the format of elements like the columns (INTEGER, TEXT and BOOLEAN).
In DBF enviroment, I use...
local aValFields := {}
aValFields := facmov->( AinitFields( ) ) // Carga CAMPOS perfil
// AinitFields()
function AinitFields()
local nI := 1
local aDbfStr := {}
local aValLocal := {}
aDbfStr := DbStruct()
For nI = 1 to Len( aDbfStr )
cType := aDbfStr[nI][2]
nLen := aDbfStr[nI][3]
Aadd( aValLocal, FieldInit( cType, nLen ) )
Next
return( aValLocal )
// FieldInit( cType, nLen )
function FieldInit( cType, nLen )
local xVar
Do Case
Case cType == 'A'
xVar := {}
Case cType == 'C'
xVar := Replicate( chr(255), nLen )
Case cType == 'D'
xVar := Date()
Case cType == 'L'
xVar := .f.
Case cType == 'M'
xVar := space(1)
Case cType == 'N'
xVar := 0
Case cType == 'U'
Alert('Un campo mal Definido !!!')
xVar := nil
EndCase
return xVar
// Ainit( aArray )
function Ainit( aArray )
local nI := 1
for nI = 1 to Len( aArray )
aArray[ nI ] := VarInit( aArray [ nI ] )
next
return aArray
// VarInit( xVar )
function VarInit( xVar )
Do Case
Case ValType(xVar) == 'A'
xVar := {}
Case ValType(xVar) == 'B'
xVar := { || Cls() }
Case ValType(xVar) == 'C'
xVar := Replicate( space(1), Len( xVar) )
Case ValType(xVar) == 'D'
xVar := Date()
Case ValType(xVar) == 'L'
xVar := .f.
Case ValType(xVar) == 'M'
xVar := space(4096)
Case ValType(xVar) == 'N'
xVar := 0
Case ValType(xVar) == 'O'
xVar := {}
Case ValType(xVar) == 'U'
xVar := nil
EndCase
return xVar
I need to eval sqlite3 number of columns and type of data to create an array for each table.
Please,give some help about.
Thanks.