Re: 4GL -> SPL (was SPL SQL statments with variabl
Posted in 2009
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
I think its pretty easy to use..
It works just like Informix 4GL (C compiler version) - theres only a couple of
minor difference (we automatically prepend function names with aclfgl_ to try
to avoid 'overlaps' with functions in the C library)..
As for an SPL version - the idea is that you'd create special 4gl modules
which you'd compile to SPL. Theres a lot of constructs that wont go across (I
dont know if Arrays or substrings with variables work in SPL for example) -
and of course - any user interaction wont be meaningful (how would you do
a 'MESSAGE' for example?)
But - provided we screened those out - it'd be a great way to get business
logic developed in 4GL into the backend.
Also - it'd be a great way to develop new Stored procedures - 4GL is far
better as a development language than SPL.
BTW - I did a very simplified POC - just to illustrate the point, I can
currently automatically convert :
database test1
define mv_somevar integer
define mv_somevar2 char(20)
function bibble(op,a,b)
define op char(2)
define a,b integer
define r record d,e char(2) end record
define r2 record
f1,f2 char(3),
cr record
f3,f4 char(4)
end record
end record
let r2.cr.f3=2
let mv_somevar=2
case op
when "+" return a+b
when "-" return a-b
end case
if op="*" then
let a=a*b
return a
else
let a=a/b
return a
end if
exit program 4
end function
Into :
CREATE PROCEDURE bibble (In_op CHAR(2),In_a INTEGER,In_b INTEGER)
RETURNING INTEGER;
DEFINE a INTEGER;
DEFINE b INTEGER;
DEFINE op CHAR(2);
DEFINE r_d CHAR(2);
DEFINE r_e CHAR(2);
DEFINE r2_f1 CHAR(3);
DEFINE r2_f2 CHAR(3);
DEFINE r2_cr_f3 CHAR(4);
DEFINE r2_cr_f4 CHAR(4);
DEFINE GLOBAL Mm1__mv_somevar INTEGER DEFAULT NULL;
DEFINE GLOBAL Mm1__mv_somevar2 CHAR(20) DEFAULT NULL;
-- #####################################
-- Copy parameters into real variables
LET op=In_op;
LET a=In_a;
LET b=In_b;
-- #####################################
LET r2_cr_f3=2;
LET Mm1__mv_somevar=2;
IF op="+" THEN
RETURN a+b;
ELIF op="-" THEN
RETURN a-b;
END IF;
IF op="*" THEN
BEGIN
LET a=a*b;
RETURN a;
END
ELSE
BEGIN
LET a=a/b;
RETURN a;
END
END IF;
RAISE EXCEPTION 4;
END PROCEDURE
:-)
On Thursday 08 January 2009 11:07:18 THEUNS VAN ONSELEN wrote:
> Sounds very interesting Mike, but I DEFINITELY won't have the time :(
>
> Haven't used Aubit before, easy to use?
>
>
> ***************************************************************************
>**** Forum Note: Use "Reply" to post a response in the discussion forum.
--
Mike Aubury
http://www.aubit.com/
Aubit Computing Ltd is registered in England and Wales, Number: 3112827
Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ
Very interesting, would be extremely useful when you need to host processing rules in a central place that multiple systems can access and no 4gl compilation and deployment... very handy :)