Don;t think you can format it in exactly the way you want it but one way to make the code more readable is to break thew SQL statement into a series of constants and string them together to create the complete statement. For example;
Thank you for the Lessons I get the idea. I have several questions?
1 will any of the recommendation impact the sql query execution performance +/=
2 is it good idea or not to call queries that reside on the server side?
thank you again
John
I can't see any of the suggestions impacting the query processing. They are all simply ways of building up a string in a variable, which you then use in your query. There likely is some impact on the time to build up the string, but I would imagine it would be imperceptible.
As to whether using server-side queries are "a good idea", it really depends on what you are doing in any specific situation. The question is usually really more about where the database is (local, or server) and how the application is to work overall.
Thank you
lets say I like to have all queries on the server side. How can I possible pass the criteria row from LC field to the SQL querie on the server side
for ex:
As Adrian noted, the answer to whether to execute the queries on the server depends on a lot of things. How sensitive is your data? Do you care if your database gets hacked via SQL injection? And many others.
The simplest thing you can do to protect your security is to to use the variables list parameter to revDataFromQuery, etc. The dictionary entry explains that but here's an example. Insetad of "SELECT * FROM Projects Where StartDate='2016-02-26'", you would use "SELECT * FROM Projects WHERE StartDate=:1". You would then have a variable named, for example, tStartDate which would contain the date. Your call to revDataFromQuery would look like this:
put revDataFromQuery(,,gDBID,"SELECT * FROM Projects WHERE StartDate=:1","tStartDate") into tData
The result of this is that the SELECT statement and the start date value are sent to your server as separate communications. That protects you from SQL injection attack and also ahs the side benefit that you don;t have to write code to escape quote characters, etc in and data strings.
There are solutions with various levels of complexity after that. The most complex system I have implemented involves php scripts on a server that have all the SQL statements contained within them. I use the Livecode post command to send messages to my php script with a code that identifies the SQL statement to be executed and any data values it needs. That way, no SQL statements are ever transmitted over the web.