![]() |
Datenbank: Absolute Database • Version: 1 • Zugriff über: 1
SQL ReplaceString
Hi all.
How to write a SQL query to change the text in a table recursively? Here is the code for an operation with a database table:
Delphi-Quellcode:
Thank you very much in advance. :)
try
tab_1.First; while not tab_1.Eof do begin with tab_1 do begin Edit; Application.ProcessMessages; Fieldbyname('URL').value := StringReplace(Fieldbyname('URL').AsString,'.','',[rfReplaceAll, rfIgnoreCase]); Fieldbyname('URL').value := StringReplace(Fieldbyname('URL').AsString,'/','-',[rfReplaceAll, rfIgnoreCase]); Fieldbyname('TEXT').value := StringReplace(tab_2.Fieldbyname('TEXT').AsString,'=','',[rfReplaceAll, rfIgnoreCase]); Application.ProcessMessages; Post; end; tab_1.Next; end; finally frm_convert.Caption := 'PtoP => Done'; end; |
AW: SQL ReplaceString
What is recursively in your example?
Code:
The existence and concrete syntax for 'replace' depends on the RDMS you are using (I am not familiar with ADS). Also, it might be possible to combine the replace-statements in one single update-statement.
update table set URL = replace (URL,'.','')
update table set URL = replace (URL,'/','-') ... |
AW: SQL ReplaceString
Zitat:
Delphi-Quellcode:
Thanks Daniel
Query1.SQL.Clear;
Query1.SQL.Add('Update [tab_1] set [URL] = "REPLACE ([URL], ""."", """")"'); Query1.SQL.Add('Update [tab_1] set [URL] = "REPLACE ([URL], ""/"", ""-"")"'); Query1.ExecSQL; ...... |
AW: SQL ReplaceString
Are you sure it worked? It looks as if you replace the contents of your column 'URL' with a string like 'REPLACE ([URL], ".", "")' and I doubt this is what you want.
|
AW: SQL ReplaceString
Zitat:
Delphi-Quellcode:
??????????????????????????
update produkt set URL = replace (URL,'.','');
=>> [4.8.2014 12:49:11] Executing Query: update produkt set URL = replace (URL,'.',''); [4.8.2014 12:49:11] Token ',' expected, but 'replace' found at line 1, column 38 - Native error: 30222 |
AW: SQL ReplaceString
Absolute Database doesn't kow of an (string-)REPLACE function
![]() If your're sure, that's only one needle:
SQL-Code:
update table set URL = substring ( URL,1, pos('.', URL)-1 ) || substring ( URL, pos('.', URL)+1 );
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:15 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz