Jump to content

Troubleshoot SQL Syntax Error


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

Recommended Posts

  • Newbies

I am relatively new to sql queries in Filemaker, and I'm receiving the ? in response to the following queries. Because I don't have the advanced version of FMP, I used Evaluate() to return the error code 8310 (syntax error). However I can't figure out where my syntax error is. Hopefully more experienced eyes will spot my problem(s).

The following is entered in a calculated field that returns text:

Let( [

$initials=ExecuteSQL("SELECT TaskAssignedTo FROM workflow WHERE" & Quote("_IDDocLog") & "=workflow::" & Quote("_IDDocLog") & "AND workflow::TaskNumber=9"; "" ; "" );

$name=ExecuteSQL ("SELECT FullName FROM staff WHERE AccountName= $initials"; "" ; "") ];

$name )

Thanks!!

 

Oops I meant to say that I used EvaluationError()

Link to comment
Share on other sites

ExecuteSQL("SELECT TaskAssignedTo FROM workflow WHERE" & Quote("_IDDocLog") & "=workflow::" & Quote("_IDDocLog") & "AND workflow::TaskNumber=9"; "" ; "" );

This is a non functional SELECT statement. I cant even begin to guess what you are trying to accomplish.

You should look into using ? as variable value placeholders in SQL...i.e

ExecuteSQL ( "SELECT field FROM table WHERE field=? and WHERE field=?" ; "" ; "" ; value_for_first? ; value_for_second? )

Edited by Kris M
Link to comment
Share on other sites

  • Newbies

Thanks Kris M.

I replaced what I was using with your placeholder suggestion (below) but I'm still getting the 8310 error. One problem might be the underscores. But there may be other problems as well.

ExecuteSQL("SELECT TaskAssignedTo FROM workflow WHERE _IDDocLog=? AND workflow::TaskNumber=?"; "" ; "" ;  workflow::_IDDocLog ; 9);

What am I trying to accomplish? I have 2 tables, workflow (see attached file) and document. They are related by fields workflow::_IDDocLog and document::_IDDocLog. For one record in document, there are 16 related records in workflow. Each of the related records in workflow has a taskNumber, value incrementing from 1 to 16. I want to grab the value of workflow::TaskAssignedTo from the record in workflow with workflow::TaskNumber=9.

If there is a better way to do this than ExecuteSQL(), I'm all ears!

 

Screen Shot 2016-04-25 at 4.42.50 PM.png

Link to comment
Share on other sites

Hi,

Try use "workflow._IDDocLog" (only one dot for all names of fields) and not workflow::_IDDocLog.

Yes underscores may be a problem at the begining of names

Have a good day

G

 

 

Link to comment
Share on other sites

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