How to configure the schema name dynamically based on user input.

configure the schema name dynamically based on user input.
For ex:
We have two schemas:
Schema1  - base schema having 15 tables.
Schema2 -  tables which is specific to modules. Having only 10 tables which is also available in Schema1
Login to application using Schema 1
Access a particlular module and select the country. Here country selection is identified.
Based on the country selection, we need to connect the schema respectively.
If the user selects France --> It should connect Schema1
If the user selects Germeny --> It should connect schema2.
Used: Eclipselink

You may want to have a different persistence unit for each country, then you just need to switch persistence units, and can put the schema in your orm.xml file.
You may also want to investigate EclipseLink multi-tenant support,
http://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/a_multitenant.htm
You can the schema in a persistence unit in code using a SessionCustomizer and the tableQualifier.

Similar Messages

  • How to parameterize the schema name in APEX

    Hi,
    How to parameterize the schema name in APEX , in order to access different tables from the respective schema.
    For example:-
    select NAME display_value, CODE return_value
    from paramSchema.DESC_LIST WHERE SELECTION_FLG = 'Y'
    order by 1
    in the above code, paramSchema will be replaced with the actual schema name duing runtime. I tried doing so by some hidden fields on page, but it didn't worked out.
    I took the schema name from the respective server as per the IPof the server.
    stored in a hidden field named as schema.
    And replaced the same in place of schema name. But no luck.
    select NAME display_value, CODE return_value
    from :schema.DESC_LIST WHERE SELECTION_FLG = 'Y'
    order by 1
    Please help me in shorting it out.
    Thanks,
    Anuradha

    Hi
    In order to do that, you would need to use dynamic SQL by changing the report type to PL/SQL Function Body Returning SQL Query and have code along the lines of
    DECLARE
    l_sql VARCHAR2(32767);
    BEGIN
    l_sql := 'select NAME display_value, CODE return_value
    from '||:schema||'.DESC_LIST WHERE SELECTION_FLG = 'Y'
    order by 1';
    RETURN l_sql;
    END;However, by doing this, you lose alot of flexibility. The other options would be...
    To have seperate report regions that are conditional on the value of the variable.
    To use a WITH clause at the tope of the query like...
    WITH src_data AS
    (SELECT * FROM schema1.my_table
    WHERE :schema = 'schema1'
    UNION ALL
    SELECT * FROM schema2.my_table
    WHERE :schema = 'schema2')
    SELECT *
    FROM src_dataOther than that you could look at using synonyms and doing something similar.
    Hope this helps.
    Cheers
    Ben

  • How to Get the schema name that contains the current procedure?

    I have try select sys_context( 'userenv', 'current_schema' ) from dual; but it returns the schema name of the login user. How to return the schema name of the procedure instead? For example, procedure A is in ControlDB, and I login as sys, when query procedure A it should return ControlDB instead of sys.
    I have searched in Google but no luck to find the answer so far, please help. Thank you

    It works!
    I am quite confused now. I did try to use select username from user_users in GetSchemaName procedure, but it always return the login user instead of the owner of the procedure. Why it return the procedure owner if I put the query inside a function then call it from the procedure?
    Is it because when the login user call the procedure and the procedure call the function, it's the procedure owner is calling the function so the user_users return the user that is calling it which is the procedure owner. And if the query is directly put inside the procedure, when the login user call the procedure, user_users return the login user directly? Does it imply that if the procedure call any function or other procedures etc, it would be the procedure's owner calling them instead of the login user?
    (sys_context works as well if I move the query into the function then call the function from the procedure)
    Cheers
    Message was edited by:
    user500168

  • How to add column dynamically based on user input in oracle?

    **how to add column dynamically based on user input in oracle?**
    I am generating monthly report based on from_date to to_date below is my requirement sample table
    EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE | 01-OCT-12 | 02-OCT-12 | 03-OCT-12
    100001.............John...........02-OCT-12...............6
    100002.............chris...........01-OCT-12...............4
    Based on user input, that is, if user need the report from 01-OCT-12 TO 03-OCT-12, i need to add that dates as column in my table, like 01-OCT-12 | 02-OCT-12 | 03-OCT-12....
    below is my code
    create or replace
    procedure MONTHLY_LVE_NEW_REPORT_demo
    L_BUSINESS_UNIT IN SSHRMS_LEAVE_REQUEST_TRN.BUSINESS_UNIT%TYPE,
    --L_LEAVE_TYPE_CODE           IN SSHRMS_LEAVE_REQUEST_TRN.LEAVE_TYPE_CODE%TYPE,
    L_DEPARTMENT_CODE IN VARCHAR2,
    --L_MONTH                    IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
    L_FROM_DATE IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
    L_TO_DATE in SSHRMS_LEAVE_REQUEST_TRN.LVE_TO_DATE%type,
    MONTHRPT_CURSOR OUT SYS_REFCURSOR
    AS
    O_MONTHRPT_CURSOR_RPT clob;
    v_return_msg clob;
    BEGIN
    IF (L_BUSINESS_UNIT IS NOT NULL
    AND L_FROM_DATE IS NOT NULL
    and L_TO_DATE is not null
    -- AND L_DEPARTMENT_CODE IS NOT NULL
    THEN
    OPEN MONTHRPT_CURSOR FOR
    select EMPLOYEE_CODE, EMPLOYEE_NAME AS NAME, DEPARTMENT_CODE AS DEPARTMENT,DEPARTMENT_DESC, CREATED_DATE,
    NVL(WM_CONCAT(CL_RANGE),'') as CL_TAKEN_DATE,
    case when NVL(SUM(CL2),0)<0 then 0 else (NVL(SUM(CL2),0)) end as CL_BALANCE,
    from
    SELECT DISTINCT a.employee_code,
    a.EMPLOYEE_FIRST_NAME || ' ' || a.EMPLOYEE_LAST_NAME as EMPLOYEE_NAME,
    a.DEPARTMENT_CODE,
    a.DEPARTMENT_DESC,
    B.LEAVE_TYPE_CODE,
    B.LVE_UNITS_APPLIED,
    B.CREATED_DATE as CREATED_DATE,
    DECODE(b.leave_type_code,'CL',SSHRMS_LVE_BUSINESSDAY(L_BUSINESS_UNIT,to_char(b.lve_from_date,'mm/dd/yyyy'), to_char(b.lve_to_date,'mm/dd/yyyy'))) CL_RANGE,
    DECODE(B.LEAVE_TYPE_CODE,'CL',B.LVE_UNITS_APPLIED)CL1,
    b.status
    from SSHRMS_EMPLOYEE_DATA a
    join
    SSHRMS_LEAVE_BALANCE C
    on a.EMPLOYEE_CODE = C.EMPLOYEE_CODE
    and C.STATUS = 'Y'
    left join
    SSHRMS_LEAVE_REQUEST_TRN B
    on
    B.EMPLOYEE_CODE=C.EMPLOYEE_CODE
    and c.EMPLOYEE_CODE = b.EMPLOYEE_CODE
    and B.LEAVE_TYPE_CODE = C.LEAVE_TYPE_CODE
    and B.STATUS in ('A','P','C')
    and (B.LVE_FROM_DATE >= TO_DATE(L_FROM_DATE, 'DD/MON/RRRR')
    and B.LVE_TO_DATE <= TO_DATE(L_TO_DATE, 'DD/MON/RRRR'))
    join
    SSHRMS_LEAVE_REQUEST_TRN D
    on a.EMPLOYEE_CODE = D.EMPLOYEE_CODE
    and D.LEAVE_TYPE_CODE in ('CL')
    AND D.LEAVE_TYPE_CODE IS NOT NULL
    group by EMPLOYEE_CODE, EMPLOYEE_NAME, DEPARTMENT_CODE, DEPARTMENT_DESC, CREATED_DATE
    else
    v_return_msg:='Field should not be empty';
    end if;
    END;
    my code actual output
    EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE
    100001....................John............02-OCT-12.................6
    100001....................chris...........01-OCT-12.................4
    how to add column dynamically based on from_date to to_date?
    Thanks and Regards,
    Chris Jerome.

    You cannot add columns dynamically. But you can define a maximum number of numbers and then hide unused columns in your form useing SET_ITEM_PROPERTY(..,VISIBLE, PROPERTY_FALSE);

  • How to pass the table name dynamically in xml parsing

    Hi All,
    I have created one procedure for parsing xml file which is working perfectly.
    FORALL i IN t_tab.first .. t_tab.last
             INSERT INTO Test_AP VALUES t_tab(i);Now I want to put the table name dynamically+. For that I have added one query and modify above code as follow:-
    I have already declare dml_str varchar2(800) in declaration part.
    Query is as follows:-
    select table_name into tab_name from VERSION_DETAILS where SUBVERSION_NO=abc;  -- here abc is variable name which contains values.
    FORALL i IN t_tab.first .. t_tab.last
              dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
              EXECUTE IMMEDIATE dml_str USING t_tab(i);But it's not working. How I will resolve this or through which way I achieved the intended results. Anyone can guide me on this matter.
    Thanks in advance for your help...

    Hi,
    But it's not working.Don't you think it would help to give the error message?
    Put the assignment before FORALL.
    FORALL only accepts one subsequent DML statement (static or dynamic SQL) :
    dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
    FORALL i IN t_tab.first .. t_tab.last          
    EXECUTE IMMEDIATE dml_str USING t_tab(i);

  • How to set the file path dynamically based on sytem, username, and date

    Hi All,
    My requirement is upload the data into one  structure like xyz that is related to t.code MCSZ.
    file will be in  UNIx SERVER .
    PATH IS: /sapif
    file name is xy789 load .txt
    I have  to write code in one user-exit
    how can i set the file path for this.
    shall i put hard code file path?
    because i have to writecode in user-exit.
    plz tell me how to set the file path based ons syetem, username, date
    Thanks in advance
    Ram.A

    Concatenate the field SY-SYSID, SY-UNAME and SY-DATUM for the file path

  • How to determine the schema name from stored function or procedure

    Hi all
    I need to find the way to determine the name of shema in which the given stored procedure residing. This SP is created with AUTHID CURRENT_USER what means that expression like SYS_CONTEXT('USERENV','CURRENT_USER') or SYS_CONTEXT('USERENV','CURRENT_SCHEMA') will be return the name of user or schema of user which calls given SP.
    can somebody help me?

    What is the problem you are trying to solve?
    Presumably, when you're creating a stored procedure, you know what schema owns it. So it's pretty trivial to simply create a local variable L_OWNER in your procedure, assign it the value of the schema owner, and then use that owner. Most people don't really need to figure out at runtime what they already knew at compile time.
    Barring that, you could inspect the data dictionary as user130038 suggested. That requires that you know the name of the procedure (which would likely also have to be a local variable that is initialized to a hard-coded value. And if there are multiple users that own procedures with the same name, it may not be reliable.
    Inspecting the call stack is the most reliable and dynamic approach. But it is also the most costly in terms or runtime performance and in terms of code complexity.
    Justin

  • How can find the schema name

    Hi,
    I just want to know,
    based on the sql statements in v$sql, want to know the schema from which the queries are being executed.
    and one more thing,
    one sql procedure/function got failed from the application , I want to know from which schema it got failed and the time when it got failed?
    RR

    You can define the EXCEPTION for any PL/SQL block to catch errors
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/exception_definition.htm#LNPLS01316
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to read data from a website based on user inputs through java programmi

    Hi
    I want to get information from a website based on some inputs that I have. The inputs change everytime and based on them, different output is expected. How do I go about with it? Please advice...
    Will data mining help in this? or is it used only for analysis and predictions?

    you can get the webpage you need very simply like this :
    Test.java
    public class Test{
              public static void main(String[] args) {
                   URLClient client = new URLClient();
                            // URL of a webpage
                   String webPage = client.getDocumentAt("http://content-ind.cricinfo.com/slvind/engine/current/match/343730.html?template=desktop;view=main;wrappertype=desktop");
                   System.out.println(webPage);
         }URLClient.java
         import java.net.*;
         import java.io.*;
         public class URLClient {
              protected URLConnection Connection;               
                   public String getDocumentAt(String urlString) {
                             StringBuffer document = new StringBuffer();
                             try {
                                            URL url = new URL(urlString);
                                            URLConnection conn = url.openConnection();
                                            BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                                            String line = null;
                                            while ((line = reader.readLine()) != null)
                                                 document.append(line + "\n");
                                            reader.close();
                                       } catch (MalformedURLException e) {
                                       System.out.println("Unable to connect to URL: " + urlString);
                                       } catch (IOException e) {
                                       System.out.println("IOException when connecting to URL: " + urlString);
                                  return document.toString();
              }

  • How to change the portal role presentation based on users BW authorization?

    Hello,
    I have created 3 BW Roles, each one contains an iView with a certain report.
    For simplicity let's name the Roles A,B,C and assume that in order to see the proper report the user needs to be assigned to the matching group (A,B,C) at the BW side.
    I have imported these 3 roles to the portal as worksets, created new pcd role, placed these 3 worksets inside the new role and assigned this role to a certain group of users in the portal (these users are ABAP users so they are the same at the BW side as well).
    What I would like to do is this: I would like that each user that I have assigned this new role to will see only the worksets that he/she allowed to see based on it's BW authorization. Meaning, if I have been assigned roles A and B at the BW I will see only worksets A and B inside the role.
    The problem is this: From the portal I cannot assign the users to the BW groups and from BW I cannot control pcd roles so this kind of change requires me to make two modifications: One for authorization from the BW and one for presentation from the portal. I would like to manage it just from one place, either from the BW or from the portal, I don't care.
    How can I achieve this?

    I think I have found a solution: Export it as a role instead of a workset and do one to one assignments with the BW groups.

  • How to get Logo in report dynamically Based on user login?

    requirement is like this:
    same report format will be used by 3 different users, but the different logo should appear based on their login..

    place all 3 images in the template, then wrap an if statement around each. something like:
    <?if:userLogin='User 1'?>image goes here<?end if?>
    if that doesn't work try sticking each in a table with no border and doing the same with the if statements

  • How to change the column header name dynamically based on sysdate

    Post Author: senthi_gokul
    CA Forum: WebIntelligence Reporting
    Dear All,
            i have designed some reports. i would like to change the column header dynamically based on sysdate. up to 24 months. can u help me, which add month function using the universe. i dont know if-then-else function is having the universe tool or not?

    Post Author: prasingh
    CA Forum: WebIntelligence Reporting
    Are you saying you are not able to create an object by value (select: statement) as sysdate and put it onto the headers of your report? You can use the add_months() function on the object to add the numbers of months you wish.
    Please let me knnow for more.. You can get in touch with me on [email protected] for quick reply. 

  • How to use the column names generated from Dynamic SQL

    Hi,
    I have a problem with Dynamic SQL.
    I have written an SQL which will dynamically generate the Select statement with from and where clause in it.
    But that select statement when executed will get me hundreds of rows and i want to insert each row separately into one more table.
    For that i have used a ref cursor to open and insert the table.
    In the select list the column names will also be as follows: COLUMN1, COLUMN2, COLUMN3,....COLUMNn
    Please find below the sample code:
    TYPE ref_csr IS REF CURSOR;
    insert_csr ref_csr;
    v_select VARCHAR2 (4000) := NULL;
    v_table VARCHAR2 (4000) := NULL;
    v_where VARCHAR2 (4000) := NULL;
    v_ins_tab VARCHAR2 (4000) := NULL;
    v_insert VARCHAR2 (4000) := NULL;
    v_ins_query VARCHAR2 (4000) := NULL;
    OPEN insert_csr FOR CASE
    WHEN v_where IS NOT NULL
    THEN 'SELECT '
    || v_select
    || ' FROM '
    || v_table
    || v_where
    || ';'
    ELSE 'SELECT ' || v_select || ' FROM ' || v_table || ';'
    END;
    LOOP
    v_ins_query :=
    'INSERT INTO '
    || v_ins_tab
    || '('
    || v_insert
    || ') VALUES ('
    || How to fetch the column names here
    || ');';
    EXECUTE IMMEDIATE v_ins_query;
    END LOOP;
    Please help me out with the above problem.
    Edited by: kumar0828 on Feb 7, 2013 10:40 PM
    Edited by: kumar0828 on Feb 7, 2013 10:42 PM

    >
    I Built the statement as required but i need the column list because the first column value of each row should be inserted into one more table.
    So i was asking how to fetch the column list in a ref cursor so that value can be inserted in one more table.
    >
    Then add a RETURNING INTO clause to the query to have Oracle return the first column values into a collection.
    See the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/returninginto_clause.htm#sthref2307

  • How to get the class name and field name dynamically

    Hi
    I have a class (ex: Contract) the fields (ex : a,b,c) .i need to get the class name and field name dynamically
    ex
    if( validation file for the field Contract.a){
    return contract.a;
    }else if(validation file for the field Contract.b){
    return contract.b;
    how to pass the field name and object dynamically
    Please help me .............
    Thanks in Advance..
    Edited by: 849614 on Aug 11, 2011 6:49 AM

    YoungWinston wrote:
    maheshguruswamy wrote:
    Agreed, but IMO, i still feel its best if there is no tie in between consumer class level details and the database it talks to. A service layer is needed in between them.Sounds like you've done a bit of this before. Me, I've either been a modeller/DBA, doling out data, or a nuts and bolts programmer (and actually more toolmaker than apps, but did a bit of that too).
    Do you know of a good book about the "middle ground" (ie, these service layers)? I understand it empirically, but haven't had a lot of exposure to it.
    Winston
    Edited by: YoungWinston on Aug 11, 2011 10:34 PM
    PS: Apologies. Edited my previous post, presumably while you were composing your reply, when I finally realized what '.filed' meant.Most of my work is in web development, never been a DBA :) . The biggest 'concern' in my shop is 'separation of concerns'. The UI group reports up to a different IT head, the DB group reports up to a different IT head and so on. The looser the coupling between these systems, the lesser the project costs (Integration, QA etc) are. Martin Fowler's books contain good information about separation of concerns in an enterprise environment. The two books which i recommend are
    [url http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420]Enterprise Application Architecture and
    [url http://www.amazon.com/Enterprise-Integration-Patterns-Designing-Deploying/dp/0321200683/ref=pd_sim_b_1]Enterprise Integration Patterns

  • How to configure the iTunes,to display only folder name as Album.

    How to configure the iTunes,to display only folder name as Album under Music.
    I have a folder with name "English" under this I have plenty of folders which are either movie names or custom names created by me,inside of these are the music files. I just want all the files to be copied to the iPod with out any album artwork(which the itunes display under "Album By Artist" contains).The "Album By Artist" doesnt seem to contain just the folder name,it gets something else like the website from where the music file downloaded. This makes me irritating to browse through iPod or iTunes.
    Please help me in configuring,so that I can just see the same folder/music hierarchy I see in my windows machine in the iPod.

    Yep, I agree with Jurjen. It is not only limited to ACTVT, but rather fields of other objects as well which are "action" or "activity" related.
    I would start the other way around - give them '03' only and investigate any transaction specific claims that it is not enough. There will be a few...
    Cheers,
    Julius

Maybe you are looking for