Introduction to Genero BDL programming / Genero BDL concepts |
A set of SQL statements are part of the language syntax and can be used directly in the source code, as a normal procedural instruction.
The static SQL statements are parsed and validated at compile time. At runtime, these SQL statements are automatically prepared and executed. Program variables are detected by the compiler and handled as SQL parameters.
You can write common SQL statements such as SELECT, INSERT, UPDATE or DELETE directly in your source code:
MAIN DEFINE n INTEGER, s CHAR(20) DATABASE stores LET s = "Sansino" SELECT COUNT(*) INTO n FROM customer WHERE custname = s DISPLAY "Rows found: " || n END MAIN
Dynamic SQL management allows you to execute SQL statements that are constructed at runtime. The SQL statement can use SQL parameters, and may produce a result set.
The next example executes a specific SQL statement with the dynamic SQL instructions PREPARE and EXECUTE:
MAIN DEFINE txt CHAR(20) DATABASE stores LET txt = "SET DATE_FORMAT = YMD" PREPARE sh FROM txt EXECUTE sh END MAIN
Through the database drivers, the same program can open database connections to any of the supported databases.