Skip Headers

Oracle Express Spreadsheet Add-In User's Guide
Release 6.3.4

Part Number A96501-01
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

3
Calling Express Programs with the API

Chapter summary

This chapter describes how Express callouts work in the API of Express Spreadsheet Add-In.

List of topics

This chapter includes the following topics:

Introducing Express Callouts

What is an Express callout?

An Express callout is an Express program that contains custom logic related to a particular database activity. This program will be run by the add-in when a specified event, associated with a key point in database processing, occurs.

For example, you can choose to run a callout program before the add-in writes permanent changes to the database (that is, before the add-in sends an UPDATE command to Express).

Arguments provided by the add-in

The callout program must use arguments provided by the add-in as input. Typically one of the arguments is the name of the target database.

Values returned to the add-in

The add-in expects that the callout program will return the following two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. The interpretation of this Boolean value depends on the specific callout method that is used to register the program.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE.

Registering Express Callout Programs

Two registration techniques

In order to specify when Express callout programs will run, you must register them. You can use one or both registration techniques, which are described in the following table.

Technique

Description

Application

Automatic

Uses a "registration" variable that contains information on the callout programs. Once the database that contains the variable is attached to an add-in session, the callout programs are registered automatically. The code database that contains the callout programs must be attached at the time the callout programs are to run.

Applies to the session only as long as the database that contains the registration variable is attached. Once the database is detached, the callout programs that are specified in the registration variable are no longer registered.

Programmatic

Uses one of the Express callout methods of the API.

Applies to the entire session in which the method was called.

Registering callout programs using both techniques

If you register callout programs both automatically and programmatically, two callout programs run for each event. For example, suppose you automatically register a PostAttach callout program and you call the XPSetPostAttachCommand method. After a database is attached, the automatically registered callout program runs, then the program specified by the XPSetPostAttachCommand method runs.

If you register the same callout program for the same event both automatically and programmatically, the program runs twice.

Procedure: Registering callout programs automatically

To register callout programs automatically, create a registration variable in the data database, as explained in the following procedure.

  1. Using Oracle Express Administrator (hereinafter referred to as "Administrator"), create a text dimension named XSA.CALLOUT.DIM in the Express database. This will be the dimension by which the registration variable will be dimensioned.

  2. Assign the following values to the XSA.CALLOUT.DIM dimension:

    CUSTOMWRITE
    POSTATTACH
    POSTUPDATE
    PRECOMMIT
    PREPAGECHANGECOMMAND
    PREREFRESH
    PREUPDATE
  3. Using Administrator, create a text variable named XSA.CALLOUTS in the Express database. Dimension the variable by the XSA.CALLOUT.DIM dimension.

  4. Edit the XSA.CALLOUTS variable to specify the name of each callout program.

    Example: If your POSTATTACH program is called XP.MYPostAttach, enter this program name in the XSA.CALLOUTS variable for the POSTATTACH value.

  5. Save your changes to the database.

Procedure: Registering callout programs programmatically

To register callout programs programmatically, use one of the Express callout methods of the API.

Related information

In the Help system for Express Spreadsheet Add-In's API, search for "Registering Express Program Callouts."

Example: Using an Express Callout Program with Programmatic Registration

Setting up the example

In this example, assume that when a user chooses Commit from the Express menu, you want to insert custom logic to write changes to the data.db database rather than allow the add-in to perform the default behavior of sending an UPDATE command to Express.

You can accomplish this task by using the Express callout method XPSetPreCommitCommand with programmatic registration.

Writing the callout program

Write an Express program called PL.COMMIT to perform the desired custom logic. This program has the following requirements:

Registering the callout program programmatically

In a VBA procedure, after writing commands to perform various spreadsheet operations, programmatically register your program as an Express callout argument for the XPSetPreCommitCommand method. The following excerpt demonstrates sample code.

Sub x( )
< Commands for spreadsheet operations>
.
.
.
Call XPSetPreCommitCommand ("PL.COMMIT")
End Sub

Running the callout program

When a user chooses Commit from the Express menu, the add-in automatically runs the callout program and supplies the name of the target database, as shown in the following call.

Call PL.COMMIT ('DATA.DB')

Values returned by the callout program

When the callout program finishes performing its custom logic, it places return values in the SNAPI fetch buffer, as shown in the following example.

FETCH FALSE
FETCH 'Your update processing completed successfully.'

When the add-in receives the FALSE return value, it does not send an UPDATE command to Express.

CustomWriteCommand Callout

Description

A CustomWriteCommand callout is an Express program that lets you replace the default behavior for writing changes to the database. To make this program available to the add-in, you must register the program by calling the XPSetCustomWriteCommand method.

When your program will run

Your program runs in Express when the user chooses Write from the Express menu. Your program must use the arguments provided by the add-in as input.

