Laying out SQL from code
stevehurcombe
Posts: 22
Hi,
A common task for me is to take an SQL query from code (which is always on one line) and format it.
Then when the query is OK it's converted back to a single line to be pasted back into the code.
SQL Prompt was going to be my saviour but it trips up with syntax errors.
Specifically it doesn't like the following constructs:
"select * from table where field=" & clause
Let's ignore the SQL injection risk here for a moment as this is a contrived example.
The second more serious problem is:
select * from table where field=?
It's doesn't like the replaceable parameters.
Best regards
Steve
A common task for me is to take an SQL query from code (which is always on one line) and format it.
Then when the query is OK it's converted back to a single line to be pasted back into the code.
SQL Prompt was going to be my saviour but it trips up with syntax errors.
Specifically it doesn't like the following constructs:
"select * from table where field=" & clause
Let's ignore the SQL injection risk here for a moment as this is a contrived example.
The second more serious problem is:
select * from table where field=?
It's doesn't like the replaceable parameters.
Best regards
Steve
Comments
Layout needs valid SQL syntax before formatting your code. The question marks used as replaceable parameter values are treated as invalid characters and therefore the error is thrown.
However, I will log this as a feature request if you may wish and will keep you posted with updates on this feature?
I am sorry but this is how the product is currently designed to work.
Many thanks,
Tanya