Fernando Alberto Velasquez wrote

>Hi

>I need port a PL/pgSQL function to SAPDB But i am failed, somebody help me?

>The the function is:

>DROP FUNCTION "lafuncion"();CREATE DBPROC lafuncion(out as int) AS
>VAR
>idnum INTEGER;
>begin
>select max(id) from dba.latabla into :idnum;
>end;
>idnum INTEGER;
>begin
>IF NEW.id ISNULL THEN
>select into idnum max(id) from latabla ;
>IF idnum ISNULL THEN
>NEW.id := 1;
>END IF;
>IF idnum >= 1 THEN
>NEW.id := idnum + 1;
>END IF;
>END IF;
>RETURN NEW;
>end;
>' LANGUAGE 'plpgsql';


>I try this on SAPDB but dont work :

>CREATE DBPROC lafuncion(out as int) AS
>VAR
>idnum INTEGER;
>idnum2 = INTEGER;
>begin
>select max(id) from dba.latabla;
>fetch into :idnum;
>SET idnum2 = idnum + 1;
>if idnum >= 1 then
>set NEW.id = idnum2;
>return new;
>end;

CREATE DBPROC lafuncion(out result int) AS
VAR
idnum INTEGER;
begin
select max(id) into :idnum from dba.latabla;
if idnum is null
then
  result = 1
else
  if idnum >= 1 
  then
    result = idnum + 1;
end;

Please note that this creates a db-procedure, not a db-function, i.e.
you cannot use this db-procedure in any sql statement except the
call statement. 
db-functions aren't supported by SAPDB yet. 

Regards,
Thomas

-- 
Thomas Anhaus
SAP DB, SAP Labs Berlin
[EMAIL PROTECTED]
http://www.sapdb.org/
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general


_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to