Arguments provided by the add-in

Arg1

String. The name of the target database.

Arg2

String. The write-back QDR script as a multiple-line argument.

Values returned to the add-in

Your program should return two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. If your program returns FALSE, the add-in assumes that the callout was not successful.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE.

PostAttachCommand Callout

Description

A PostAttachCommand callout is an Express program that lets you insert custom logic associated with attaching a database. To make this program available to the add-in, you must register the program by calling the XPSetPostAttachCommand method.

When your program will run

Your program runs in Express immediately after the add-in attaches any database. Your program must use the argument provided by the add-in as input.

Argument provided by the add-in

Arg1

String. The name of the database.

Values returned to the add-in

Your program should return two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. If your program returns FALSE, the add-in assumes that the callout failed.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE.

PostUpdateCommand Callout

Description

A PostUpdateCommand callout is an Express program that lets you insert custom logic after the add-in writes permanent changes to the database (that is, performs an UPDATE command in Express). To make this program available to the add-in, you must register the program by calling the XPSetPostUpdateCommand method.

When your program will run

Your program runs in Express immediately after the add-in writes permanent changes to a database whose attach mode was switched from read-only to read/write. Your program must use the argument provided by the add-in as input.

Argument provided by the add-in

Arg1

String. The name of the database.

Values returned to the add-in

Your program should return two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. If your program returns FALSE, the add-in assumes that the callout failed.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE.

PreCommitCommand Callout

Description

A PreCommitCommand callout is an Express program that lets you insert custom logic for writing permanent changes to the database. To make this program available to the add-in, you must register the program by calling the XPSetPreCommitCommand method.

When your program will run

Your program runs in Express immediately before the add-in writes permanent changes to the database (that is, sends an UPDATE command to Express). Your program must use the argument provided by the add-in as input.

Argument provided by the add-in

Arg1

String. The name of the target database.

Values returned to the add-in

Your program should return two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. If your program returns FALSE, the add-in will not send the UPDATE command to Express.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE. If you do not return a value, the add-in assumes TRUE.

PrePageChangeCommand Callout

Description

A PrePageChangeCommand callout is an Express program that lets you insert custom logic before changing to a different page in the query. To make this program available to the add-in, you must register the program by calling the XPSetPrePageChangeCommand method.

When your program will run

Your program runs in Express immediately before the add-in changes to a different page in the query. Your program must use the arguments provided by the add-in as input.

Arguments provided by the add-in

Arg1

String. The Express name of the dimension in the page whose status will change.

Arg2

Integer. The current setting of the dimension in status. For example, if the dimension is set to the first value in status, the value of this argument is zero.

Arg3

Integer. The position to which the page change will set the dimension. For example, the add-in will send the following command to Express if the user changes the PRODUCT page control from the first PRODUCT value in the list to the seventh PRODUCT value in the list.

call your.prepage.cmd('PRODUCT', 0, 6)

Values returned to the add-in

Your program should return two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. If your program returns FALSE, the add-in will not send the page change information to Express.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE. If you do not return a value, the add-in assumes TRUE.

PreRefreshCommand Callout

Description

A PreRefreshCommand callout is an Express program that lets you insert custom logic before the add-in refreshes data from a database. The refresh can occur either as a result of a successful writeback of data or by the user choosing the Refresh menu option. To make this program available to the add-in, you must register it by calling the XPSetPreRefreshCommand method.

When your program will run

Your program runs in Express immediately before the add-in refreshes data from a database. Your program must use the argument provided by the add-in as input.

Argument provided by the add-in

Arg1

String. The name of the database.

Values returned to the add-in

Your program should return two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. If your program returns FALSE, the add-in will not send the refresh command to Express.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE.

PreUpdateCommand Callout

Description

A PreUpdateCommand callout is an Express program that lets you insert custom logic before the add-in writes permanent changes to a database (that is, sends an UPDATE command to Express). To make this program available to the add-in, you must register it by calling the XPSetPreUpdateCommand method.

When your program will run

Your program runs in Express immediately before the add-in writes permanent changes to a database whose attach mode was switched from read-only to read/write. Your program must use the argument provided by the add-in as input.

Argument provided by the add-in

Arg1

String. The name of the database.

Values returned to the add-in

Your program should return two values in the SNAPI fetch buffer:

  1. Boolean. TRUE or FALSE. If your program returns FALSE, the add-in leaves the attach mode unchanged and does not send the UPDATE command to Express.

  2. String. Optional. Lets you return a message to the user. This message is displayed only if the first return value is FALSE.


Go to previous page Go to next page
Oracle
Copyright © 1997, 2002 Oracle Corporation.

All Rights Reserved.
Go To Table Of Contents
Contents
Go To Index
Index