INFORMIX DataBlade Developers Kit Tutorial

List of Exercises

Tutorial Exercise 7

Using Smart Large Objects

This exercise demonstrates creating a DataBlade module that handles smart large objects.

Smart large objects allow you to store large data files in a way similar to that used by an operating system file system, while controlling, accessing, and altering files with the database server.

A smart large object has two parts:

  • The data file, which is stored in an sbspace
  • The handle, which is stored in the database and contains the location of the data file in the sbspace

For more information on smart large objects, see the DataBlade API Programmer's Manual.

The Poem DataBlade module creates one new opaque data type, Poem, and the internal support routines the database server uses to process the Poem data type. The Poem data type contains a single member: a handle to a smart large object. The data for the Poem data type are XML files, each containing a poem.

Tutorial Steps

This exercise has 11 steps. It takes approximately one hour to complete.


1

Create a new project.

Start BladeSmith from the Informix program group and choose Project New.

Enter Poem for the DataBlade module name, specify your database server version, leave all other fields in the wizard as their default values, and then click Finish.

Choose Project Save; create a new directory called Poem in any convenient place on your hard drive and save your project in this directory as a file called Poem.ibs.


2

Add the Poem data type.

Choose Edit Insert Opaque Type, enter the following information in the New Opaque Type wizard, and leave all other fields in the wizard as their default values.

Opaque Type Property Value

Opaque type name

Poem

Internal members

Name: poem, Type: MI_LO_HANDLE, Array: 0

Click Finish and then choose Project Save to save your project.


3

Add custom SQL to test for an sbspace.

Because you are creating smart large objects, you must have a default sbspace defined in your database server. If you do not have an sbspace, BladeManager does not register your DataBlade module.

BladeManager can execute a routine, SYSBldTstSBSpace(), during registration to check for the required sbspace. If the sbspace is found, BladeManager successfully registers the DataBlade module. If the sbspace is not found, BladeManager does not register the DataBlade module, and an error appears in the registration log explaining the problem. You instruct BladeManager to run SYSBldTstSBSpace() by adding a custom SQL file to your DataBlade module project.

Choose Edit Insert SQL File, enter the following information in the New SQL File wizard, and leave all other fields in the wizard as their default values.

Custom SQL Property Value

Descriptive name for SQL

SbspaceTest

Custom SQL create text

EXECUTE FUNCTION SYSBldTstSBSpace(" ");

These objects require this SQL

Poem

Click Finish and then choose Project Save to save your project.


4

Generate the source code and SQL registration scripts.

See " Generating Code" for detailed instructions.

BladeSmith generates the basic C code and SQL scripts necessary for your DataBlade module to run:

  • The source code is saved in the Poem\src\C directory.
  • The SQL scripts are saved in the Poem\scripts directory.

The BladeSmith portion of this exercise is complete; you can exit BladeSmith.


Copyright © 1998, Informix Software, Inc. All rights reserved.