Metatranz StepSqlite alpha Metatranz StepSqlite Home Metatranz StepSqlite Home

StepSqlite Frequently Asked Questions

  1. What is StepSqlite?
  2. How do I create triggers in Sqlite that use procedural code?
  3. I have existing procedures/functions written in C++ code; Can I reuse it in my StepSqlite PL/SQL package?
  4. Is Exception Handling supported?
  5. Where is the download link for StepSqlite?

What is StepSqlite?

StepSqlite is a multi-target PL/SQL compiler suite for Sqlite. It can be used to compile your database interfaces written in PL/SQL for use on several target operating systems, architectures and language APIs.

Currently StepSqlite supports Linux and iPhone on x86, ARM using Sqlite native C++ API - this list is being continuously expanded.

StepSqlite is being developed to support compiling Pl/SQL code to several target platforms (Linux, iPhone, Mac, Windows), architectures (x86, ARM) and languages/APIs (Sqlite native C++ API, Python PySqlite, Android SDK/NDK, JDBC, etc).

How do I create triggers in Sqlite that use procedural code?

You can create a trigger in usual PL/SQL syntax using 'Create Trigger' statement. Just put the 'Create Trigger' statement in the initialization block of your package body. The trigger body can use all the procedures and functions defined within the package. Special variables :New and :Old can be used in the trigger body.

Here is an example of how to write a trigger.

    CREATE TABLE parts(part_no integer, part_name varchar(100), part_desc varchar(200));

        CREATE TRIGGER MyTrig before update on parts 
        WHEN (:new.part_name <> '')
            my_part_name varchar(100);
            IF :new.part_name <> :old.part_name THEN
              :new.part_desc := :new.part_desc || '-- Updated part_name on: ' || sysdate(); 
            END IF;

I have existing procedures/functions written in C++ code; Can I reuse it in my StepSqlite PL/SQL package?

Yes. StepSqlite allows you to embed arbitrary code written in your 'host-language' into the PL/SQL code in your package between the [-- and --] tags . This enables you to quickly reuse any code you already have to write stored procedures in StepSqlite database interface.

Here are some things to note when embedding the host language code. Since PL/SQL is case insensitive, all procedure parameters and variables defined in PL/SQL part of the code must be referred to in embedded part of the code (between [-- and --] tags ) as ALL CAPS.

Here is an example which utilizes the existing C++ STL function for string replace to write a utility function which can be called from StepSqlite PL/SQL. Note the CAPS for parameters: MAINSTRING, SEARCHSTRING and REPLACESTRING when they are used within the [-- and --] tags.

    procedure replace(mainString OUT varchar, searchString varchar, replaceString varchar DEFAULT '') is
            string::size_type pos = 0;
        while ( (pos = MAINSTRING.find(SEARCHSTRING, pos)) != string::npos ) 
            MAINSTRING.replace( pos, SEARCHSTRING.size(), REPLACESTRING );

Is Exception Handling supported?

Yes! StepSqlite supports all PL/SQL exception handling constructs. Even the standard exception handlers like, NO_DATA_FOUND, INVALID_CURSOR etc are pre-defined for you. Also available are SQLCODE, SQLERRM and RAISE_APPLICATION_ERROR functions.

To use exception handling features with SQLite you need to compile the C code of SQLite to allow it to pass-through exceptions to C++ libraries generated by StepSqlite. This is easy to do: just specify the compile flag: -fexceptions when compiling SQLite on your linux box. (This is not needed on Windows - Windows does this by default).

Here are the steps to compile SQLite for exceptions on a linux x86 box (Note use of -fexceptions):

$ cd sqlite-3.6.18
$ CFLAGS="-fexceptions" ./configure --prefix=/path/to/installation/directory
$ make
$ make install

Where is the download link for StepSqlite?

There isn't any!..well, so far! We are building StepSqlite around the cloud computing paradigm. The tools in the StepSqlite suite are accessible from anywhere on the web without requiring installation of bulky software. This spares you - the user - from spending time on maintenance and version management of our software and lets you focus on writing your software. Whenever we introduce a new feature in StepSqlite suite, you will see a link on the login page alerting you about it and the feature will be immediately available to you for use - no need to spend time doing software upgrades either.

Now, we do realize that some tasks require a downloadable tool for ex, you would need one if you want to integrate StepSqlite compiler into your regular build environment. We are working on creating some very innovative, easy-to-manage cloud-enabled tools to help you in this area as well. So yes, we will make some downloadable tools available in due course; keep tuned in for all the exciting developments.

That said, there are some downsides to the cloud paradigm that you need to be aware of:

Please see our Terms of Service for details.