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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:30:17+00:00 2026-06-10T18:30:17+00:00

I need to update a table column with values that are derieved. To add

  • 0

I need to update a table column with values that are derieved. To add little more complexity, I need to concat a value based on the derivate and hence the value to append for concat is not always the same. I came up with this query, but it apparently has a problem executing.

    update TRANSFER set PROCESS_STATUS = concat ( PREDICATE , 
                (select dom_value from DOMAIN_VALUES dv where dv.val_id = st.sr_cashflow_status
CASE PREDICATE WHEN dv.dom_value = 'ZZZZ' THEN 'SPB'
                         WHEN dv.dom_value = 'XXXX' THEN 'SPB'
                         WHEN dv.dom_value = 'YYYY' THEN 'SPB'
              ELSE 'DPS'
                         END ))         from TRANSFER st
    where PROCESS_STATUS is null;

My main problem is that how do I maintain the appender (here, predicate) as dynamic value that can be checked on the value obtained by join?

Any answers/directions much appreciated.

  • 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-10T18:30:19+00:00Added an answer on June 10, 2026 at 6:30 pm

    I guess you are trying to achieve something like below (considering PREDICATE is a column in TRANSFER table)-

    MERGE INTO TRANSFER st 
       using (select CASE 
                WHEN dv.dom_value = 'ZZZZ' THEN 'SPB'
                WHEN dv.dom_value = 'XXXX' THEN 'SPB'
                WHEN dv.dom_value = 'YYYY' THEN 'SPB'
                ELSE 'DPS'
                END as key,
                val_id
               from DOMAIN_VALUES) dv
          on (dv.val_id = st.sr_cashflow_status and st.PROCESS_STATUS is NULL)         
        WHEN MATCHED THEN
             UPDATE SET PROCESS_STATUS = concat(PREDICATE,dv.key);
    

    OR

    MERGE INTO TRANSFER st 
           using (select CASE 
                    WHEN dv.dom_value = 'ZZZZ' THEN 'SPB'
                    WHEN dv.dom_value = 'XXXX' THEN 'SPB'
                    WHEN dv.dom_value = 'YYYY' THEN 'SPB'
                    ELSE 'DPS'
                    END as key,
                    val_id
                   from DOMAIN_VALUES) dv
              on (dv.val_id = st.sr_cashflow_status and st.PROCESS_STATUS is NULL)         
            WHEN MATCHED THEN
                 UPDATE SET PROCESS_STATUS = PREDICATE||dv.key;
    

    A quick note on your CASE statement syntax. The syntax looks incorrect since you do not compare the outcome of the CASE with anything since you are using this in a WHERE clause, also you are missing AND clause too.

    update TRANSFER set PROCESS_STATUS = concat ( PREDICATE , 
                    (select dom_value from DOMAIN_VALUES dv where dv.val_id =            st.sr_cashflow_status
                       CASE PREDICATE WHEN dv.dom_value = 'ZZZZ' THEN 'SPB' -- and clause missing
                             WHEN dv.dom_value = 'XXXX' THEN 'SPB'
                             WHEN dv.dom_value = 'YYYY' THEN 'SPB'
                       ELSE 'DPS'
                             END ))         --comparison missing like CASE ... END = 'SPB' since the case is inside WHERE
           from TRANSFER st                 -- you cannot have a FROM clause in UPDATE
        where PROCESS_STATUS is null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that I need to update where all columns are optionally
I have one table TABLE_EXAM . i need to update the value of specific
Hit a speed bump, trying to update some column values in my table from
So I have this SQL table that I need to update. Now we use
I need to update column values (say column2) with concatenation of two string variables
I need to update each row of a table with one column as sum
I want to add values to a new column I added to a table.
I need to get the last inserted id of table that have multi-column primary
I need to update a table, and the Where clause should contain the last
Using C# .net 4.0 and visual studio 2010. I need to update a table

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.