pg>执行代码段
2021-09-24 14:57:22    25    0    0
ivan

例1:

create table tab_function_test(

    a int

);

do LANGUAGE plpgsql $$

    declare

      a int;

    begin

      -- a := datediff('month',now(),'2020-10-10') ;

      select datediff('month',now(),'2020-10-10') into a;

      insert into tab_function_test values(a);

    end$$

select * from tab_function_test;

select datediff('month',now(),'2020-10-10') ;


例2:

DO LANGUAGE plpgsql $$

DECLARE

     ret integer;

BEGIN

    ret := DATEDIFF('2008-11-30','2018-10-30');

    RAISE NOTICE '%',ret;

END; $$;

Pre: linux>常用命令

Next: pg>执行sql文件

25
Sign in to leave a comment.
No Leanote account? Sign up now.
0 comments
Table of content