Jump to content
Server Maintenance This Week. ×

Escaped quotes vs. single quotes in ExecuteSQL


This topic is 3742 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Can someone enlighten me why this fails:

ExecuteSQL( "SELECT COUNT ( IDs ) FROM TableA WHERE aaName = "Bob Bob" " ; "" ; ""  )

But this one works?

ExecuteSQL( "SELECT COUNT ( IDs ) FROM TableA WHERE aaName = 'Bob Bob' " ; "" ; ""  )

To mine eyes the only difference is the single quotes, and I thought that the escaped double quotes should be an acceptable form.  I know I have used escaped double quotes before, I swear.  (Oh wait, that's right, I am swearing too much recently.  :)

 

I guess I have used escaped quotes around field/table names but never as part of the WHERE clause's string-to-match.  I typically have used the replaceable parameter in these cases; but this time I was trying to put it directly in the statement.  I.e. this version also works:

ExecuteSQL("SELECT COUNT ( IDs ) FROM TableA WHERE aaName = ?" ; "" ; "" ; "Bob Bob" )

Thanks,

C

 

Link to comment
Share on other sites

  • 2 weeks later...

I'd be curious to see test results on that. I have found some ExSQL function to be slow (e.g. BETWEEN), but Count seems to perform very well. Interestingly, Count(*) is quite fast, it may be using internal record IDs or something.

Link to comment
Share on other sites

In Comparison to the Filemaker value count function in compared to the Count, it is slightly slow.

In case of using the ExecuteSQL Sum() function, it is really slow in compared to that using any custom function to sum down the values in a list.

Link to comment
Share on other sites

  • 3 weeks later...

I had recently done some testing of these methods and here is what I came up with:

 

This calculation is a CF on the Notes icon, showing if there are notes that exist or not.

Returning 258 records today.  The 'No CF' timing is the baseline for loading the layout in general.  This is a rather large list-view layout (i.e. lots of columns).  This formatting equation was only one calculation, and was the only thing changed for these tests.  You could subtract the average time there from each of the following tests to get how much time the calculation itself added to the loading.

 

The file is hosted on FMSA 12.03.  File was closed each time (i.e. no caching involved).

More calculation timing (CF on the Notes icon):

Returning 258 records today:

*******************
No CF calculation:
--------------------
5.75
5.84
5.83

*******************
Calculation references only local static data (a field in the same table that is set by script triggers)
--------------------
7.54
7.4
6.57
6.8
7.8
6.1
8.3
5.9

*******************
ValueCount( ExecuteSQL ( "SELECT Author FROM Comment WHERE C_ID = ? " ; Char(9) ; Char(13) ; Parent:_ID )  ) < 1
-----------------
9.77
8.1
8.23
8.36

******************
ExecuteSQL ( "SELECT COUNT (Author ) FROM Comment WHERE C_ID = ? " ; Char(9) ; Char(13) ; Parent:_ID )   < 1
-----------------
9.0
7.9
7.8
8.1

******************
Robustified ESQL:   
ExecuteSQL ( "SELECT COUNT (" & GFN ( Comment::Name ) & ") FROM " & GTN ( Comment::Name ) & " WHERE " & GFN ( Comment::C_ID ) & " = ? "  ; Char(9) ; Char(13) ; Parent:_ID  )  < 1
 ------------------
 8.82
 9.3
 8.96

*****************
ExecuteSQL ("SELECT COUNT (*) FROM " & GTN ( Comment::Name ) & " WHERE " & GFN ( Comment::C_ID ) & " = ? "  ; Char(9) ; Char(13) ; Parent:_ID )   < 1
-----------------
8.97
8.66
9.47
9.11

*****************
ExecuteSQL ("SELECT COUNT (*) FROM Comment WHERE C_ID = ? "  ; Char(9) ; Char(13) ; Parent:_ID )   < 1
-----------------
7.01
6.96
7.10
7.11

Added a test for "= 0" instead of "< 1":

*****************
ExecuteSQL ("SELECT COUNT (*) FROM Comment WHERE C_ID = ? "  ; Char(9) ; Char(13) ; Parent:_ID ) = 0
-----------------
6.99
7.03
6.98
6.97

So...calculations are bad for scrolling.  ESQL (Count(*) ) is pretty quick, but not as good as local data (generally - variances due to server/network).  Impact of Count(*) on scrolling was also less, but it was still noticable that it would hitch as you scrolled.

 

--  J

Link to comment
Share on other sites

This topic is 3742 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.