Home > database >  Postgres - Use LPAD with raise info
Postgres - Use LPAD with raise info

Time:02-25

In postgres when I SELECT LPAD('begin ',50,'*'); it works and shows displays "********************************************begin " which is expected.

I want to use the same in a block with displaying parameter. Using below code.

DO $$ 
DECLARE
BEGIN 
    raise info LPAD('begin %',50,'*'),clock_timestamp();  
    raise info 'begin %',clock_timestamp();
END $$;

It throws error, ERROR: unrecognized exception condition "lpad". Tried many thing but didn't work. Any suggestion to fix this error. Thanks

CodePudding user response:

DO $$
    DECLARE  a text;
    BEGIN
        raise info 'begin %', lpad(clock_timestamp()::text, 50, '*');
        raise info 'begin %',clock_timestamp();
END $$;
  • Related