Dynamically change schema/user name in sql query

I have tables with same name in different schema.
and Suppose I have query like:
select * from myHR.emp;
Now I want to pass variable in place of myHR, may be as follows:
Declare
vSH varchar2(10);
Begin
vSH := 'myHR';
select * from vSH.emp;
End;
But I got error with this query.
I want to pass variable as scheme_name/user.
So, please help me with this.
Thanks in advance.

Like said before, it is no different than running any other SQL statement from the client.
All you have to do is run a ALTER SESSION statement immediately after opening the connection:
SQL> alter session set current_schema = your_company_specific_schema_name ;or you can create synonyms under the Oracle user that you use to connect to the database and these synonyms will point to the correct schema.table that needs to be accessed. Then your queries will simply use the synonym as if it were the actual table without caring where the actual table is located.
Justin is faster even considering its a friday.
Message was edited by:
Kamal Kishore

Similar Messages

  • How do you handle change in user names if folks get married or divorced

    If an application is using the apex authentication scheme, how do you handle change in user names if folks get married or divorced. The reason I ask the question is that all of apex uses v('app_user'), which is the user_name. If I have transactions done by this user and then their name changes, which means so does their id, how do I get all of their transactions, before and after the name change. Traditionally I would expect to use user_id, not sure if this feature is still available. I can always create a custom auth scheme, but that is a lot of additional work. Any ideas?
    Thanks,

    Appreciate your help and time Jari, below is my game plan, unless someone has a better idea,
    I plan on doing the following to use user_id for auditing of transaction records:
    1. Get the user_id to use in the tables audit trail fields
    user_id := apex_util.get_user_id(v('app_user'));
    OR
    user_id := apex_util.get_current_user_id;
    2. If a user changes their name then use
    apex_util.set_last_name(p_user_id, p_new_lastname);
    apex_util.set_username(p_userid, p_new_username);
    Thanks,

  • We have an itunes account on our desktop and my kids have it on their ipod and iphone. I went in and changed our user name from my old e-mail address which is no longer accessible to my new one and now either of my kids can access the itunes store..

    We have an itunes account on our desktop and both my kids have it on iphone and ipod. I went in and changed out user name from an old e-mail address which is no longer accessible to my one I use now... When the kids try to sign onto the itunes store it tells them they have the wrong user name..
    Can this be fixed??

    Did you change the email address or create a new Apple ID?
    If the email address associated with the account was merely changed, sign out of the Apple ID on the devices and sign in using the new credentials.

  • How do I change my user name in syn? I typed in the wrong email address. And I cancelled syn thinking this may work but no luck.

    How do I change my user name in syn? I typed in the wrong email address. And I cancelled syn thinking this may work but no luck.

    You have to clear saved password for this page:
    # Open you login page (where you have to enter username and password).
    # Right click on page and select '''Page Info''' form context menu.
    # On last tab ('''Security''') there is '''View saved passwords''' button, click it and delete all saved passwords for this page.
    # Also clear all related cookies (just in case) there is button for this next to first one.

  • Is it possible to change schema or name of locally built provider in portal

    Is it possible to change schema or name of locally built provider in portal 9.0.4?
    We have built an application as a pagegroup and locally built provider in Oracle portal. We can deploy the application to different portals using transport sets. However, it is not possible to install the same provider twice to a shared portal because a provider's name and schema cannot be changed. Does anyone know of a way to rename and change the schema of locally built providers? I was once told that substition strings at import would be available in an upcoming release to do that, but I haven't seen anything like that.
    Thanks,
    Trenton

    Maybe use a MHT archive.
    *Mozilla Archive Format: https://addons.mozilla.org/firefox/addon/mozilla-archive-format/
    *UnMHT: https://addons.mozilla.org/firefox/addon/unmht/

  • 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

  • I changed the user name and screensaver does not let me enter

    I changed the user name this morning, later the screensaver popped up. The screen shows the old user name and does not accept the password, so i cannot even open the main page.

    Change it back, then:
    How to change user short name or home directory name
    http://support.apple.com/kb/HT1428?viewlocale=en_US
    Also, this might be useful:
    http://www.macworld.com/article/132693/2008/03/changeshortusername.html

  • Change of user name

    Hi all,
    I just bought a Macbook pro. I was wondering if anyone knew how to change the user name of the computer. The one associated to the little house icon.
    I have been trying unsuccessfully to do it!
    A part that I'm really enjoying my new computer!
    thanks a lot!
    t

    If it is new and you haven't added anything to it, just create a new account with the name you want. Make it able to administer the computer and then log in to it. Delete the other one, or keep it for testing and troubleshooting.

  • How to change your user name for the Ipod nano...

    Can anyone please explain how to change the user name on your Ipod nano?

    hiya!
    do you mean the nano's name in the ipod source list?
    if so, select the ipod in the itunes sourcelist. click on it once, and pause for a second or so. you should then be able to type in what you please.
    love, b

  • How to change my user name?

    I want to change the user name in "Users and Groups"
    I changed it so that in the upper right hand corner of the desktop it reflects the new name, but when I open the Users folder, it still has the old name.  I want to change the name of the main users folder.  However, I would rather not change my Apple ID (which is my old user name).

    More Like This ---------------->
    https://discussions.apple.com/message/12135072#12135072

  • How to change my user name in itunes connect?

    hey there! i am iOS app developer and i am looking to change my user name in itunes connect but after even changing it, it still showing me the previous name in app store. Can anyone help me in that? cheers!

    YYou go to settings and scroll down to iTunes and change the e-mail there.

  • Change my User Name?

    I am a brand new Mac user and am trying to learn everything on my own. Among many other questions, how can I change the name of my computer? When I bought the computer, the Geek Squad "optimized" it but they imputed my husbands name on everything instead of mine (since it was his credit account) but I am the primary user. Call me selfish, but I want my name on everything.
    I have changed my User Name under Preferences>Accounts, and I have managed to change info in Address Book. However, in Finder, the name of my "home" is still set to my hubby's name and when I pull up "Get Info" I cannot change it. If you can help, I would appreciate it. It is moderately annoying to me.

    Since you're a newcomer to the Mac, see these for answers:
    Switching from Windows to Mac OS X,
    Basic Tutorials on using a Mac,
    MacFixIt Tutorials,
    MacTips, and
    Switching to the Mac: The Missing Manual, Leopard Edition.
    Additionally, *Texas Mac Man* recommends:
    Quick Assist.
    Welcome to the Switch To A Mac Guides, and
    A guide for switching to a Mac.

  • Change iPhone user name

    I recently upgraded my iPhone & gave the older phone to my husband to us as an iPod.  However, whenever I connect to iTunes it still sees it as my phone.  How can I change the user name on the iPhone/iPod so that it will have separate recognition?
    thanks

    Double click the name under devices and type whatever you like.

  • I also would like to change my User Name

    I'm hoping a host will contact me so that I can change my user name from my full name to simply my first name or a nickname.
    Thanks

    Hello Tom,
    If you mean your Community name here, i'm afraid you cannot.   Or at least it would be a very rare event.   I have heard of one change recently because the name concerned was an embarrassment, but as I said, it's very, very rare.   I will draw the host's attention to your post.

  • I can't access my itunes account because my aol account is not active, how do i change my user name using gmail?

    I can't access my itunes account because my aol account is not active, how do i change my user name using gmail?
    I need to change my itunes user name to [email protected] instead of [email protected] AOL account is not active anymore.
    Thanks

    Chill out guys. Clare, I suggest that you try this link below. It might be possible taht the email you are using is not what your Apple ID should be:
    How to Recover Your Apple ID
    http://support.apple.com/kb/HE34
    Recovering a forgotten iTunes Store account name
    http://support.apple.com/kb/HT1920

Maybe you are looking for