Q

Using PL/SQL to read delimited ASCII text files... Part 5

Continued from Part 4...

-- *********************
-- **  u n q u o t e  **
-- *********************

--  unquote returns a copy of in_text with all doubled 
--  occurrences of in_quote_text changed to single occurrences.
--  If in_text starts with quote_text, the starting quote is
--  removed first, and an equal length (assumed to be a closing
--  quote, but not checked that it is) is removed from the end.

FUNCTION unquote
(
  in_text         IN      VARCHAR2,
  in_quote_text   IN      VARCHAR2
)
RETURN  VARCHAR2
IS
  quote_len PLS_INTEGER := LENGTH (in_quote_text);
  return_text VARCHAR2 (32767) := in_text;
BEGIN
  IF  in_quote_text IS NOT NULL
  THEN
    IF  INSTR (in_text, in_quote_text) = 1
    THEN
      return_text := SUBSTR ( in_text,
                              1 + quote_len,
                              LENGTH (in_text) - (2 * quote_len)
                            );
    END IF;

    return_text := REPLACE ( return_text,
                             in_quote_text || in_quote_text,
                             in_quote_text
                           );
  END IF;

  RETURN  return_text;
END unquote;


-- ******************************
-- **  Initialization Section  **
-- ******************************

BEGIN
 unclaimed_text := '';
END pk_csv;
/


GRANT  EXECUTE  ON csv.pk_csv  TO csv_admin;


This was first published in July 2003

Dig deeper on Using Oracle PL-SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close