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 last published in July 2003

Dig Deeper on Using Oracle PL-SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

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.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close