Extracting tokens from a string using substr function.

Posted on 2011-04-27
Last Modified: 2013-12-07
Tokens come within #..#, and are not fixed, could be any number.

Program should extract tokens one by one and assign it into variable.
Question by:gram77

    Author Comment


    sample string
    This report is ran on #sysdate#, The report is run on #as_of_dt#. Report is written on file #name#
    LVL 4

    Expert Comment

    Assuming name adn as_of_dt are variables
    select regexp_replace( regexp_replace(regexp_replace('This report is ran on #sysdate#, The report is run on #as_of_dt#. Report is written on file #name#','#sysdate#', sysdate),
                                                                         '#name#', name),
                                      '#as_of_dt#',as_of_dt) from dual

    If as_of_dt,name are column name then replace dual with table name.
    LVL 76

    Accepted Solution

    So if I read this right, you want to extract say #sysdate# then assign that to a pl/sql variable like:    #sysdate# := 'some value'

    If so, sdstuber already provided the main piece of the code in:

    I provided the loop to loop through the delimited strings in the same question:

    Please confirm the exact requirements and we'll see if we can provide working code.
    LVL 14

    Assisted Solution

    for this we have written a procedure.  

    Attached is the procedure and other file is calling of the procedure

    HTH parse-list.sql calling-pk-parse-list.sql

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now