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 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

Hi i've wrote a query that works: SELECT `comments`.* FROM `comments` RIGHT JOIN (SELECT
I have a query that I pulled from ms sql 2000 and plugged into
I have a mapping in NHibernate that works like so: <?xml version=1.0 encoding=utf-8 ?>
In SQL one can write a query that searches for a name of a
I have a table that looks like something like this: timestamp value person ===============================================
I want to write a stored procedure that works something like this: SELECT *
I have an error in my query sub query. I been trying to work
I have a table that looks like this: Timestamp Event User ================ ===== =====
I am trying write a SQL query that filters a gridview by the fields
Ok. I have searching on this site Since August 24 2011.(not that it matters)

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.