Bad Query

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bad Query

Justin Will
I have had a situation with a bit of code in A4D giving me some issues lately.  I have a built query something like this.

Query([MyTable]; [MyTable]ABC="EFG"; *)
Query([MyTable]; & ; [MyTable]Def=0; *)
Query([MyTable];  & ;[MyTable]SessionID=$SomeValue)
If(Records in selection([MyTable])>0)
                LogDeletes("Delete From [MyTable] on page Mypage.html")
Delete Selection([MyTable])
End If

This has ended up deleting the wrong records a couple of times on me lately.  The first instinct is Run Tools and check the records and indexes.  Those are coming up clean BUT I am also seeing just moments before this happens I get an email from the webserver saying an error of incompatible types occurred in a different page.

My logs from this are as such.

Error Classification: 6
Error Description: An operation on incompatible types was attempted
Error Path: /checkin/image.a4d
Error Source Method:
Error Before Token: $pict := $imgPtr
Error Token: ->
Error After Token:
Error Line Number: 51
Error Err Code: 0
Form Variables:
Query Params:
size: 60
qry_value: 11161
qry_field: Contact_Photo_ID
img_field: [Contact_Photo]Photo
Any ideas on how I can prevent this from happening or what might be happening?

Thanks
Justin Will

_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/
Reply | Threaded
Open this post in threaded view
|

Re: Bad Query

Aparajita Fishman
Active4D effectively uses EXECUTE under the hood for the QUERY command, once for each line in the built query. I have no idea what could be going wrong here, but just to be sure there isn’t some weird thing going on within the 4D engine, my suggestion is to use QUERY BY FORMULA instead, as this becomes a single EXECUTE:

query by formula(*; [MyTable];([MyTable]ABC = “EFG”) & ([MyTable]Def = 0) & ([MyTable]SessionID = $someValue))

You will have to update the just-released v7.0r6 to be able to reference local variables like this, you definitely want to use the * form of ‘query by formula’.

All the best,

  - Aparajita

> On Jan 19, 2018, at 1:12 PM, Justin Will <[hidden email]> wrote:
>
> I have had a situation with a bit of code in A4D giving me some issues lately.  I have a built query something like this.
>
> Query([MyTable]; [MyTable]ABC="EFG"; *)
> Query([MyTable]; & ; [MyTable]Def=0; *)
> Query([MyTable];  & ;[MyTable]SessionID=$SomeValue)
> If(Records in selection([MyTable])>0)
>                LogDeletes("Delete From [MyTable] on page Mypage.html")
> Delete Selection([MyTable])
> End If
>
> This has ended up deleting the wrong records a couple of times on me lately.  The first instinct is Run Tools and check the records and indexes.  Those are coming up clean BUT I am also seeing just moments before this happens I get an email from the webserver saying an error of incompatible types occurred in a different page.
>
> My logs from this are as such.
>
> Error Classification: 6
> Error Description: An operation on incompatible types was attempted
> Error Path: /checkin/image.a4d
> Error Source Method:
> Error Before Token: $pict := $imgPtr
> Error Token: ->
> Error After Token:
> Error Line Number: 51
> Error Err Code: 0
> Form Variables:
> Query Params:
> size: 60
> qry_value: 11161
> qry_field: Contact_Photo_ID
> img_field: [Contact_Photo]Photo
> Any ideas on how I can prevent this from happening or what might be happening?
>
> Thanks
> Justin Will
>
> _______________________________________________
> Active4D-dev mailing list
> [hidden email]
> http://list.aparajitaworld.com/listinfo/active4d-dev
> Archives: http://active4d-nabble.aparajitaworld.com/

_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/
Reply | Threaded
Open this post in threaded view
|

Re: Bad Query

Aparajita Fishman
In reply to this post by Justin Will
Active4D effectively uses EXECUTE under the hood for the QUERY command, once for each line in the built query. I have no idea what could be going wrong here, but just to be sure there isn’t some weird thing going on within the 4D engine, my suggestion is to use QUERY BY FORMULA instead, as this becomes a single EXECUTE:

query by formula([MyTable];([MyTable]ABC = “EFG”) & ([MyTable]Def = 0) & ([MyTable]SessionID = $someValue))

All the best,

  - Aparajita

> On Jan 19, 2018, at 1:12 PM, Justin Will <[hidden email]> wrote:
>
> I have had a situation with a bit of code in A4D giving me some issues lately.  I have a built query something like this.
>
> Query([MyTable]; [MyTable]ABC="EFG"; *)
> Query([MyTable]; & ; [MyTable]Def=0; *)
> Query([MyTable];  & ;[MyTable]SessionID=$SomeValue)
> If(Records in selection([MyTable])>0)
>                LogDeletes("Delete From [MyTable] on page Mypage.html")
> Delete Selection([MyTable])
> End If
>
> This has ended up deleting the wrong records a couple of times on me lately.  The first instinct is Run Tools and check the records and indexes.  Those are coming up clean BUT I am also seeing just moments before this happens I get an email from the webserver saying an error of incompatible types occurred in a different page.
>
> My logs from this are as such.
>
> Error Classification: 6
> Error Description: An operation on incompatible types was attempted
> Error Path: /checkin/image.a4d
> Error Source Method:
> Error Before Token: $pict := $imgPtr
> Error Token: ->
> Error After Token:
> Error Line Number: 51
> Error Err Code: 0
> Form Variables:
> Query Params:
> size: 60
> qry_value: 11161
> qry_field: Contact_Photo_ID
> img_field: [Contact_Photo]Photo
> Any ideas on how I can prevent this from happening or what might be happening?
>
> Thanks
> Justin Will
>
> _______________________________________________
> Active4D-dev mailing list
> [hidden email]
> http://list.aparajitaworld.com/listinfo/active4d-dev
> Archives: http://active4d-nabble.aparajitaworld.com/

_______________________________________________
Active4D-dev mailing list
[hidden email]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/