Using Direct SQL Command (Magic xpa 3.x)
Magic xpa lets you embed native SQL statements in your Magic xpa project with the SQL Command dialog box. If the SQL Command dialog box is used, the task’s Main Source is the SQL statement.
-
From the Project menu, select Programs.
-
Create a new line.
-
Type demo for the program name.
-
Zoom to the task tree.
-
From the Task menu, select the SQL Command option (Ctrl+Q). The SQL Command dialog box appears.
Magic xpa executes the SQL command before it executes the Task Prefix logic unit. The task can use the returned data as an integral part of its data view.
Magic xpa does not attempt to analyze the command’s syntax and semantics. This gives the programmer flexibility, but requires that the programmer plan the programming carefully. Magic xpa does not protect the data from errors in the Direct SQL commands.
Make sure to have a look at the Restrictions on Using Direct SQL topic.
Magic xpa’s Direct SQL feature is a tuning tool to improve performance. Use this feature selectively, and only when its use results in significant performance improvement. You should use this when you want to:
-
Calculate statistics on the database, such as how many records have a specific property, or the total sum of this month's salaries.
-
Make a vertical update to your data, such as to increase all salaries by 5 percent, delete all old records, and copy parts of one table to another table.
-
Utilize existing code that was developed and compiled using the SQL DBMS tools, such as stored procedures.
Direct SQL Task Elements