views:

28

answers:

2

Although Oracle is one of the earliest to create stored procedures (PL/SQL) then Informix with (SPL) which RDBMS products besides DB2 have implemented SQL/PSM or a subset of it after 1998?.. Which RDBMS' can support procs like in the following example?:

 CREATE OR REPLACE FUNCTION foo1(a integer)
RETURNS void AS $$
  CASE a
    WHEN 1, 3, 5, 7, 9 THEN
      PRINT a, 'is odd number';
    WHEN 2, 4, 6, 8, 10 THEN
      PRINT a. 'is odd number';
    ELSE 
      PRINT a, 'isn't from range 1..10';
  END CASE;
$$ LANGUAGE plpgpsm;
+1  A: 

Only DB2 is close to PSM, AFAIK. Sybase had its Transact-SQL very early on; Microsoft borrowed that. Three dark horses that perhaps bear checking out are MySQL, PostgreSQL and Ingres. However, I don't recall thinking that any of them were close to PSM when I've looked at their code.

However, a Google search for 'mysql psm' suggests that MySQL 5.x and PostgreSQL 8.2 support a form of PSM close to the standard. (The search for 'ingres psm' shows that PSM in Ingres is a 'Partial Sort Merge' join technique.)

Jonathan Leffler
+1  A: 

It seems that each product contains its own implementation of stored modules, but most are pretty similar. For instance, your example could be rewritten in Oracle's PL/SQL as follows:

CREATE OR REPLACE PROCEDURE foo1(a integer) AS
BEGIN
  CASE
    WHEN a IN (1, 3, 5, 7, 9) THEN
      DBMS_OUTPUT.PUT_LINE(a || ' is odd number');
    WHEN a IN (2, 4, 6, 8, 10) THEN 
      DBMS_OUTPUT.PUT_LINE(a || ' is even number'); 
    ELSE
      DBMS_OUTPUT.PUT_LINE(a || ' isn''t FROM RANGE 1..10');
  END CASE;
END;

Share and enjoy.

Bob Jarvis