HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMajor

How do I split a long PL/pgSQL line of code over multiple lines?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
howlinelongsplitmultiplepgsqlcodeoverlines

Problem

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.'
);

Solution

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.'
);

Code Snippets

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.'
);

Context

StackExchange Database Administrators Q#143845, answer score: 43

Revisions (0)

No revisions yet.