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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:55:06+00:00 2026-06-08T04:55:06+00:00

I have a merge query like this MERGE INTO dept a USING ( SELECT

  • 0

I have a merge query like this

MERGE INTO dept a
 USING (
     SELECT  50           deptno
          , 'ENGINEERING' dname
          , 'WEXFORD'     loc
     FROM dual
 ) b
 ON (a.deptno = b.deptno)
 WHEN NOT MATCHED THEN
     INSERT VALUES (b.deptno, b.dname, b.loc)
 WHEN MATCHED THEN
     UPDATE SET a.loc = 'WEXFORD, PA';

I need output like:

INSERT VALUES (b.deptno,b.dname,b.loc)
UPDATE SET a.loc='WEXFORD,pA'

Can I achieve this by using substring any another simple way to do this.

  • 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-08T04:55:09+00:00Added an answer on June 8, 2026 at 4:55 am

    As I understand it, you don’t particularly care about executing the query, you only want to extract certain parts of the query text, right? Your best bet would be formulating a regular expressions describing those parts, matching them against the input string, and printing the relevant parts of each match you find.

    A simple example would be this:

    import java.util.regex.*;
    class Foo {
        private static final Pattern re
          = Pattern.compile("INSERT VALUES \\(.*?\\)|UPDATE SET .*;");
        static void find(String text) {
            Matcher m = re.matcher(text);
            while (m.find())
                System.out.println(m.group());
        }
    }
    

    This simple example expects insert parts to contain spaces exactly as stated in the expression, and to be followed a single list of parenthesized arguments. The update is expected to continue to the end of the query. See the Pattern documentation on how to formulate regular expressions.

    If you want to deal with strings, which might contain parentheses, semicolons and even words that look like SQL commands, things will become more difficult. And if you at some point should reqire detection of arbitrary levels of nested parenthesis, then this cannot be expressed using regular expressions at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that returns all stream posts from users (with comments): SELECT
I've got 2 queries I'd like to merge into 1 result set without using
I have a query below which displays these results: SELECT q.QuestionId, q.QuestionContent, an.Answer FROM
I have two iterators which i have to merge into one result. Here are
I have to array and I want to merge this two array with a
I have 2 images and I want to merge them into one on my
I have multiple datasets that I would like to combine into one. There is
I have a simple query over a table, which returns results like the following:
I have a complex table pulled from a multi-ActiveRecord object array. This listing is
please consider this image: I have a table like this: Age Active Men/Women -------------------------------------------------

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.