Take a look at htis modified method: Why eventually the column "complemento" is…
- User
Take a look at htis modified method: Why eventually the column "complemento" is generated like this (enclosed by double quotes): UPDATE centauro005.endereco SET identificacao = 'Cobrança',tipo_endereco = '1',data_cadastro = '2024-04-30 10:26:01',unidade_origem = '0',logradouro = 'ROD. ARY CAMPANHOLO',numero = 'S/N',"complemento = 'KM 1,5',bairro = 'CARDEAL'",municipio = 'ELIAS FAUSTO',uf = 'SP',cep = '13350000',cod_cidade_ibge = '3514908',pessoa_responsavel = 'Gustavo',referencia = '',codigo_obra = '',endereco_ativo = 'True',end_envio_boleto = 'True',uuid_endereco = 0x0192F9A5FB347FF7A9767DD9133492C3 WHERE endereco_id = 4078 AND cliente_id = 1626;
procedure GenerateUpdateScriptsForOldDataCadastro;
function BytesToHex(const Bytes: TBytes): string; var i: Integer; begin Result := ''; for i := 0 to Length(Bytes) - 1 do Result := Result + IntToHex(Bytes[i], 2); end;
function FormatSQLValue(const Value: Variant; const FieldType: TFieldType): string; begin if VarIsNull(Value) or VarIsEmpty(Value) then Result := 'NULL' else case FieldType of ftString, ftWideString, ftMemo, ftWideMemo, ftFixedChar, ftFixedWideChar: Result := QuotedStr(Trim(VarToStr(Value))); ftDate, ftDateTime, ftTime: Result := QuotedStr(FormatDateTime('yyyy-mm-dd hh:nn:ss', Value)); ftInteger, ftSmallint, ftWord, ftLargeint, ftAutoInc, ftFloat, ftCurrency, ftBCD, ftFMTBcd: Result := VarToStr(Value); ftBytes, ftVarBytes, ftBlob, ftGraphic, ftOraBlob, ftOraClob, ftParadoxOle, ftDBaseOle: if VarIsArray(Value) then Result := '0x' + BytesToHex(Value) else Result := 'NULL'; else Result := QuotedStr(VarToStr(Value)); end; end;
function GenerateSetClause(const FieldName: string; const Value: Variant; FieldType: TFieldType): string; begin Result := FieldName + ' = ' + FormatSQLValue(Value, FieldType); end;
var QueryStore1, QueryStore2: TUniQuery; ScriptFile, ReportFile: TextFile; ScriptFileName, ReportFileName: string; enderecoId, clienteId: Integer; dataCadastro1, dataCadastro2: TDateTime; isStore1Newer: Boolean; FieldList: TStringList; i: Integer; FieldName: string; ValueStore1, ValueStore2: Variant; FieldType: TFieldType; Connection: TUniConnection; Store2Keys: TDictionary<string, TDateTime>; CompositeKey: string; SourceQuery, TargetQuery: TUniQuery; SetClauses: TStringList; sqlUpdate: string; begin ScriptFileName := 'update_data_cadastro.sql'; ReportFileName := 'update_data_cadastro_report.txt';
AssignFile(ScriptFile, ScriptFileName); Rewrite(ScriptFile);
AssignFile(ReportFile, ReportFileName); Rewrite(ReportFile);
QueryStore1 := nil; QueryStore2 := nil; Store2Keys := nil; SourceQuery := nil; TargetQuery := nil; FieldList := nil; SetClauses := nil;
try WriteLn(ReportFile, 'Update Scripts for endereco Records with Older data_cadastro'); WriteLn(ReportFile, 'Generated on: ' + DateTimeToStr(Now)); WriteLn(ReportFile, '--------------------------------------------------------'); WriteLn(ReportFile, '');
code - Assistant