连接字符串时插入换行符

时间:2016-09-02 12:52:08

标签: sql oracle12c

我有一个包从某些表中删除旧元素 该包在批处理中运行,并将其结果写入日志文件 问题是由于某种原因,在连接一些字符串时会插入换行符。

这是一般的日志程序:

-- *****************************************************************************
-- This procedure logs the specified message
-- *****************************************************************************
PROCEDURE LogMessage
(
  p_message IN VARCHAR2
)
IS
BEGIN

  -- Log message
  dbms_output.put_line(TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') || ' ' || p_message);

END LogMessage;

这是产生问题的程序:

-- *****************************************************************************
-- This procedure logs the specified message
-- *****************************************************************************
PROCEDURE LogPurgeResult
(
  p_table   IN VARCHAR2,
  p_records IN NUMBER
)
IS
  v_last_analyzed VARCHAR2(20);
  v_num_rows      NUMBER;
  v_message       VARCHAR2(256);
BEGIN

  -- Determine number of records within table
  SELECT TO_CHAR(last_analyzed, 'YYYY-MM-DD HH24:MI:SS'),
         num_rows
    INTO v_last_analyzed,
         v_num_rows
    FROM user_tables
   WHERE table_name = UPPER(p_table);

  -- Compose message
  v_message := 'Deleted ' || TO_CHAR(p_records) || ' records from ' || p_table;
  IF (v_last_analyzed IS NOT NULL) THEN
    v_message := v_message || '. Number of records at ' || v_last_analyzed || ' --> ' || TO_CHAR(v_num_rows);
  END IF;

  -- Log message
  LogMessage(v_message);

END LogPurgeResult;

我得到的输出是:

2016-09-02 09:37:38 Deleted 12 records from MONITORING_STATUS. Number of records at
2016-08-24 02:01:29 --> 1960

由于某种原因,在字符串Number of records at

之后插入换行符

如果我将字符串Number of records at更改为Records at,则会在日期之后插入换行符:

2016-09-02 09:48:47 Deleted 0 records from MONITORING_STATUS. Records at 2016-06-14
02:01:29 --> 1960

知道发生了什么事吗?

0 个答案:

没有答案
相关问题