I have approx 50 SQL queries in LO Base that I would like to edit/make changes to…
Apart from manually editing each one (time consuming and error-prone) is there, for example, a “Find/Replace” function available within the LO Base Queries panel ?
Any suggestions on how to achieve this would be much appreciated.
Many thanks,
Coder99
PS… running LO 24.8.3.2 on Mac OS 10.15.7 Catalina
When editing bigger queries I will copy the content to a editor (here: Kate, Linux), which is able to format code like SQL and could find and replace all searched content at once.
There is no possibility to do this with internal query editor.
Thanks for the follow-up and I have resorted to doing this…albeit it rather tedious for many complex SQL statements.
An SQL Workbench style facility in the internal query editor would be a “very useful” feature,
Perhaps someone might develop such a feature in future…?
Thanks again…
Most of the features of LO have been created before LO exits. So has been created up to 2011. At this time the most important feature is to integrate internal Firebird well and set status to “no more experimental”.
You could wish an enhancement for SQL-code for a query editor. But you will need a developing person, who has enough time for this…
Hello,
if you just want to replace a string in all queries, you could use a simple basic code like this:
sub Main
replaceStringsInQueries("Surname","SURNAME")
end sub
sub replaceStringsInQueries(oldstring,newstring)
oQueries = Thisdatabasedocument.Datasource.QueryDefinitions
for i = 0 to oQueries.count - 1
oQuery = oQueries(i)
sCommand = oQuery.Command
sNewCommand = replace(sCommand,oldstring,newstring)
oQuery.Command = sNewCommand
oQueries(i) = oQuery
next i
end sub
but be aware, that it would also change Surname_from_anybody to SURNAME_from_anybody in all queries.
So you should test it with a copy of your .odb file
If your SQL names are quoted, you can include the quotes:
replaceStringsInQueries("""Surname""","""SURNAME""")