Skip to content

Instantly share code, notes, and snippets.

@dansmith65

dansmith65/ExecuteSQL

Last active Apr 2, 2018
Embed
What would you like to do?
ExecuteSQL template for FileMaker which allows for viewing the query in the data viewer while debugging, and testing for an error.
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
You can’t perform that action at this time.