version 11
We would now like to know something about the actors for each movie: more specifically, we are interested in finding all the movies with at least 7 actors. The result will be sorted by year.
To do this, we will use a 4D function (Find_Nr_Of_Actors) that receives the movie ID as unique parameter and returns the number of actors that played in that movie:
The initial query in 4D code would be:
Using SQL code, the above query becomes:
You can see that we are able to call a 4D function inside SQL code using the syntax:
{fn 4DFunctionName AS 4DFunctionResultType}.
Using generic SQL commands, the above query becomes:
Using the QUERY BY SQL command, the above query becomes:
Using the SQL EXECUTE IMMEDIATE command, the query above becomes:
To test all the above examples, launch the "4D SQL Code Samples" database and go to the main window. You can then choose the query mode and press the Calling 4D methods button.