EXECUTE IMMEDIATE

4D - Documentation   Français   English   German   Japanese   4D SQL Reference, Table of Contents   4D SQL Reference, Index   Back   Previous   Next

version 11


EXECUTE IMMEDIATE <<sql_name>> | <<$sql_name>> | :sql_name | :$sql_name

Description

The EXECUTE IMMEDIATE command is used to execute a dynamic SQL statement. The sql_name passed represents a variable containing a set of SQL statements that will be executed as a whole.

Note: This command cannot be used within a connection to an external data source (SQL pass-through) established using the USE EXTERNAL DATABASE 4D command.

Example

This example recovers the number of movies in the database that were released in 1960 or more recently:

   C_LONGINT($NoMovies)
   C_TEXT($tQueryTxt)
   $NoMovies:=0
   
   $tQueryTxt:="SELECT COUNT(*) FROM MOVIES WHERE Year_of_Movie >= 1960 INTO :$NoMovies;"
   Begin SQL
      EXECUTE IMMEDIATE :$tQueryTxt;
   End SQL

   ALERT("The Video Library contains "+String($NoMovies)+" movies more recent or equal to 1960")

4D - Documentation   Français   English   German   Japanese   4D SQL Reference, Table of Contents   4D SQL Reference, Index   Back   Previous   Next