Let ( [ ~sql = "
SELECT ~field
FROM t1.~table1
JOIN t2.~table2
ON t1.~field = t2.~field
WHERE ~field=?
ORDER BY ~field
";
$sqlQuery = Substitute ( ~sql ;
[
"~table1"
; SQLTableName ( Table1::fieldName ) ];
[
"~table2"
; SQLTableName ( Table2::fieldName ) ];
[
"~field"
; SQLFieldName ( Table1::fieldName ) ]
)
$sqlResult = SQLDebugResult (
ExecuteSQL ( $sqlQuery ;
""
;
""
;
$value ;
$value[
2
] ;
$value[$n]
)
)
];
If ( $sqlResult =
"?"
;
False ;
True
)
)
...
...
; If (
$sqlResult = "?"
; False // SQLDebugResult ( $sqlResult )
; True )
)
SQLDebugResult ( debug ; _executeSQL )
If (
//the sql call results in an error, return empty so the error will be returned
_executeSQL = "?" and debug ; "" ;
//the sql call is executed correctly, just return the result
_executeSQL
)
Let ( [
~sql = List ( "SELECT ~field" ; "FROM ~table1 AS t1" ; "JOIN ~table2 AS t2" ; "ON t1.~field = t2.~field" ; "WHERE ~field = ?" ; "ORDER BY ~field" )
; $sqlQuery = Substitute ( ~sql ; [ "~table1" ; SQLTableName ( Table1::fieldName ) ] ; [ "~table2" ; SQLTableName ( Table2::fieldName ) ] ; [ "~field" ; SQLFieldName ( Table1::fieldName ) ] )
; $sqlResult = SQLDebugResult ( false ; ExecuteSQL ( $sqlQuery ; "" ; "" ; $value ; $value[$n] ))]
; If ( $sqlResult = "?" ; False ; True ) )
--
You received this message because you are subscribed to the Google Groups "FileMaker Development Standards" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fmstandards...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I guess I should update these things. Been busy… :)
Here is what I currently use Darren. I’ll put it up on the web site. It includes a commented line, which you can uncomment to preview the SQL and a debug option for using SQLDebugResult.
Matt
Let ( [ ~sql = "
SELECT t1.~field
FROM ~table1 t1
JOIN ~table2 t2
ON t1.~field = t2.~field
WHERE ~field LIKE '%~value%'
AND ~field=?
ORDER BY ~field";
$sqlQuery = Substitute ( ~sql ;
[ "~table1" ; SQLTableName ( Table1::fieldName ) ];
[ "~table2" ; SQLTableName ( Table2::fieldName ) ];
[ "~field" ; SQLFieldName ( Table1::fieldName ) ];
[ "~value" ; Table::field ]
);
$sqlResult = ExecuteSQL ( $sqlQuery ; "" ; "" ;
$value;
$value[2];
$value[$n]
)
];
//Substitute ( $sqlQuery ; " " ; "" ) &¶& // sql preview
If ( $sqlResult = "?" ;
Let ( ~debug = False ; If ( ~debug ; SQLDebugResult ( $sqlResult ) ; False ) );
$sqlResult
)
)
On 7 Jan 2016, at 10:01, Perren Smith wrote:
Hi Darren,
I just checked the page history and the code on the page proper (not the last comment by Matt) is the code that should be used and fixes what you’re finding with SQLDebugResult ():
Can you still break things with the code snip at the top of the page (which looks very much like what you’re proposing)?
Hope this helps,
—Perren
- Leave SQLDebugResult in the SQL template code, but comment it out as below. This allows for quick transfer to dataviewer and uncommenting of the condition branch. SQLDebugResult is then removed from $sqlResult assigment. ... ... ; If ( $sqlResult = "?" ; False // SQLDebugResult ( $sqlResult ) ; True )
)
- Modify SQLDebugResult so that it accepts a second debug parameter such as: SQLDebugResult ( debug ; _executeSQL ) If (
To unsubscribe from this group and stop receiving emails from it, send an email to fmstandards...@googlegroups.com fmstandards...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.