Identify the name of the schema in a procedure/package

My google-fu is totally miss you on this one and I have a method for doing this already, but there is an insidious sense that there is a better way to do it there.

Basically I have two schemas that have the same procedures, packages, etc. in them (separate for reasons of risk; leaves do not enter the problem of duplication of code to maintain...!) and in a few, there are references to the schema to which belongs the package/proc/function (for example for analysis of tables). In order to avoid the schema name and the nightmare of maintaining different publication for different schemas, hard coding scripts I want to code in order to determine which schema it runs under.

I can't use 'USER' as which shows the user connected, and I want the name of the owner of the code being run.

I came with:
select username from user_users;
but as I said, I can't help but feel that there is a better way.

Is there, and if there is, what is it please?

This?

sys_context (' USERENV', 'CURRENT_SCHEMA' ")

Tags: Database

Similar Questions

  • Identify the schema using sys_context (' USERENV', 'CURRENT_SCHEMA' ")

    DB version: 10.2.0.4

    I am trying to create a trigger that will follow all DDL in a particular schema.
    But the relaxation below does not seem to work. Don't know if
    ('USERENV', 'CURRENT_SCHEMA') 
    is the right way to identify the schema where the DDL has occurred.
    create or replace trigger sys.mytest_trg after ddl on database
    declare
    v_sch_name varchar2(350);
    begin
    
    SELECT sys_context('USERENV', 'CURRENT_SCHEMA') into v_sch_name FROM dual;
    
    if v_sch_name = 'PRODSCHEMA'
    then
    --insert into SCOTT.test21 values (v_sch_name);
    --commit;
    dbms_output.put_line ('You just performed a DDL in PRODSCHEMA');
    end if;
    
    end mytest_trg;
    /

    Why not simply refers to ora_dict_obj_owner?

    Refer to the documentation:
    http://download.Oracle.com/docs/CD/B10501_01/AppDev.920/a96590/adg14evt.htm

  • How can I identify the name of the invisible file for a backup file successfully to an external hard drive USB2 separate? I use Windows Vista backup program (Service Pack 2),

    How can I identify the name of the invisible file for a backup file successfully to an external hard drive USB2 separate?  I use Windows Vista backup program (Service Pack 2), and I need to do backups plus two from other computers on the same external hard drive.  To do this, I think I would need to identify each backup file separate I know which file to specify if I need to do a restore.

    How can I accomplish this? The program does not seem to give me the ability to specify a file to which to write the backup during a given session files.  In addition, I do not understand why I can not see the file name in Windows Explorer - my files options are defined to be able to view hidden and system.  Would be grateful for any help you can provide, tonight if possible.   Best regards, Oliver for Norm

    Hello

    See this link:

    http://Windows.Microsoft.com/en-us/Windows-Vista/back-up-and-restore-frequently-asked-questions

    http://Windows.Microsoft.com/en-us/Windows-Vista/set-up-or-change-automatic-backup-settings

    http://Windows.Microsoft.com/en-us/Windows-Vista/back-up-your-programs-system-settings-and-files

  • 4.1 ai2 Migration for SQL Server: cannot change the schema name?

    I'm trying to convert a SQL Server database to Oracle.

    As I wanted to insert into an existing (with not the same name on SQL Server) schema, I followed this guideline:

    A SQL Developer... @dermotoneill: migrate existing users of Oracle

    I first picked up the source and then tried to convert the designation.

    but there is no tab:

    Migrate_missing_naming.jpg

    (you can see it's really show the previously entered data as I can choose the check box 'Show only data types used in the source model')

    Is there a new path now how to map the schema?

    Thank you

    Martin

    Hi Martin,

    This page of naming of the object has been removed from the migration wizard.

    The feature is now available in the migration of object report.

    It's easier to work with the report that you can filter and order objects according to your needs.

    In this case, you can simply show the OBJECT_TYPE = 'SCHEMA '.

    The steps are so.

    (1) capture and convert you data source

    (2) open the report of the object (left click on the node "Convert database objects") and change the SCHEMA TARGET_OBJECT_NAME objects in your name of the desired target. Commit the changes.

    Translate 3) and generate the Oracle database (right-click on the node "Convert database objects")

    Kind regards

    Dermot.

    SQL development team.

  • name of the schema

    Hi all

    hope all are doing well. I need your help, I have a doubt, and it is-how can I the schema name using v$ active_session_history? I have to join v$ active_session_history with v$ session to get schema name?

    DB: 11.2.0.3

    EBS:12.1.3

    OS: RHEL 6

    Thank you and best regards.

    Just look at the documentation here:

    http://docs.Oracle.com/CD/B19306_01/server.102/b14237/dynviews_1007.htm

    The description of the user_id column gives you the answer.

    If the session no longer exists, you can also join the view dba_users (user_id)

  • DatabaseProcedure with the return type preceded of the schema name

    Salvation (Paco)

    I have a question on the DatabaseProcedure class. We use proxy Oracle users to our database connections.
    Everything is accessible via a role of database that are granted to the user. All of our database objects, tables, etc. are protected by this database role.
    When I want to call a function/procedure of database, I need to add the name of the schema as a prefix to the custom database object that uses us for parameters and return types.

    So far so good. I can also define a parameter prefixed by the name of schema via the DatabaseProcedure.registerArrayType...
    But when I try to set a function call that uses this parameter I get an error saying "the statement is not valid.
    The problem is the regular pattern of PROCEDURE_DEFINITION:
    private static final Pattern PROCEDURE_DEFINITION = Pattern.compile("\\s* (FUNCTION|PROCEDURE) \\s+ ([\\w.$]+) \\s* (?:\\((.*?)\\))? \\s* (?:RETURN\\s+(\\w+))? \\s* ;? \\s*", CASE_INSENSITIVE | COMMENTS | DOTALL);
    The return type cannot be prefixed by the name of schema.

    Any good suggestions or workarounds?

    I have actually change the duration of reflection model to make it work-, but I really don't like this solution over the long term.

    / Torben

    Published by: Zonic 2013-05-07 10:52

    Hi Torben,

    I think that I have a work around for the problem which might work for you. If you look at the source of DatabaseProcedure.registerArrayType you will find that it is actually called DatabaseProcedure.registerCustomParamType.

    public static void registerArrayType(String name)
    {
      registerCustomParamType(name, Types.ARRAY, Array.getORADataFactory(), name);
    }
    

    A solution you can replace calls to DatabaseProcedure.registerArrayType with calls to DatabaseProcedure.registerCustomParamType as follows.

    // Instead of DatabaseProcedure.registerArrayType("NAME.WITH.DOTS") call:
    DatabaseProcedure.registerCustomParamType("anyNameWithoutDots", Types.ARRAY, Array.getORADataFactory(), "NAME.WITH.DOTS"); // Don't forget to use uppercase here.
    
    DatabaseProcedure dp = DatabaseProcedure.define("procedure my.procedure(param1 in out anyNameWithoutDots)");
    
    DatabaseProcedure.ParamType type = dp.getParamDef(0).getType();
    System.out.println(type.getName() + " is " + type.getTypeName()); // ANYNAMEWITHOUTDOTS is NAME.WITH.DOTS
    

    In this way, that you don't have to use the 'illegal' name in the definition of DatabaseProcedure.

    Kind regards
    Paco van der Linden

  • Which is the best way for a function called identify the class name of the appellant.

    Which is the best way for a function called identify the class name of the appellant.

    (1) sun.reflect.Reflection using the function call
                    Class caller = Reflection.getCallerClass(2);
                    System.out.println("Caller Class Name ::"+caller.getName());
    Trace of function called battery 2) analysis of current threads
                    StackTraceElement[] stElements=Thread.currentThread().getStackTrace();
                    System.out.println("Caller Class Name ::"+stElements[3].getClassName());
    Y at - it all the other ways to achieve the same. What is the best way?
    Called function does accept no argument, I don't want the arguments of function calling function called t.

    Help, please.

    With greetings
    Paul

    798185 wrote:
    Which is the best way for a function called identify the class name of the appellant.

    Y at - it all the other ways to achieve the same.

    SecurityManager

        // 0 is the anonymous SecurityManager class
        // 1 is this class (also works in static context)
        // 2 is calling class
        static Class getClass(int i) {
            return new SecurityManager() {
                protected Class[] getClassContext() {
                    return super.getClassContext();
                }
            }.getClassContext();} 
    
  • Name of the schema in the DB adapter

    Hello

    Schema name is hardcoded in the adpater DB, even if I do not select the schema name everything in creation.

    < jca:operation
    SchemaName = "APPS".
    PackageName = 'XX_PKG. '
    Procedurename = "POPULATE_DATA."
    InteractionSpec = "oracle.tip.adapter.db.DBStoredProcedureInteractionSpec" > "

    ...


    How can I make generic? Can I remove the SchemaName settings?

    My JNDI Url may change dynamically and the target database may have different schemas.


    Thank you
    Rishi

    SchemaName is an optional parameter.
    You can delete it.

    Prasanna-

  • What is the schema for the service module planning part name

    Hi Experts,

    I need the info

    1. What is the name of the schema for the PSP module
    For example, suppose that we call CPSA as MSC, in similar passion, which is the name given to the SPP.

    2. I searched the details in the table in etrm site (in R12.1.1) but it does not exist, can anyone help me to get the details of the table in the PSP?

    Thank you for your valuable time.

    Good bye
    Badin

    SPP uses the same tables as MSC with additional columns as appropriate. There is therefore no separate scheme for the SPP name.

  • How to identify the Source of Table in a schema star

    Hello
    We have a star schema with an intermediate table (with fact, as data on sales data) and two tables of dimension (such as by location and product data). In the model, we have specified an intermediate table to have a FK relationship with these two dimension tables.

    Two questions:
    -How can I select staging table and the foreign key columns in a KM. There are a few options available to the general public as: FK_PK_TABLE_NAME which helps me get my dimension of array, CT_NAME, ERR_NAME, but I can not find a method to identify the intermediate table that is one of the source tables in my interface.

    -Is it possible to use the function getsrctableslist() somehow? For example we can use like I_TABLE or TABLE_ORD fields to identify the source table by using this function.

    -On the 'Control' of my interface tab, I see the constraints that have been on the target table, is it possible to check the constraints on the source table. For example I can check if the source table contains all the entries valid product by referring to the product as the forign key relationship dimension table.

    Pointers, advice, solutions are appreciated.

    Thank you

    It's Ok now...

    follow these steps...

    (1) at IKM (not ckm) create a new step.

    technology: the same to the table in step
    Logical schema: that of the table in step

    Code:

    <%=odiRef.getSrcTablesList( "","/*\n Will be used the table (and its alias): \n*/","","")%>

    (2) move this step just before the stage of "Flow Control".

    (3) to sewing, the same stage where is the code that you sent change me all code at 'FROM' to

    It will work.

  • The name of the schema of synonyms

    Hello

    How can we get the name of the schema of synonyms?

    for example
    I am user of DATA and access to the HR user using the synonym objects.

    I am directly by selecting data using these synonym.

    But I want to know the list of the other patterns where I come to access the data using synonyms.

    Kind regards
    RSD

    How about the ALL_SYNONYMS view?

  • Select the schema name. How?

    Hi all

    Can be a very simple question, how can I select the scheme name that I am connected. I don't wear DBA privileges.


    -Sam
    SELECT USER FROM DUAL
    
  • Cloning of the prod to test data (with names different ownerIDs/schema)

    Hello
    ID of owner or the schema of production data is different than in the Test environment; So what happens is that after cloning the database, all the tables are still owned by prod user and not the test user. So if we just update the ownerID in psdbowner, logging would not be possible because it begins to search tables in a different pattern. If we leave the entry in psdbowner as it is, then the connection is possible but is not what we want. We want owner id to be different in the TEST.

    If we want to have all tables with an ID of owner different test than production; What measures should be taken?

    Thank you
    Vikas

    You must export from the user of the production and import in the test user.
    IMPDP in db 10g and more, within REMAP_SCHEMA option. However, there is no real reason to have another username across different environment, it's much easier to have the same username across all the env, especially if you want to copy the data files...

    Nicolas.

    Published by: Gasparotto N on May 31, 2010 16:46

  • Satellite A100-234: how to identify the good recovery CD

    I have 20 laptops from TOSHIBA in my office. I have the CD of restoration for all laptops kept together. Now I want to reinstall my laptop A100-234.

    How do I identify the recovery for this laptop CD.

    I tried to use 3 different recovery CD. With all the CD Installation is done properly and reboot is requested. But the system does not start.

    Any suggestions?

    Generally all recovery CD are labeled and you should see the name of the laptop on the recovery CD.
    In order to compare the information on the CD with the numbers that lie at the bootom of the laptop.

  • How to identify the hardware CAN connected to the PC

    Hello

    Is it possible to identify the devices CAN to your PC via the USB port, I am able to see the name of material CAN logged in the Device Manager list. Even I want to read using LabVIEW.

    Regars

    Visuman

    Use of the vi in the zip file.

    And the "Devcon.exe" will show you the list of devices.

    With this list, you can sort the channel search on the EIB devices.

Maybe you are looking for