SPL routines in SELECT statements
Previous examples in this chapter show SELECT statement expressions that consist of column names, operators, and SQL functions. This section shows expressions that contain an SPL routine call.
SPL routines contain special Stored Procedure Language (SPL) statements as well as SQL statements. For more information on SPL routines, see Create and use SPL routines.
HCL Informix® allows you to write external routines in C and in Java™. For more information, see HCL Informix User-Defined Routines and Data Types Developer's Guide.
SELECT col_a, test_func(col_b) FROM tab1
WHERE col_c = "Davis";
SPL routines that return more than a single value are not supported in the Projection clause of SELECT statements. In the preceding example, if test_func() returns more than one value, the database server returns an error message.
SPL routines provide a way to extend the range of functions available by allowing you to perform a subquery on each row you select.
SELECT customer_num, lname, get_orders(customer_num) n_orders
FROM customer;
customer_num lname n_orders
101 Pauli 1
102 Sadler 9
103 Currie 9
104 Higgins 4
⋮
123 Hanlon 1
124 Putnum 1
125 Henry 0
126 Neelie 1
127 Satifer 1
128 Lessor 0
SELECT stock_num, manu_code, description FROM stock
WHERE conv_price(unit_price, ex_rate = 1.50,
tariff = 50.00) < 1000;