如何将长长的PL / pgSQL代码行分成多行?


16

有没有办法将多行PL / pgSQL代码分割成多行?我的上下文是一个触发函数,在该函数中,我按照以下记录将插入日志记录到表中:

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
那是普通的SQL,不是PL / pgSQL
a_horse_with_no_name 2016年

我只包括需要帮助的部分,它是PL / pgSQL函数的一部分。
dw8547 '16

Answers:


23

字符串常量可以分成多行,如手册中所述

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.'
);
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.