11

Is there a way to split a long line of PL/pgSQL code over multiple lines? My context is a trigger function where I log inserts into a table as per:

INSERT INTO insert_log (log_time, description)
VALUES (
    now()
    , 'A description. Made up of 3 semi long sentences. That I want to split, in the code, not in the log table, over 3 lines for readability.'
);
  • 2
    That is plain SQL, not PL/pgSQL – a_horse_with_no_name Jul 14 '16 at 10:36
  • I only included the chunk that I needed help with, it's part of a PL/pgSQL function. – dw8547 Jul 14 '16 at 10:48
16

String constants can be split over multiple lines as documented in the manual

INSERT INTO insert_log (log_time, description)
VALUES (
    now()
    , 'A description. Made up of 3 semi long sentences. '
      'That I want to split, in the code, not in the log table, '
      'over 3 lines for readability.'
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.