Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9081865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:25:07+00:00 2026-06-16T20:25:07+00:00

I have a list of comma-separated strings (from a user input) and I’d like

  • 0

I have a list of comma-separated strings (from a user input) and I’d like to use this list as a parameter in a pl/sql stored function in a nested sql block using a “not in where clause”.

I can’t find an elegant way to make it work…

That’s what I’m thinking of:

CREATE TABLE example ( somevalue VARCHAR(36) NOT NULL);
--
INSERT INTO example VALUES ('value1');
INSERT INTO example VALUES ('value2');
INSERT INTO example VALUES ('value3');
--
SELECT * FROM example;
--
CREATE OR REPLACE
  FUNCTION resultmaker(
      ignoreList IN VARCHAR2)
    RETURN VARCHAR2
  IS
    result VARCHAR2(4000);
  BEGIN
    result  := 'Here is my calculated result, using ignorelist=' || ignoreList || ':'     || CHR(10);
    FOR rec IN
    (SELECT DISTINCT somevalue
    FROM example
    WHERE somevalue NOT IN resultmaker.ignoreList -- here's my issue, the NOT IN     clause using the parameter value
    )
    LOOP
      result := result || 'not in ignorelist: ' || rec.somevalue || CHR(10);
    END LOOP;
    result := result || '.' || CHR(10);
    --
    RETURN result;
  END resultmaker;
  /
--
-- simulate function call with user input 'value2, value3'
SELECT resultmaker('value2, value3') FROM dual; -- doesn't work  
--
DROP TABLE example;
DROP FUNCTION resultmaker;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:25:08+00:00Added an answer on June 16, 2026 at 8:25 pm

    Here’s my solution using dynamic sql for my original question above:

    CREATE TABLE example ( somevalue VARCHAR(36) NOT NULL);
    --
    INSERT INTO example VALUES ('value1');
    INSERT INTO example VALUES ('value2');
    INSERT INTO example VALUES ('value3');
    --
    SELECT * FROM example;
    --
    CREATE OR REPLACE
      FUNCTION resultmaker(
          ignoreList IN VARCHAR2)
        RETURN VARCHAR2
      IS
        result VARCHAR2(4000);
        example_cursor sys_refcursor;
        rec example.somevalue%type;
      BEGIN
        result := 'Here is my calculated result, using ignorelist=' || ignoreList || ':' || CHR(10);
        OPEN example_cursor FOR ( 'SELECT DISTINCT somevalue FROM example WHERE somevalue NOT IN (' || ignoreList || ')' );
        FETCH example_cursor INTO rec;
        WHILE example_cursor%found
        LOOP
          result := result || 'not in ignorelist: ' || rec || CHR(10);
          FETCH example_cursor INTO rec;
        END LOOP;
        CLOSE example_cursor;
        result := result || '.' || CHR(10);
        --
        RETURN result;
      END resultmaker; 
    /
    --
    -- simulate function call with user input 'value2', 'value3'
    SELECT resultmaker('''value2'', ''value3''') FROM dual;
    --
    DROP TABLE example;
    DROP FUNCTION resultmaker;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to loop through comma separated list in SQL? I have a list of
I have a list of ID's, comma separated stored as string. 123,456,789 I was
I have a comma separated list, and would like to remove the first occurrence
Possible Duplicate: The most sophisticated way for creating comma-separated Strings from a Collection/Array/List? I
I have a List and it is filled with strings like this: List<string> data
I am having difficulty retrieving a comma separated list from MSAccess using SQL. It
I have a string ($c) that contains a comma-separated list of settings. Some settings
I have a very simple function that takes a list of comma separated (x,y)
I have a HTML form that accepts a comma separated list of tags, which
I have a DB table that contains a comma separated list of ID's (ints)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.