Salesforce

How Do I Send My Own SQL Statements to the Database? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Send My Own SQL Statements to the Database? (Magic xpa 4.x)

When you use Magic xpa with an SQL database, Magic xpa generates the SQL code needed. However, there are times when you may want to override the default code generation. For instance, you may want to call a stored procedure or tightly control how a group of records is retrieved.

This is easily done from within a Magic xpa program. There are several different ways you can send SQL statements, each of which is covered below.

Manually entering a WHERE Clause

If you only want to send a WHERE clause, you can do this in the Range/Locate dialog box. You can type in your Where statement in the DB SQL field, and you will see the result concatenated onto Magic xpa’s Where clause in the Full Where Clause field.

  1. Go to Task->Range/Locate.

  2. Click on the SQL Where tab header.

  3. Enter the Where clause you want, either by typing it in the DB SQL field, or by zooming on the Exp field and entering an Expression.

  4. The full where clause will be displayed below.

Note: This option is only valid when you are using Physical transactions (Task Properties->Data->Transaction Mode = Physical).

Manually entering another SQL Statement

If you want to enter something more complex than the WHERE statement, you can do this using a Direct SQL statement.

  1. Go to the Data View tab.

  2. From line 1, select Direct SQL, then tab.

  3. The SQL Command dialog box will appear. Here you can type in an SQL command. Clicking on the Assist button will bring up a dialog box that will help you format the SQL command.

  4. Zoom from the Output Arguments field to map the fields from the SQL command onto virtuals in the task.

The Virtuals can be used in your program just as you would use a Real from a Main data source.

See also

The Online and Rich Client Samples projects (program SQ01 and RSQ01)

Reference
Attachment 
Attachment