How to dynamically change the table name for a update statement

Hi All,
I need to update a coulumn xyz in either of tables abc and efg based on some condition.
I wrote a cursor which has union of two queries(one querying abc and other efg)
Now based on some inparameter only one will be executed at a time.
And based on some condition a coulumn xyz needs to be updated which is in either of the table.
As the update condition is same
Update abc/efg set xyz=data where condition
I am looking to initialize a variable like v_tname based on some condition and update like
update v_tname .........
(Exactly that may not be like so, But looking a technique like this)
Please help

If there is only two tables you'll need to update then you are better off using static SQL and implementing something like this instead:
DECLARE
        update_condition        BOOLEAN;
BEGIN
        -- initialize update_condition
        update_condition := <some_boolean_check>;
        IF update_condition
        THEN
                UPDATE abc
                SET    xyz = some_val
                WHERE  some_col = some_other_val;
        ELSE
                UPDATE fgh
                SET    xyz = some_val
                WHERE  some_col = some_other_val;   
        END IF;
END;
/Hope this helps!

Similar Messages

  • How to dynamically change the table name inside a view

    Hi All,
    create table t_auto_feeds
    id number,
    table_name vachar2(100));
    insert into t_auto_feeds values(1,'T_FEED_POSITIONS');
    insert into t_auto_feeds values(2,'T_KAP_MTM');
    assume there are 100 records on id=1 in T_FEED_POSITIONS and 100 records of id=2 in T_KAP_MTM (id 1 is present only in t_feed_positions & id 2 is present only in t_kap_mtm)
    i need to create a view such that it needs to give the count of records based on the id
    create or replace view aa_view as
    select count(*), id from t_feed_position group by id
    union
    select count(*), id from t_kap_mtm group by id;
    I am getting a proper result when i query the view like select * from aa_view where id=1 but will the other union query seems to be a overhead?. I am having 10 such tables configured for different id in t_auto_feeds.so do i need to put 10 unions or is there a better way to handle this stuff.
    I know i can use a PLSQL block and dynamically build view structure, the problem is the view itself is configured in a table , so i cant write a proc for this.. can this aa_view be modified such that it queries only the table(using the t_auto_feeds ) which matches the id rather than the entire list.
    Kindly help me in this regard and let me know in case u need any further information from my side.

    >
    so do i need to put 10 unions or is there a better way to handle this stuff.
    >
    Yes - you need 10 unions
    Yes - there is a better way so that only one of the 10 queries does anything.
    You can use SYS_CONTEXT to control the query selection.
    Here is an example of using SYS_CONTEXT. Try this code in the SCOTT schema.
    create or replace context VIEW_CTX using SET_VIEW_FLAG;
    create or replace procedure SET_VIEW_FLAG ( p_table_name in varchar2 default 'EMP')
      as
      begin
          dbms_session.set_context( 'VIEW_CTX', 'TABLE_NAME', upper(p_table_name));
      end;
    select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
    select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
    select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    exec set_view_flag( p_table_name => 'EMP' );
    exec set_view_flag( p_table_name => 'EMP1' );
    exec set_view_flag( p_table_name => 'EMP2');
    SELECT sys_context( 'VIEW_CTX', 'TABLE_NAME' ) FROM DUAL
    CREATE VIEW THREE_TABLE_EMP_VIEW AS
    select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    union all
    select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    union all
    select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    SELECT * FROM THREE_TABLE_EMP_VIEWNote that you set the context for the table you want. This doesn't have to be a table name it could just be flag value
    -- use the emp table
    exec set_view_flag( p_table_name => 'EMP' );
    -- ue the emp1 table
    exec set_view_flag( p_table_name => 'EMP1' );
    -- use the emp2 table
    exec set_view_flag( p_table_name => 'EMP2');

  • How can I change the "Full Name" for my iCloud account?

    Hello,
    At some point in the past, iCloud started identifying me as someone else when I send emails. This incorrect name appears to be the "Full Name" setting of the email account, but when modifying the properties for the email account in Mail the field for modifying the "Full Name" setting is disabled, not allowing me to make any changes.
    Where is the correct place to change the "Full Name" setting for my iCloud account?
    Thanks,
    - Josh
    <Email Edited By Host>

    I believe it can be changed by going to https://appleid.apple.com/, click Manage your Apple ID, sign in with your iCloud ID, select "Name, ID and Email Addresses", then click "Edit" next to the name listed under "Your Name" and change it as desired.
    Also, if you are trying to change the sender name for your iCloud email account, you'll want to go to icloud.com, sign into your account, open Mail, click the gear shaped icon on the bottom left and choose Preferences, go to the Accounts tab and enter the name you want to use in the Full Name field and click Done.  Then quit Mail (Command-Q) on your Mac and re-open it.  Your new From name should now appear in the drop-down list when you compose a new email.
    (The image was removed in your post above because it showed your iCloud email address.)

  • How I may change the encoding names for downloaded files?

    I have some problem with encoding when I download files from russian sites. The downloaded files look like this "ìîé êàáèíåò - èíôîðìàöèÿ"

    Firefox, as is, will only download the file. You can choose where the file is
    saved, but that's it.
    Go to the '''''[https://addons.mozilla.org/en-US/firefox/ Mozilla Add-ons Web Page]''''' {web link}
    (There’s a lot of good stuff here) and search for '''download managers.'''
    Many of them give you a chance to change the file name.

  • How do I change the "friendly name" for a Windows Azure subscription?

    I have multiple Windows Azure subscriptions named "Subscription-1" because this was the default name given to my clients when they signed up for the service. How can I change this?

    Craig,
    Login to your Microsoft Online Services Customer Portal at
    https://mocp.microsoftonline.com.
    On the right side, in the list of "Actions", click on "Manage subscriptions".
    You will then see a list of your Subscriptions. On the right side in the Action column, select "Edit service details" and click the "Go" button for the Subscription you want to edit.
    You will then be prompted with a dialog that will allow you to modify your Subscription name.
    Eric
    Eric D. Boyd - Director, Chicago + Cloud at Centare 
    Blog |
    twitter

  • How do I change the broadcast name for my MiFi wireless network?

    I would like to change the SSID broadcast name for my 4620 MiFi network. I want to be able to recognize mine immediately in the sea of other wireless that is available. How do I change that name for my device?

    MiFi 4620L User Guide:
    http://cache.vzw.com/multimedia/mim/vzw_mifi_4620_jetpack/4620_manual.pdf
    Change the SSID on a MiFi 4620L:
    1. Navigate to http://vz.hotspot or the IP Address of the MiFi
    2. Sign in with the Wi-Fi/Admin password posted to the back of your device
    3. Click the Wi-Fi tab
    4. Click the Wi-Fi Settings sub tab
    5. Replace the default SSID with your own value
    6. Click Save and Restart

  • How to change the table's for an existing report

    Hello,
    How can I change the table names for reports created with a different table name? for e.g If I created a report which included a table called "2009_10_example", How can I change that table to a different table "2010_10_example1".
    I am using Crystal reports 2008, and the reports were created using Report Creating Wizard.
    Thanks,
    Abhishek

    In the Database Menu, there is an option Set Datasource Location.  This allows you to pick a table from the current tables used, and select a table to replace it with.  Press the Update button, and Crystal will swap one for the other.  If the field names and data types are all the same, it will automatically change all references throughout the report to the new table's fields.
    May I suggest that your tables are set up improperly if you have to change report code to run it for different months?  The data should all be in one table with dates, and parameters to select the date range to report on.  (That was said in the spirit of helping...)
    HTH,
    Carl

  • What is the table name for structure field MUEBS???

    Hi...Experts...
        How can I know the table for a screen-field if i get structure from it F1 Technical settings....
    Ex: Here MUEBS is the screen field (Char. Display) in one of the subscreens of VA41. And it is from
          RV45A structure...
    Now how can I know the table name for this field MUEBS.
    I know some methods but they r not help ful.. please try it and get back to me.
    Thanks,
    Naveen.I

    Naveen,
    Table field                    Short Description                                                                               
    VBMUE            Sales Document: Characteristic Overview           
    MUEBS                          Characteristic display                                                                               
    VBMUEZ           Sales Document: Characteristic Overview Assignments
    MUEBS                          Characteristic display                                                                               
    VBMUET           Sales Document: Characteristic Overview Description
    MUEBS                          Characteristic display
    You can find same by SE15>Abap dictonary>fields>table fields.
    Amit.

  • How to change the attribute name for a relation

    When the Data Modeler engineers a logical model into a relational model it create table columns for the relations. The names of the generated columns are listed in the attributes list in the properties dialog of the relation. The actual name of the attribute gets calculated by the attribute name of the entity which is part of the relation. This is okay, if there is only one relation between two entities. But when there are two relations between two entities the second attribute gets a stupid number suffix. This makes it impossible to give the attribute a useful semantic meaning.
    When I engineer the model into a relational model I can change the column name in the relational model. Changing the column name in the relational model is not perfect but it would be okay for me, if it would not be overwritten during the next engineering run.
    So I have two questions:
    How can I change the attribute name in the attributes section of the properties dialog of a relation? See here for screen shot:
    http://public.ceving.de/2012050300/relationattribute.png
    And if it is not possible:
    How can I preserve any changes on column names in the relational model during a re-engineering run?
    Edited by: 931739 on 03.05.2012 08:07

    Hi,
    I've logged an Enhancement request on this.
    I don't believe it's possible to change it from the Entity or Relationship dialog, as it's not updatable in these dialogs.
    What you can do is change it in the Relational Model, and then reverse engineer the change back to the Logical Model.
    David

  • How to change the package name for a msg class

    Can anybody tell me how to change the package name for a message class.
    and how will it effect in the rerport?
    thanks in advance
    kp

    >>and how will it effect in the report?
    You wouldn't see any direct effect on the Report.. But if you transport the report to QA & leave the Message class in Dev, it might result in syntax issues & you will not be able to execute the report. Just ensure that both of them get transported to QA & you will be fine.
    ~Suresh

  • When bates numbering a .pdf in XI, how can I change the file name to include the bates number AND its name?  I know under file output, there is an option for either/or.  I want both.  Thank you.

    when bates numbering a .pdf in XI, how can I change the file name to include the bates number and the file name?  I know under "file output: it's either/or.  I need both.  Thanks!

    Long ago I wrote a little demo using the touch command. Check out the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=25128#M25128
    LabVIEW Champion . Do more with less code and in less time .

  • Dynamically changing the flatfile name..

    Hi friends,
    I 'm Getting data from 30 Flat files...all are with same structure but different data.. .. all these files are now in Application server...
    now i want to upload data into with a single DataSource and to ODS with process chains..
    so, how can i dynamically change the file name in Data Source level.. i saw previous threads.. in that.. through Routines.. we can solve this problem.. but I dont know ABAP code... so, can any one plz give me the exact code.. what i have to write...exact coding..
    <b>
           I already post this question in forums.... but evry one gave different options.. some  one gave the function module..
    BAPI_IPACK_CHANGE    and BAPI_IPACK_START.
      and some one gave  other function module.. like .. EPS_GET_DIRECTORY_LISTING
    i tryd for All these options.. but i'm not getting the exact solution... even i'm unable to pass the parameters also.. beacuse.. in that function what parameters can i pass....</b>
    can u plz suggest me the solution..
    Thanks
    Babu

    Hi  Friends,
      for the above requirement i had write the bellow coding in the routine.. it is working.. but the problem is.. it was loading  only  the last file..(30 th file  data only..)
    data : z1(50) type c,
             z2 type c,
             z3(50) type c,
             z4(50) type c.
             Z2 = 1.
       Do 5 times.
              z1 = 'C:\Documents and Settings\e10035\Desktop\'.
              z3 = '.csv'.
              concatenate z1 z2 z3 into z4.
              p_filename = z4.
              z2 = z2 + 1.
        Enddo.
    SO, CAN YOU PLZ SUGGEST ME.. when ever the file name was changing in the loop.. that automatically should load into the  PSA ..
    plz... plz.... help regarding this..
    Bbau

  • How can I change the tag name in cursor statement?

    Hi
    I have two tables: TableA and TableB. I want generate a XML file using XSU12 from these two tables, the XML structure like:
    <ROWSETA>
    <ROWA num="1">
    <A1></A1>
    <A2></A2>
    <A3>
    <A3_ROW num="1">
    <B1></B1>
    <B2></B2>
    </A3_ROW>
    <A3_ROW num="2">
    <B1></B1>
    <B2></B2>
    </A3_ROW>
    </A3>
    </ROWA>
    </ROWSETA>
    How can I change the tag name and attribute for "A3_ROW"?
    Thanks in advance!
    null

    In short, you can't.
    You can use the column alias as you're already doing to change the name of the "A3" part of "A3_ROW" but you cannot change the "_ROW" part of "A3_ROW". This is added automatically.
    You can combine the results of XSU with an XSLT stylesheet (made very simple if you're using XSU by working with Oracle XSQL Pages) to change the name of any element or completely restructure the XML output into a target XML, HTML, or text format.

  • How can I change the account name in iCloud.  My email has changed and I want to change it on iCloud.

    How can I change the account name in iCloud.  My email has changed and I want to change it on iCloud.

    To change your iCloud ID, go to Settings>iCloud, tap Delete Account, then sign back in with the new ID.  This deletes the account and your iCloud data from your device, but not from iCloud.  Provided you are signing back into the same account, your iCloud data will reappear on your device when you sign back in.
    To avoid losing photo stream photos, save them to your camera roll (if not already there) before deleting the account.  To do this, open your my photo stream album, tap Edit, tap the photos, tap Share, then tap Save to Camera Roll.
    To change the ID on your Mac, go to System Preferences>iCloud, sign out, choose Delete for all the prompts (your data will still be in iCloud), then sign back in with the changed ID.

  • How can i change the screen name in my icould account?

    my Apple ID used to have my Dad's name because of the billing issues.. now is changed again to have my name, but i keep seeing that my account on icloud.com still says my dad's name, so if i try to send an email through there it says my dad's name and my email address instead of my name...
    how can i change the name that appears linked to my icloud account? (note that as i already sayd my Apple ID has my name now, i jsut want to know why is not my name in my icloud account?)
    thank you,

    I believe it can be changed by going to https://appleid.apple.com/, click Manage your Apple ID, sign in with your iCloud ID, select "Name, ID and Email Addresses", then click "Edit" next to the name listed under "Your Name" and change it as desired.
    Also, if you are trying to change the sender name for your iCloud email account, you'll want to go to icloud.com, sign into your account, open Mail, click the gear shaped icon on the bottom left and choose Preferences, go to the Accounts tab and enter the name you want to use in the Full Name field and click Done.  Then quit Mail (Command-Q) on your Mac and re-open it.  Your new From name should now appear in the drop-down list when you compose a new email.
    (The image was removed in your post above because it showed your iCloud email address.)

Maybe you are looking for

  • Share calendar from a specific date

    I am spending three months in the US visiting family. While I am here, I'd like to share certain calendars with my family members (doctor's appointments, social engagements, etc.), but don't want them to be able to see every such appointment I've had

  • Need Calendar Year as a Variable in the Caption of an Analysis Item WAD 7

    I am using Web Application Designer 7.X for the first time. I am modifying a template that has the following Analysis Item in it:            <bi:ANALYSIS_ITEM name="TABLE_4" designheight="300" designwidth="966" >                 <bi:WIDTH value="966"

  • Can't add participants to a chat

    The "+" option in the Participants window isn't available and therefore i can't add participants to a chat. If I right-click my mouse over the "+" button, i see the names of available buddies, but receive this error when I try to add them: "NSInterna

  • RECORDING WITH F-32 ......ITS URGENT SO PLZ HELP

    HI  WISH EVERYTHING IS GOING ON WELL FOR YOU PELOPE I GOT AN ASSIGNMENT IN FI AND I AM VERY MUCH NEW TO FI SO PLZ HELP TO SOLVE THIS PROBLEM REQUIREMENT IS SOMETHING LIKE THIS I HAVE TO TAKE THE START DATE AND THE END DATE AS INPUT. I HAVE TO DO THE

  • Imovie to Idvd : DVD on TV flickers and moving imges poor quality

    Hallo, I did my first IDVD project (yes I am coming from the PC world) which works fine so far. I did the movie in iMovie and selected iDVD as the output. iDVD created a DVD which looks fine. But showing the DVD in standard DVD player shows issues wi