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 8088841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:12:27+00:00 2026-06-05T19:12:27+00:00

I have defined a table type PL/SQL variable and added some data there. create

  • 0

I have defined a table type PL/SQL variable and added some data there.

create or replace type varTableType as table of varchar2(32767);
my_table varTableType := varTableType()
...
my_table := some_function();

Now I have this my_table table type variable with several thousands of records.
I have to select only those records ending with specific character, say ‘a’ and get results in a comma separated string.
I think that COLLECT function could do this, but I do not understand exactly how.
I am using Oracle 10g.

  • 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-05T19:12:29+00:00Added an answer on June 5, 2026 at 7:12 pm

    Without getting into the question- why are you using a table type and not a table (or temporary table), you can do it like this:

    declare
      my_table varTableType;
      i varchar2(32767);
    begin
      my_table := new
                  varTableType('bbbb', 'ccca', 'ddda', 'eee', 'fffa', 'gggg');
    
      select trim(xmlagg(xmlelement(e, column_value || ','))
                  .extract('//text()'))
        into i
        from table(my_table)
       where column_value like '%a';
    
      dbms_output.put_line(i);
    
    end;
    

    There are more ways to concat rows- WM_CONCAT (if enabled) or LISTAGG (since 11g R2) but the basic idea of

    select column_value 
    from table(my_table) 
    where column_value like '%a';
    

    stays


    There is another way without sql:

    declare
      my_table varTableType;
      i varchar2(32767);
    begin
      my_table := new
                  varTableType('bbbb', 'ccca', 'ddda', 'eee', 'fffa', 'gggg');
    
      FOR j IN my_table.first .. my_table.last LOOP
    
         IF my_table(j) like '%a' THEN
            i := i || my_table(j);
         END IF;
    
      END LOOP;
    
      dbms_output.put_line(i);
    
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a user defined table type: create or replace type SrcCodeTbl
I have a user-defined type: create or replace type my_message_type as object (relatedid varchar2(50),
Suppose I have some data types defined in PL/SQL: TYPE foo_t IS RECORD (...);
I have an user defined table function in SQL Server that aggregate data from
I have a table defined by the following SQL: CREATE TABLE test ( id
I have an SQL table defined as below: CREATE TABLE [TestComposite] ( ID int,
Basically I have a User-Defined Table Type (for use as a table-valued variable) which
In Oracle I've created a data type: TABLE of VARCHAR2(200) I want to have
I have this SQL Server 2008 UDT: CREATE TYPE [dbo].[IdentityType] AS TABLE( [Id] [int]
I have a table that contains a GEOMETRY data type. SQL Server 2008 ships

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.