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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:50:50+00:00 2026-05-20T10:50:50+00:00

I wrote a query that works like a charm in SQL Server. Unfortunately it

  • 0

I wrote a query that works like a charm in SQL Server. Unfortunately it needs to be run on an Oracle db. I have been searching the web inside out for a solution on how to convert it, without any success :/

The query looks like this i SQL:

UPDATE tab1   SET budgpost_gr1=     
CASE  WHEN (budgpost in (1001,1012,50055))  THEN 'BP_GR_A'   
      WHEN (budgpost in (5,10,98,0))  THEN 'BP_GR_B'  
      WHEN (budgpost in (11,876,7976,67465))     
      ELSE 'Missing' END`

My problem is also that the columns budgetpost_gr1 and budgetpost is alphanumeric and Oracle seems to want to see the list as numbers. The list are variables/parameters that is pre-defined as comma separated lists, which is just dumped into the query.

  • 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-20T10:50:50+00:00Added an answer on May 20, 2026 at 10:50 am

    Got a solution that runs. Don’t know if it is optimal though. What I do is to split the string according to http://blogs.oracle.com/aramamoo/2010/05/how_to_split_comma_separated_string_and_pass_to_in_clause_of_select_statement.html

    Using:
    select regexp_substr(' 1, 2 , 3 ','[^,]+', 1, level) from dual
    connect by regexp_substr('1 , 2 , 3 ', '[^,]+', 1, level) is not null;

    So my final code looks like this ($bp_gr1' are strings like 1,2,3):

    UPDATE TAB1
    SET    BUDGPOST_GR1 =
              CASE
                 WHEN ( BUDGPOST IN (SELECT     REGEXP_SUBSTR ( '$BP_GR1',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                     FROM       DUAL
                                     CONNECT BY REGEXP_SUBSTR ( '$BP_GR1',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                                   IS NOT NULL) )
                 THEN
                    'BP_GR1'
                 WHEN ( BUDGPOST IN (SELECT     REGEXP_SUBSTR ( ' $BP_GR2',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                     FROM       DUAL
                                     CONNECT BY REGEXP_SUBSTR ( '$BP_GR2',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                                   IS NOT NULL) )
                 THEN
                    'BP_GR2'
                 WHEN ( BUDGPOST IN (SELECT     REGEXP_SUBSTR ( ' $BP_GR3',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                     FROM       DUAL
                                     CONNECT BY REGEXP_SUBSTR ( '$BP_GR3',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                                   IS NOT NULL) )
                 THEN
                    'BP_GR3'
                 WHEN ( BUDGPOST IN (SELECT     REGEXP_SUBSTR ( '$BP_GR4',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                     FROM       DUAL
                                     CONNECT BY REGEXP_SUBSTR ( '$BP_GR4',
                                                                '[^,]+',
                                                                1,
                                                                LEVEL )
                                                   IS NOT NULL) )
                 THEN
                    'BP_GR4'
                 ELSE
                    'SAKNAR BUDGETGRUPP'
              END;
    

    Is there a way to make it run faster?

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

Sidebar

Related Questions

In SQL one can write a query that searches for a name of a
During my work with databases I noticed that I write query strings and in
How do I write a query that outputs the row number as a column?
I need to write a query that will group a large number of records
I'm trying to write a query that will pull back the two most recent
I'm trying to write a query that extracts and transforms data from a table
I'm trying to write a query that updates rows in a table if a
Using standard mysql functions is there a way to write a query that will
I am trying to write a MySQL query that retrieves one record from table
I need to write a select query that joins the tables based on a

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.