Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Procedure

It is similar to PL/SQL of ORACLE.

Code Block
c
c
CREATE OR REPLACE PROCEDURE proc()
AS
// declare variable
BEGIN
// User-Code
END;
/

Call Proc in Embedded-SQL

Code Block
c
c
...
EXEC SQL EXECUTE
  BEGIN
     pro_name();
  END;
END-EXEC;
  • APRE doesn't support functionality as follows.
    Code Block
    c
    c
    char ename[100];
    int sal;
    
    ...
    // It is not supported.
    EXEC SQL EXECUTE
    BEGIN
      SELECT ename, sal into :ename, :sal FROM employee;
    END;
    END-EXEC;
    
  • ALTIBASE HDB doesn't support returning array-result.
  • ALTIBASE HDB doesn't support a external procedure. (like procedure that it is stored in library-files)

Sample Code

Code Block
c
c
// Procedure Sample
CREATE OR REPLACE PROCEDURE proc1(ename in CHAR(40), o_sal out INTEGER)
AS
BEGIN
  SELECT sal INTO o_sal FROM employee WHERE name = ename;
END;
/

// APRE source Sample
#include <stdio.h>

main()
{
  EXEC SQL BEGIN DECLARE SECTION;
    char name[40+1];
    int  sal;
  EXEC SQL END DECLARE SECTION;


  // Connect To DB
  ...
  // Call Procedure
  sprintf (name, "Andy Park");

  EXEC SQL EXECUTE
    BEGIN
      proc1(:name, :sal);
    END;
  END-EXEC;

Difference from ORACLE in Procedure

If you execute a procedure having DML statement in auto-commit mode, you can search records affected after execution of procedure is complete.

If you want to do it with ORACLE-style, you have to execute a procedure after change to Non-Autocommit mode in your session.