READ_LINE v14

The READ_LINE procedure reads a single line of text from an established connection, stopping when it encounters a newline character sequence.

READ_LINE (
  c    IN connection,
  data IN OUT VARCHAR2
);

Parameters

c

The connection handle of the active session, originally returned by OPEN_CONNECTION.

data

The IN OUT buffer that receives the text read from the connection.

Notes

  • Newline termination: The procedure reads data until it reaches the newline sequence.

  • Buffer limits: Ensure the VARCHAR2 variable passed to data is large enough to hold the expected line length. If a line exceeds the buffer size or the internal in_buffer_size, an exception may be raised.

  • Blocking behavior: This procedure will wait for a complete line to arrive or until the tx_timeout duration is reached.

Example

DECLARE                   
  c        UTL_TCP.CONNECTION;
  strReply TEXT;
  count    INT;
BEGIN
  c := UTL_TCP.OPEN_CONNECTION('mail-arts.enterprisedb.com', 25);
  DBMS_OUTPUT.PUT_LINE('--- Sending Request ---');
  count := UTL_TCP.WRITE_LINE(c, 'HELO localhost');
  DBMS_OUTPUT.PUT_LINE('--- Receiving Response ---');
  UTL_TCP.READ_LINE(c, strReply);
  DBMS_OUTPUT.PUT_LINE('reply >> ' || strReply);
END;