Splice Machine PL/SQL extends Splice Machine SQL with a procedural language you can use to perform operations that you would otherwise write as SQL queries. Splice Machine PL/SQL provides the same functionality as Oracle PL/SQL, with a few notable exceptions, which are detailed in the Splice Machine PL/SQL Compared to Oracle PL/SQL section below.
Splice*Plus is an interactive, command line utility program that provides an interpreter for running PL/SQL programs interactively. You can run PL/SQL programs stored in text files, or you can use your keyboard to enter PL/SQL statements and blocks, similarly to the way you use the splice> prompt to run SQL commands.
If you are already familiar with PL/SQL from using it with Oracle or another database, Splice Machine PL/SQL is almost exactly the same. The PL/SQL topic in this section calls out any differences you need to know about between this implementation of PL/SQL and other implementations.
Hello World in PL/SQL
Here’s a basic PL/SQL version of “Hello World:”
DECLARE message varchar2(20):= 'Hello, World!'; BEGIN dbms_output.put_line(message); EXCEPTION WHEN PROGRAM_ERROR THEN dbms_output.put_line('Uh-oh; something went wrong'); END; /
/ at the end of the program block is required to tell the
PL/SQL interpreter that it should run the code block; if you leave the
/ out, the interpreter will simply wait for more input after loading
SplicePlus* is automatically installed for you when you install Splice Machine. To run a PL/SQL program that you have stored in a text file, invoke spliceplus and specify on the command line that it should take its input from that file:
% spliceplus < helloworld.sql
You’ll see your code loaded in and executed, and any results will display on your screen. For example:
% spliceplus < helloworld.sqlSource file is hellowworld.sqlExecuting:DECLARE message varchar2(20):= 'Hello, World!'; BEGIN dbms_output.put_line(message);EXCEPTION dbms_output.put_line('Uh-oh; something went wrong'); END;Hello, World!%
To invoke the Splice*Plus interactive environment, open a terminal window and enter the following command line:
You can enter SQL statements to execute, or you can enter a block of
PL/SQL code. When you want to run PL/SQL code, simply enter a
/ on a
line by itself, and splice*plus will
execute the block and display the results.
Creating, Editing, and Managing Your Splice*Plus programs
- Basics of creating a program within the interpreter and externally.
- Basics of editing an existing program.
- Managing programs stored in your database
Debugging Your Splice*Plus Programs
Tools to help debugging