Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I have an ExecuteSQL statement that looks like this:

 
ExecuteSQL ( 
"SELECT DISTINCT( " & GFN(WT::Version) &")
FROM " & GTN(WT::Version) &"
WHERE "
 & GFN(WT::Version) &" <> 2
or "
 & GFN(WT::Version) &" <> 2"
;
""; "")
 
The output of which is:
1
3
4
5
 
If I remove the or statement it stops working and I get the ?.
 
Anyone have any ideas why that is?
 
 
Not Working Version:
 
ExecuteSQL ( 
"SELECT DISTINCT( " & GFN(WT::Version) &")
FROM " & GTN(WT::Version) &"
WHERE "
 & GFN(WT::Version) &" <> 2 "
;
""; "")
 
Posted

is "version" a text field or a number?  I'm guessing a text field in which case the 2 should be '2'

You can avoid this by passing in the 2 as a parameter to the Execute SQL like this:

 

ExecuteSQL ( 
"SELECT DISTINCT( " & GFN(WT::Version) &")
FROM " & GTN(WT::Version) &"
WHERE "
 & GFN(WT::Version) &" <> ? "
;
""; "" ; 2 )
  • Like 1
Posted

Version is a number field.

 

I created a basic table with a number field and tried the same logic on that and it does work like it should and as you say. 

 

Do you know why the first part of the where is false, but the second would be true?


I've also tried passing it as a parameter with no luck. 

Posted

break out the SQL syntax into its own variable so that you can inspect it before firing the ExecuteSQL.

 

Not familiar with your GTN and GFN implementation but you may have to feed it something like 

GetFieldName( WT::version ) instead of the value of the WT::version field.

 

 

Posted

Thanks for the debug tip. I'll tinker with that for awhile to see if I can discover what's going on. 

 

GFN function is as follows and GTN is similar:

Let ( [ 
a = GetFieldName ( field ) ; 
b = Substitute ( a ; "::" ; ¶ ) 
] ; 
   Quote ( GetValue ( b ; 2 ) )
)  
Posted

I've done more testing and narrowed it down to one table that doesn't calculate SQL correctly.

 

Test 1: Works

     SELECT ID

     FROM TroubleTable

 

     Result: 1,2,3,4,5 

 

Test 2: Doesn't work

    SELECT COUNT(ID)

    FROM TroubleTable

 

    Result: ?

 

I then Copied the table and filled my copy with test data.

 

Test 1b: Works

     SELECT ID

     FROM TroubleTableCopy

 

     Result: 1,2,3,4,5 

 

Test 2b: Works

    SELECT COUNT(ID)

    FROM TroubleTableCopy

 

    Result: 5

 

So my question would be, what can cause a table to behave this way, but a copy of the table works as expected? Is it an indexing issue? Is it a possible sign of corruption? 

Posted

I copied one of the backups of the file from a month ago to see if anything has changed.. The SQL works as expected in the back up file. I double checked that the field definitions are the same as well. My final conclusion is that the table is corrupt. 

Posted

File has been completely rebuilt and put back in place. Everything is back in working order. Only took me 30 minutes. Got to love that data separation model. 

This topic is 4136 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.