Last active
April 2, 2018 18:13
-
-
Save dansmith65/4684647 to your computer and use it in GitHub Desktop.
ExecuteSQL template for FileMaker which allows for viewing the query in the data viewer while debugging, and testing for an error.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let ( [ | |
$sqlQuery = | |
"SELECT " | |
& SQLTableAndField ( field ) | |
& "¶FROM " | |
& SQLTable ( field ) | |
& "¶LEFT JOIN " | |
& SQLTable ( field ) | |
& "¶ON " | |
& SQLTableAndField ( field ) | |
& " = " | |
& SQLTableAndField ( field ) | |
& "¶WHERE " | |
& SQLTableAndField ( field ) | |
& " = ? " | |
& "¶AND " | |
& SQLTableAndField ( field ) | |
& " = ? " | |
& "¶ORDER BY " | |
& SQLTableAndField ( field ) | |
& ", " & SQLTableAndField ( field ) & " DESC" | |
& "¶GROUP BY " | |
& SQLTableAndField ( field ) | |
; | |
$sqlParameter1 = "value" ; | |
~start = Get ( CurrentTimeUTCMilliseconds ) ; | |
$sqlResult = ExecuteSQL ( | |
$sqlQuery ; | |
SQLFieldSeparator ; | |
SQLRowSeparator ; | |
$sqlParameter1 | |
) ; | |
$sqlRuntime = Get ( CurrentTimeUTCMilliseconds ) - ~start ; | |
$error = If ( $sqlResult = "?" ; | |
ErrorApp ( 17 ; "" ) | |
& # ( "sqlQuery" ; $sqlQuery ) | |
& # ( "sqlParameter1" ; $sqlParameter1 ) | |
& # ( "sqlRuntime" ; $sqlRuntime ) | |
; | |
$error | |
) | |
] ; | |
$sqlResult | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment