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

  • Home
  • SEARCH
  • 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 6795041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:17:42+00:00 2026-05-26T18:17:42+00:00

I know that there are REGEXP_ functions, but this ones return maximum 1 row

  • 0

I know that there are REGEXP_ functions, but this ones return maximum 1 row when simply applied to a string var. I know that you can use it in a WHERE clause, but I need a way of dealing with large strings/text/clob vars not tables, so I would like to know if some function can return multiple substrings somehow (I am thinking at something like the explode() or – even better – preg_match() in PHP).

As APC suggested I am providing a sample string and examples of outcomes that I would like to get..
Like I said in the comments bellow, I wand to get the functions/procedures bodies (functions/procedures that are part of some packages) like this:

THE STRING:

  create or replace PACKAGE BODY export_db IS
  FUNCTION o_functie(ceva NUMBER) return boolean IS
  BEGIN
    RETURN null;
  END;
  FUNCTION o_functie(ceva NUMBER, altceva VARCHAR2) return boolean IS
  BEGIN
    RETURN null;
  END;
  PROCEDURE export_db_tabele IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT object_type,object_name FROM user_objects where object_type IN ( 'TABLE')) LOOP
        v_ddl := v_ddl || dbms_metadata.get_ddl(c.object_type, c.object_name)||';'||CHR(13)||CHR(10);   
      END LOOP; 
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('tabele', v_ddl);
  END;
  PROCEDURE export_db_restrictii IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT constraint_name FROM user_constraints) LOOP
        v_ddl := v_ddl || dbms_metadata.get_ddl('CONSTRAINT', c.constraint_name)||';'||CHR(13)||CHR(10);   
      END LOOP; 
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('restrictii', v_ddl);
  END;
  PROCEDURE export_db_secvente IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT sequence_name FROM user_sequences) LOOP
        v_ddl := v_ddl || dbms_metadata.get_ddl('SEQUENCE', c.sequence_name)||';'||CHR(13)||CHR(10);   
      END LOOP; 
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('secvente', v_ddl);
  END;
  PROCEDURE export_db_proceduri IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT OBJECT_NAME FROM user_objects up WHERE object_type = 'PROCEDURE') LOOP 
        v_ddl := v_ddl || dbms_metadata.get_ddl('PROCEDURE', c.OBJECT_NAME)||CHR(13)||CHR(10);   
      END LOOP;  
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('proceduri', v_ddl);
  END;
  PROCEDURE export_db_functii IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT OBJECT_NAME FROM user_objects uo WHERE object_type = 'FUNCTION' ) LOOP 
         v_ddl := v_ddl || dbms_metadata.get_ddl('FUNCTION', c.OBJECT_NAME)||CHR(13)||CHR(10);   
      END LOOP; 
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('functii', v_ddl);
  END;
  PROCEDURE export_db_pachete IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT OBJECT_NAME FROM user_objects uo WHERE object_type = 'PACKAGE' ) LOOP 
        v_ddl := v_ddl || dbms_metadata.get_ddl('PACKAGE', c.OBJECT_NAME)||CHR(13)||CHR(10);   
      END LOOP;   
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('pachete', v_ddl);
  END;
  PROCEDURE export_db_declansatoare IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT OBJECT_NAME FROM user_objects uo WHERE object_type = 'TRIGGER' ) LOOP 
        v_ddl := v_ddl || dbms_metadata.get_ddl('TRIGGER', c.OBJECT_NAME)||CHR(13)||CHR(10);   
      END LOOP; 
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('declansatoare', v_ddl);
  END;
END;

OUTCOMES would be:

ex:

  FUNCTION o_functie(ceva NUMBER, altceva VARCHAR2) return boolean IS
  BEGIN
    RETURN null;
  END;

and

PROCEDURE export_db_secvente IS
    v_ddl CLOB;
  BEGIN
      FOR c IN(SELECT sequence_name FROM user_sequences) LOOP
        v_ddl := v_ddl || dbms_metadata.get_ddl('SEQUENCE', c.sequence_name)||';'||CHR(13)||CHR(10);   
      END LOOP; 
      INSERT INTO dbexport(tipobiect, ddltext) VALUES ('secvente', v_ddl);
  END;

IF you know any other method of geting those procedures/functions I am glad to give up parsing all this – from what I know – there is no select to do that… not even from user_source, user_procedures tables or other…

  • 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-05-26T18:17:43+00:00Added an answer on May 26, 2026 at 6:17 pm

    Something like this maybe:

    CREATE OR REPLACE FUNCTION explode(longline varchar)
      RETURN sys.dbms_debug_vc2coll PIPELINED
    IS  
      pos PLS_INTEGER;
      lastpos PLS_INTEGER;
      element varchar(2000);
    BEGIN
       lastpos := 1;
       pos := instr(longline, ',');
    
       while pos > 0 loop
          element := substr(longline, lastpos, pos - lastpos);
          lastpos := pos + 1;
          pos := instr(longline, ',', lastpos);
          pipe row(element);
       end loop;
    
       if lastpos <= length(longline) then
          pipe row (substr(longline, lastpos));
       end if;
    
       RETURN;
    END;  
    /
    

    This can be used like this:

    SQL> select * from table(explode('1,2,3'));
    
    COLUMN_VALUE
    ---------------------------------------------
    1
    2
    3
    SQL>
    

    If you are not on 11.x you need to define the return type yourself:

    create type char_table as table of varchar(4000);
    

    and change the function declaration to:

    CREATE OR REPLACE FUNCTION explode(longline varchar)
      RETURN char_table pipelined
    .....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there are lots of examples out there on this, but they
I know that there can be multiple values for an email, but I'm not
I know that there are many Delphi database related questions available, but I'm considering
I know that there is no return type of the constructors in C++ However,
i know that there is some rules and standards in css handling but i
Is there a shorter way of writing this (without using regex or string-matching functions)?
I know that there is no way to fully protect our code. I also
I know that there are many free and not so free compression libraries out
I know that there is an allocator for user applications than handles lots of
I know that there are so many standards for writing code. And some policy

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.