Professional Documents
Culture Documents
Declaration of MyModifyStructure
MyModifyStructure is Class
m_sTabela is string
m_nTipo_bd is int
m_ctConection is Connection
PRIVATE
END
Constructor
PROCEDURE Constructor()
Destructor
PROCEDURE Destructor()
Method Verifica
09/07/2023 1
MyModifyStructure
PROCEDURE Verifica()
:Prepara_Dados_Analise()
:Prepara_Dados_Tabela()
:ChecaEstrura()
RESULT True
Method Prepara_Dados_Analise
// Summary: <specify the procedure action>
// Syntax:
// Prepara_Dados_Analise ()
//
// Parameters:
// None
// Return value:
// None
//
// For instance:
// Indicate an example.
//
PROCEDURE Prepara_Dados_Analise()
_Field is string
_Type is string
_Typex is string
_size is string
_dec is string
_dec1 is string
09/07/2023 2
MyModifyStructure
_dec2 is string
IF :m_sTabela = "cad_produto" THEN
s is int = 0
END
Method Prepara_Dados_Tabela
// Summary: <specify the procedure action>
// Syntax:
// Prepara_Dados_Tabela ()
09/07/2023 3
MyModifyStructure
//
// Parameters:
// None
// Return value:
// None
//
// For instance:
// Indicate an example.
//
PROCEDURE Prepara_Dados_Tabela()
SWITCH :m_nTipo_bd
CASE 4 // mysql
dsQRY is Data Source
sCSql is string = [
SHOW FULL COLUMNS FROM '%1'
]
sCSql = StringBuild(sCSql, :m_sTabela)
HExecuteSQLQuery(dsQRY, :m_ctConection , hQueryWithoutCorrection, sCSql)
FOR ALL dsQRY
//1 2 3 4 5 6
ArrayAddLine(m_arrStru_atu ,Lower(dsQRY.field),dsQRY.type,dsQRY.null ,dsQRY.key)
END
CASE 5 // postgres
09/07/2023 4
MyModifyStructure
END
Method ChecaEstrura
// Summary: <specify the procedure action>
// Syntax:
//ChecaEstrura ()
//
// Parameters:
// None
// Return value:
// For instance:
PROCEDURE ChecaEstrura()
npos is int
:sDic_Campo = :m_arrStru_dic[nIFOR,1]
:sDic_Tipo = :m_arrStru_dic[nIFOR,3]
:sDic_Tipox = :ConverteTipoDic(:m_arrStru_dic[nIFOR,3] )
:nDic_Tamanho = :m_arrStru_dic[nIFOR,4]
:nDic_tamx = :m_arrStru_dic[nIFOR,6] // Usado Para pegar o Valor Preciso TAMANHO
:nDic_Decx = :m_arrStru_dic[nIFOR,7] // Usado Para pegar o Valor Preciso DECIMAL
npos = ArraySeek(m_arrStru_atu,asLinearFirst,1,:sDic_Campo)
09/07/2023 5
MyModifyStructure
:MyChangeColumn()
END
END
:MyDropColumn()
Method ConverteTipoDic
// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] ConverteTipoDic (<xType> is string)
//
// Parameters:
// xType (ANSI string):
09/07/2023 6
MyModifyStructure
END
RESULT cvalue
// https://help.windev.com/?3044230&lang=en-US&productversion=xxF260100j
Method ConverteTipoAtu
// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] ConverteTipoAtu (<XType> is string)
//
// Parameters:
// XType (ANSI string):
SWITCH :m_nTipo_bd
CASE 4 // mysql
CASE 5 // postgres
09/07/2023 7
MyModifyStructure
OTHER CASE
END
RESULT cvalue
Method MyAddColumn
// Summary: <specify the procedure action>
// Syntax:
//MyAddColumn ()
//
// Parameters:
// None
// Return value:
// For instance:
PROCEDURE MyAddColumn()
sTexto is string
SWITCH :m_nTipo_bd
CASE 4 // mysql
CASE 5 // postgres
IF :sDic_Tipox = "C" THEN
IF :nDic_Tamanho > 10
sTexto = "ADD COLUMN "+:sDic_Campo+" character varying("+:nDic_Tamanho+") "
ELSE
sTexto = "ADD COLUMN "+:sDic_Campo+" character("+:nDic_Tamanho+") "
END
09/07/2023 8
MyModifyStructure
sTexto = "ADD COLUMN "+:sDic_Campo+" bigint NOT NULL DEFAULT nextval("+ :sDic_Campo +")"
END
OTHER CASE
09/07/2023 9
MyModifyStructure
END
Method MyChangeColumn
// Summary: <specify the procedure action>
// Syntax:
//MyChangeColumn ()
//
// Parameters:
// None
// Return value:
// For instance:
PROCEDURE MyChangeColumn()
sTexto is string
SWITCH :m_nTipo_bd
CASE 4 // mysql
CASE 5 // postgres
09/07/2023 10
MyModifyStructure
END
OTHER CASE
END
Method MyDropColumn
09/07/2023 11
MyModifyStructure
npos is int
sTexto is string
nQtd is int = ArrayCount(m_arrStru_atu)
Method Executa
// Summary: <specify the procedure action>
// Syntax:
// Executa ()
//
// Parameters:
// None
// Return value:
// None
09/07/2023 12
MyModifyStructure
//
// For instance:
// Indicate an example.
//
PROCEDURE Executa()
IF ArrayCount(m_arrMyArray) > 0
sComando is string
FOR nIFOR = 1 _TO_ ArrayCount(m_arrMyArray)
sComando += :m_arrMyArray[nIFOR]+","
END
dsQRY is Data Source
sCSql is string = "ALTER TABLE "+:m_sTabela +" "+ Left(sComando,Length(sComando)-1)
sCSql = Replace(sCSql,"'","`")
09/07/2023 13