update of old PL/SQL PLpgSQL and SQLPL patch based on current version

see [linguist] add support for oracle PLSQL (#1003)
This commit is contained in:
David Pyke Le Brun
2015-02-06 13:36:40 +00:00
parent 6d770ab68f
commit 3e54d6651c
22 changed files with 1213 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
create or replace type myobject
AUTHID DEFINER
AS OBJECT
(
m_name varchar2(200),
member function toString RETURN VARCHAR2,
map member function Compare return varchar2
)
not instantiable not final;
/
prompt create type myarray
create or replace type myarray as table of myobject;
/

View File

@@ -0,0 +1,58 @@
CREATE OR REPLACE PACKAGE BODY linguistpackage
AS
/*
* Package: linguist pacakage body
* Purpose: a sample PLSQL file for linguist to work with
*
* Date: 03/03/2014
* Author: david pyke le brun
* Comments: initial version
*/
PROCEDURE proc_1
IS
BEGIN
NULL;
END;
-- functions with 1 arg
FUNCTION function1( param1 VARCHAR2 ) RETURN VARCHAR2
IS
CURSOR c IS
select * from dual;
v c%ROWTYPE;
BEGIN
open c;
fetch c into v;
close c;
return v;
end;
FUNCTION function2( param1 NUMBER ) RETURN DATE
IS
BEGIN
return SYSDATE;
end;
--a few more to use all basic SQL types
FUNCTION function3( param1 TIMESTAMP ) RETURN CHAR
IS
BEGIN
IF 1 = 2 THEN
return 'Y';
ELSE
return 'N';
END IF;
return NULL;
END;
FUNCTION function4( param1 CLOB ) RETURN BLOB
IS
BEGIN
return null;
END;
END linguistpackage;
/

View File

@@ -0,0 +1,28 @@
CREATE OR REPLACE PACKAGE linguistpackage
AUTHID DEFINER
AS
/*
* Package: linguist pacakage
* Purpose: a sample PLSQL file for linguist to work with
*
* Date: 03/03/2014
* Author: david pyke le brun
* Comments: initial version
*/
k_constant CONSTANT NUMBER(10,2) := 3.14;
--basic procedure
PROCEDURE proc_1;
-- functions with 1 arg
FUNCTION function1( param1 VARCHAR2 ) RETURN VARCHAR2;
FUNCTION function2( param1 NUMBER ) RETURN DATE;
--a few more to use all basic SQL types
FUNCTION function3( param1 TIMESTAMP ) RETURN CHAR;
FUNCTION function4( param1 CLOB ) RETURN BLOB;
END linguistpackage;
/

View File

@@ -0,0 +1,65 @@
CREATE OR REPLACE PROCEDURE who_called_me
( owner OUT VARCHAR2,
name OUT VARCHAR2,
lineno OUT NUMBER,
caller_t OUT VARCHAR2 ,
depth NUMBER DEFAULT 1
)
AUTHID DEFINER
AS
--depth based version of who_called_me from asktom
call_stack VARCHAR2(4096) default dbms_utility.format_call_stack;
n NUMBER;
found_stack BOOLEAN DEFAULT FALSE;
line VARCHAR2(255);
cnt NUMBER := 0;
BEGIN
LOOP
n := instr( call_stack, chr(10) );
exit when ( n is NULL or n = 0 );
--
line := substr( call_stack, 1, n-1 );
call_stack := substr( call_stack, n+1 );
--
if ( NOT found_stack ) then
if ( line like '%handle%number%name%' ) then
found_stack := TRUE;
end if;
else
cnt := cnt + 1;
-- cnt = 1 is ME
-- cnt = 2 is MY Caller
-- cnt = 3 is Their Caller
if ( cnt = (2+depth) ) then
lineno := to_number(substr( line, 13, 8 ));
line := substr( line, 23 ); --set to rest of line .. change from 21 to 23
if ( line like 'pr%' ) then
n := length( 'procedure ' );
elsif ( line like 'fun%' ) then
n := length( 'function ' );
elsif ( line like 'package body%' ) then
n := length( 'package body ' );
elsif ( line like 'pack%' ) then
n := length( 'package ' );
elsif ( line like 'anonymous%' ) then
n := length( 'anonymous block ' );
else
n := null;
end if;
if ( n is not null ) then
caller_t := ltrim(rtrim(upper(substr( line, 1, n-1 ))));
else
caller_t := 'TRIGGER';
end if;
line := substr( line, nvl(n,1) );
n := instr( line, '.' );
owner := ltrim(rtrim(substr( line, 1, n-1 )));
name := LTRIM(RTRIM(SUBSTR( LINE, N+1 )));
exit;
END IF;
END IF;
END LOOP;
END;
/