KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Enabling a Project method to be called from a SQL query
PRODUCT: 4D Developer | VERSION: 11 | PLATFORM: Mac & Win
Published On: December 5, 2007

It is possible to call a 4D Project method from within a SQL query, however the method property must be set accordingly.

First, locate the method that will be called from the SQL query. Right click (Windows) or Ctrl + click (Mac OS) the method and select Method Properties:



The last option in the Attributes section, Available through SQL, needs to be checked:



This is an added measure of security to ensure developers have complete control over which methods can or can not be called from within SQL. By default, it is unchecked.

As an example, assume that the following SQL query calls a method, function_call_received, which performs its own query:

Begin SQL
   SELECT {fn function_call_received(id) AS INT}
   FROM Customer INTO $var
END SQL


4D will return an error at the point of calling function_call_received if its method property described above is not checked. If it is checked, function_call_received will be called and executed.