Running sql against another schema in same db

Inside forms i need to check all other schemas to see if a record exists in any of the other schemas
so im doing a loop based on a cursor of select username from all_users and would need to then inside do something along the lines of
select column from schema.table where column = x
I normally would use execute immediate via a new procure to do this but it seems overkill and wondered if there was no built in via forms ?

I would do it using your "overkill" method: create a function, pass in column and tablename as parameters (if required) and call the function from the form.
My forms development philosophy is to put as much logic into the db as stored procedures rather than in the individual forms.

Similar Messages

  • Exp XML Schema (.xsd) to another schema on same instance

    Hello,
    I hope someone on this forum can help me or point me in the correct direction. I want to export a schema which contains a table (EQUIPMENT) which has a XMLType column defined against a registered .xsd. I would then like to restored this schema to another schema on the same instance (development instance) and also onto another db instance.
    I have been trying to do this with the help of "Chapter 30 Importing and Exporting XMLType Tables" from the Oracle® XML DB Developer's Guide
    10g Release 2 (10.2). Unfortunately without success. At the end of this message I have encluded sample error messages that I am receiving for creation of TYPES which is causing my import to fail.
    I cannot find any examples on the web on how to achieve an exp from one schema and imp in another either on the same instance or another one.
    DDL for my table is :
    create table EQUIPMENT
    ID number(7) not null,
    STATUSID number(7) not null,
    ATTRIBUTEDATA xmltype
    xmltype column ATTRIBUTEDATA xmlschema "EQUIPMENT.xsd" element EQUIPMENT_XML
    tablespace TBS_DATA1;
    Three test runs as follows:
    1. Using an empty u2 schema and I register the .xsd file. Then I try to import (FROMUSER - TOUSER imp mode) my dump file which leads to the following error:
    IMP-00017: following statement failed with ORACLE error 2304:
    "CREATE TYPE "MTA1440_T" TIMESTAMP '2007-11-14:14:42:16' OID '3EE57B10307317"
    "74E044080020C94102' AS OBJECT ("SYS_XDBPD$" "XDB"."XDB$RAW_LIST_T",""
    "ATTRIBUTE_01" NUMBER(38),"ATTRIBUTE_02" VARCHAR2(4000 CHAR),"ATTRIBUTE_03" "
    "VARCHAR2(4000 CHAR),"ATTRIBUTE_04" NUMBER(38),"ATTRIBUTE_05" VARCHAR2(4000 "
    "CHAR))FINAL INSTANTIABLE "
    IMP-00003: ORACLE error 2304 encountered
    NOTE: Even though import failed, I now see a new TYPE created called "MTA1526_T".
    2. If I try to create the TYPE as is from the error above I get the following error:
    SQL> CREATE TYPE MTA1440_T
    2 OID '3EE57B1030731774E044080020C94102'
    3 AS OBJECT (SYS_XDBPD$ XDB.XDB$RAW_LIST_T,
    4 ATTRIBUTE_01 NUMBER(38),
    5 ATTRIBUTE_02 VARCHAR2(4000 CHAR),
    6 ATTRIBUTE_03 VARCHAR2(4000 CHAR),
    7 ATTRIBUTE_04 NUMBER(38),
    8 ATTRIBUTE_05 VARCHAR2(4000 CHAR)) FINAL INSTANTIABLE;
    9 /
    CREATE TYPE MTA1440_T
    ERROR at line 1:
    ORA-02304: invalid object identifier literal
    3. So now I create the "MTA1440_T" type without the OID value and retry the import.
    IMP-00061: Warning: Object type "U2"."MTA1440_T" already exists with a different identifier
    "CREATE TYPE "MTA1440_T" TIMESTAMP '2007-11-14:14:42:16' OID '3EE57B10307317"
    "74E044080020C94102' AS OBJECT ("SYS_XDBPD$" "XDB"."XDB$RAW_LIST_T",""
    "ATTRIBUTE_01" NUMBER(38),"ATTRIBUTE_02" VARCHAR2(4000 CHAR),"ATTRIBUTE_03" "
    "VARCHAR2(4000 CHAR),"ATTRIBUTE_04" NUMBER(38),"ATTRIBUTE_05" VARCHAR2(4000 "
    "CHAR))FINAL INSTANTIABLE "
    Questions from me:
    A. Can I export TYPES only as suggested by the online documentation ?
    B. If importing onto same instance in another schema surely the OID for the TYPE will always fail - so then why can the import not create the required TYPE name itself during the import ?
    C. Should I use global TYPES and Register the .XSD globally for all schema's in an instance to validate against .. would this prevent me from having errors on an import ?
    I would appreciate any insight any one could provide me. Many thanks in advance.
    Dom

    Hi Guys,
    Thank you all for the replies. I am dissappointed to hear that in 10g does not support exp/imp of schema's structured XML. However I am a little confused or should I say mislead by the "" documentation I
    Here is an extract from chapter "30 - Importing and Exporting XMLType Tables" from the Oracle XML DB 10g Developers Guide documentation:
    "..... Oracle Database supports the import and export of XML schema-based XMLType tables. An XMLType table depends on the XML schema used to define it. Similarly the XML schema has dependencies on the SQL object types created or specified for it. Thus, exporting a user with XML schema-based XMLType tables, consists of the following steps:
    1. Exporting SQL Types During XML Schema Registration. As a part of the XML
    schema registration process .....
    2. Exporting XML Schemas. After all the types are exported, XML schemas are
    exported as XML text .....
    3. Exporting XML Tables. The next step is to export the tables. Export of each table consists of two steps:
    A. The table definition is exported as a part of the CREATE TABLE statement....
    B. The data in the table is exported as XML text. Note that data for out-of-line
    tables is.....
    From this documentation I was under the impression that the exp/imp of XML Schema-Based XMLType Tables was supported.
    Regarding the backup mechanism/strategy for database schema's containing tables with Schema-Based XMLTypes what would you recommend the best online backup method to use - tablespace backups ?
    What I need to be able to do in day-to-day work is to have the ability to be able to take a copy of a customers UAT or production database schema and apply it to a dev or test db instance here for bug testing etc. Do you have any advice on best to achieve this without the use of an exp/imp when the schema will contain Schema-Based XMLType tables.
    Thank you all for your assistance so far.

  • Run SQL against Pointbase server

    After creating a new domain from domain template, I was asked to run a sql against the pointbase database ..
    I noticed the startPointBaseConsole.cmd does not start the database itself. Do you know how to start the pointbase in WLP10GR3??
    Thanks,

    Shouldnt need to as far as I remember for pointbase.
    In any case, if you open startWeblogic.cmd you should get the command to start up pointase
    In 10.2
    call "%WL_HOME%\common\bin\startPointBase.cmd" -port=%POINTBASE_PORT% -debug=%PB_DEBUG_LEVEL% -console=false -background=true -ini=%DOMAIN_HOME%\pointbase.ini >"%DOMAIN_HOME%\pointbase.log" 2>&1
    which should be same in 10.3 but I havent verified that

  • Running HTMLDB against another Oracle Instance

    I have an HTMLDB dashboard onto our system and would like to be able to run it against a different Oracle instance. Ideally would like to be able to choose the instance on the login screen. Currently we have to setup dblinks to each of our instances and then customise the application to select from the relevant instance. Any ideas?

    AFAIK, Golden Gate has no requirement on Oracle edition to be used, but could have licence cost differences.
    It works on Oracle from version 8i to the latest one, not only on Oracle database, and not only between same Oracle version and same OS, and not only between two Oracle db .
    Nicolas.

  • Dbms_job - running update on another schema is failing

    Hi all,
    I believe I've traced my problem down to a permissions issue, but I'm not exactly sure why.
    I have three users in a particular database. One user has DBA access, one user is there just to be the owner of everything and a third user which will be the account our web app uses to connect so we can assign privliges appropriately.
    I'm signed in as the DBA account (not SYS) and I can run a simple update statement on a table in the main schema:
    insert into mainuser.bloodtype (blood_type) values('z');
    Do a commit, and it's all good. Now I try putting that same SQL into a job:
    DECLARE
    jn binary_integer;
    begin
         DBMS_JOB.SUBMIT(jn, 'insert into mainuser.bloodtype (blood_type) values(''z'');',SYSDATE + 1/1440);
         DBMS_OUTPUT.PUT_LINE(jn);
         commit;
    END;
    When I check all_jobs, the job is there with the SQL listed exactly as it should be executed however the job ends up failing. Now I tried something similar but working strictly inside the DBA's schema and it works fine. So there must be something I'm missing due to permissions...but since the SQL works outside the job I'm not sure what it is. Is there a view or log I could look at in order to determine what the cause of the failure is, or does anyone know exactly why this is failing?
    The ultimate goal here is to grant the webuser account enough privliges to submit jobs in order to execute SQL to update items in the database based on a scheduled time. I'm just testing right now using the DBA account as I thought this would be easy to get working.
    Thanks.

    .......wouldn't you know it worked now.?!
    I'm not sure I understand the 'why' behind that though....it sort of makes roles a bit useless, no?No.
    [url http://asktom.oracle.com/pls/ask/f?p=4950:1:11743829664184798667:pg_R_576301530530070&pg_min_row=11&pg_max_rows=10&pg_rows_fetched=10]AskTom

  • How to create table in another schema of same database

    Hi..
    I've a database DB1
    and has 2 schemas / USers in that..
    Usr1 and Usr2...
    And i created a TEMP table in Usr1 schema... and created
    Then tried the following statement in Usr2 schema...
    CREATE TABLE TEMP AS SELECT * FROM Usr1.TEMP;
    Then it's giving error that ...
    :00942 TABLE OR VIEW DOESN'T EXIST..
    What is the reason for that...
    Thank you

    josh1612 wrote:
    What other grants do i need to give so as to replicate the Primary Keys also...????That's not a matter of grants. It's the way the CREATE TABLE AS SELECT statement works. It does not copy over indexes, primary key constraints, unique constraints, foreign key constraints, etc.
    If you want to copy all that over, you would probably want to get the DDL from the original table (using the DBMS_METADATA package if you're in a recent version), modify the DDL with the new schema name, create the table, indexes, and constraints, and then do an INSERT ... SELECT to populate the data. Or do an export & import of the table from one schema to another.
    Justin

  • Imp records of One schema into another schema of same table.

    I had done following steps,
    schemas(toy,toys)
    1) i open the session of toy schema
    First i taken backup of table
    create table bck20121103_himan as select * from himan;
    Backup table is created.
    After taking the Backup table
    delete himan;(deleting the records)
    2) i log in to another session(toys)
    exp toys/toys@orcl file=20121103TOYs.DMP TABLES=(HIMAN) /* Particular table is taken*/
    3) i log in to toy schema
    imp toy/toy@orcl file=<dump file name> TABLES=(HIMAN) INDEXES=N IGNORE=Y
    i tried the above statement it taken so much of time..
    Later i tried
    I log in to toy session
    i rename the table with other name.
    later i imported
    imp toy/toy@orcl file=<dump file name> TABLES=(HIMAN) IGNORE=Y FULL=Y
    it's successfully imported..
    kindly correct me if its wrong or any other steps is their ..

    as per your first method.
    you took backup
    you deleted not commited.
    took export from toys and imported into toys without fromuser & touser
    after correction.
    ============
    you mentioned
    you took backup
    you deleted toy.himen (again not commited)
    exported toy.himen
    imported toy.himen
    check you might have got the duplicate records also
    when you delete any records its a dml operation which does not auto commit you need to commit it.
    hope you got the point.
    Regards
    Kaleem.

  • Best LKM to move data from with in Oracle from one schema to another Schema

    Hi Gurus,
    What is the best KM to move data from one schema to another schema within same oracle database.
    Thanks in advance

    Dear,
    If your source and target are on the same database server then you dont need LKM.
    You have to 1. create one data server for the database server
    2. Create one physical schema for your source and another physical schema for your target under the above created data server.
    3. Then create models for each above created physical schema
    In this case you just need IKM knowledge module
    Please refer http://oditrainings.blogspot.in/2012/08/odi-interface-source-target-on-same.html
    If your source and target are on different server then you must create two different data servers in topology. You have to use LKM.
    The best LKM to use is LKM oracle to Oracle dblink. But you should have proper grants to use it
    If your source has very few records you can go with LKM SQL to Oracle other wise use LKM oracle to Oracle dblink

  • Help me to fix the error while running DBMaintain Against the Database Schema in ASE.

    Hi All,
    I am trying to install sybase mobiliser platform 5.1 SP 03.I am  referring the following guide
    http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01871.0513/pdf/Mobiliser_Platform_Installation_Guide_5.1…
    Now I have configured the ASE database server with default settings and now it is running fine.
    Now my concerns are as follows:
    1) I have executed the database schema (mobr5): 001_MONEY_drop_and_create_user.DDL with the help of linux command
    isql -Usa -SASE1 -Phello@123 -i/opt/sybase/db/sql/001_MONEY_drop_and_create_user.DDL -o/opt/sybase/ASE-15_0/install/ASE1.log
    How do I check the created database schema and user with default name 'mobr5'?
    2) While running DBMaintain Against the Database Schema, I have followed the steps mentioned in the guide and made the following changes in the file dbmaintain.properties.ase
    database.driverClassName=com.sybase.jdbc4.jdbc.SybDriver
    database.url=jdbc:sybase:Tds:ASE1:5000/mobr5
    database.userName=mobr5
    database.schemaNames=mobr5
    database.password=paybox
    #Must be set if the driver is not packaged inside the scriptarchive or is present on the classpath
    #e.g. /path/to/driver.jar
    #database.driverLocation=/path/to/jconnect.jar
    database.driverLocation=/opt/sybase/db/sql/com.sybase365.mobiliser.vanilla.standalone-5.1.3.RELEASE-scriptarchive-ase.jar
    database.driverLocation=/opt/sybase/db/sql/com.sybase365.mobiliser.vanilla.standalone-5.1.3.RELEASE-scriptarchive-ase-vanilla.jar
    When I execute the script archives ,
    java –jar /opt/sybase/db/sql/com.sybase365.mobiliser.vanilla.standalone-5.1.3.RELEASE-scriptarchive-ase-driverless.jar -c /opt/sybase/db/sql/dbmaintain.properties.ase
    java –jar com.sybase365.mobiliser.vanilla.standalone-5.1.3.RELEASE-scriptarchive-ase-vanilla-driverless.jar -c dbmaintain.properties.ase
    I get the following error:
    So please help me to resolve the issues.

    Hi All,
    Issue is resolved and database has been updated successfully..
    Error was in database .url field of dbmaintain.properties.ase file.
    I have changed the database.url field  from database.url=jdbc:sybase:Tds:ASE1:5000/mobr5
    to  database.url=jdbc:sybase:Tds:<Private IP of Linux instance>:5000/mobr5
    Note:- I am installing mobiliser platform on AWS cloud.So I have made use of Private IP address of AWS Linux instance.

  • SQL Plan Management - Baseline- Can it be used in another Schema

    Hi,
    I have never implemented, SQL Plan Management -Creating SQL plan baselines.
    I am having a query which is using indexes in one Schema.
    On another Schema in the same DB, the query accesses the SAME TABLE THROUGH SYNONYM. And the plan is very different. And query goes into indefinite execution.
    I have tried hints and other ways but it's simply not using the indexes.
    Anyone having experience with Baselines, can you suggest if I create a Baseline for the plan in SchemaA.
    Then can I use the same plan through Baseline in SchemaB for the same query?
    Please suggest..Thanks..

    Hi Jeneesh,
    Thanks for the reply.
    Problem is that the query has Xquery code inside and it's using the XMLType indexes. That's why it does not seem to be using the XML Indexes even by Hints.
    I have posted the scenario in XMLDB Forum as well:
    Re: Table in Schema1 using XMLIndexes But not in View- Schema2
    But can you think of any harm if I try to create Baseline and tag the query with it.
    So even in other schema if the same query is fired it will use the right Explain Plan.
    I am not able to figure out any other way right now.
    Please suggest..Thanks..

  • Calling PL/SQL Procedure In Another Schema Gives Unexpected Result

    I have a SQL Script that does this:
    conn pnr/<password for user pnr>;
    set serveroutput on;
    exec vms.disable_all_fk_constraints;
    SELECT owner, constraint_name, status FROM user_constraints WHERE constraint_type = 'R';
    and the disable_all_fk_constraints procedure that is owned by user 'vms' is defined as:
    create or replace
    procedure disable_all_fk_constraints is
    v_sql   VARCHAR2(4000);
    begin
    dbms_output.put_line('Disabling all referential integrity constraints.');
    for rec in (SELECT table_name, constraint_name FROM user_constraints WHERE constraint_type='R') loop
    dbms_output.put_line('Disabling constraint ' || rec.constraint_name || ' from ' || rec.table_name || '.');
    v_sql := 'ALTER TABLE ' || rec.table_name || ' DISABLE CONSTRAINT ' || rec.constraint_name;
    execute immediate(v_sql);
    end loop;
    end;
    When I run the SQL script, the call to vms.disable_all_fk_constraints disables the FK constrains in the 'vms' schema, whereas I wanted it to disable the FK constraints in the 'pnr' schema (the invoker of the procedure). I know that I could make this work by copying the disable_all_fk_constraints procedure to the 'pnr' schema and calling it as "+exec disable_all_fk_constraints;+" from within the SQL script but I want to avoid having to duplicate the PL/SQL procedure in each schema that uses it.
    What can I do?
    Thank you

    You have two issues to solve.
    First you need to write a packaged procedure that works with INVOKER rights. The default is DEFINER rights.
    The difference is excatly what you need. Usually the package has the rights from the schema where it is defined (=Definer rights). In your case schema VMS. Whereas you need the privileges from the user that calls the package (PNR).
    => Check out the documentation for INVOKER rights
    The second problem is that the view "user_constraints" will not give the results you expect when called from inside a procedure in another schema. An alternative could be to use the view DBA_CONSTRAINTS with a filter on the owner (where owner = 'PNR'). Not sure if there are other working possibilities. Well you could create a list of constraint names that you want to disable, instead of creating the list dynamically.
    And you could have another potential disaster creeping up upon you. If you run this thing, then at this moment you don't have any referential integrity anymore. You can't be sure that you can create the FKs again after this action. This is EXTREMLY DANGEROUS. I would never ever do this in any kind of production or test database. I would be very careful when I do it on a development database.

  • DEMANTRA Error Another engine might be running currently on this schema

    Hello Experts,
    When i am running the Analytical Engine . I am getting the following error:-
    DEMANTRA Error Another engine might be running currently on this schema, delaying for 22 seconds to make sure...
    ERROR Another Engine is already running in Unknown mode.
    Please make sure to stop all running Engines either in Batch or simulation mode before retrying.
    I have tried all possibilitties like 1. SHUTTING Down database 2. Restarting my machine .3 Tried to kill the process using KillProcess.exe ...But nothing works.
    I am getting the same error when ever i tried to start the Analytical Engine.
    Please help!!!!!!
    Thanks,
    Neeraj.

    Hi Shekhar,
    Thank you very much for your response.
    Steps for running the Analytical Engine:-
    There are two ways and from both i am getting the same error :-
    1. Start--> Engine Administrator --> Connect --> Run Mode = 'Batch' and Engine Profile = 'Batch' --> Run Engine.
    2. Start--> Analytical Engine.
    Log Meesage:-
    07:48:35:109 [EngLogger.cpp,187] Logger General Level: info, UserLevel: message
    07:48:35:109 Working with Oracle RDBMS
    07:48:35:156 Database connection string: Provider=MSDAORA;Data Source=orcl User:
    DPNEW
    07:48:53:468 --------------------------------------------------------------
    07:48:53:468 Oracle Demantra Forecast Engine Version 7.2.0 (290)
    07:48:53:468 Engine Start Time 07:48:53
    07:48:53:468 Running in Batch mode
    07:48:53:468 --------------------------------------------------------------
    07:48:53:578 WARNING Another Engine might be running currently on this schema, d
    elaying for 22 seconds to make sure...
    07:49:15:593 ERROR Another Engine is already running in Unknown mode.
    Please make sure to stop all other running Engines either in batch or simulation
    mode before retrying.
    I also tried to Kill any existing running engine
    1. Start--> Engine Administrator --> Connect --> Run Mode = 'Batch' and Engine Profile = 'Batch' -->
    Selecting the Executable File Name = 'KillProcess.exe' --> Run Engine
    Log Message
    Usage: KillProcess [ProcessName]
    However , this process keeps running and is not completing. I had to terminate the process.
    Thanks,
    Neeraj.

  • Creating a database link to another schema in the same database

    Hello,
    I'm trying to create a database link to another schema in the same database. It was created without errors, but when I try to use it I receive "ORA-12154: TNS:could not resolve the connect identifier specified" message...
    I'm trying to do it because on my production enviroment the databases are separated, so there I can use database links without problem, but in my development environment it's all in one database separated by schemas...
    So I'm trying to simulate the same system to not need to rewrite the query every time I move from development to production environment.
    Any ideas?
    Thanks

    Hi,
    Yes, you can create a database link to your own database. I've done it before for exactly the same reason you want to.
    (By the way, I think it's a good reason. What are the alternatives?
    Having different versions of code for Development and Production? Absolutely not! Terrible idea!
    Using synonyms or substitution variables that are set differently in the different databases? That might be more efficient than a database link, but efficiency probably isn't such a big issue in Development.
    [Conditional compilation|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/fundamentals.htm#sthref250]? This might be good; it has all the efficienty of the above options, with more clarity.)
    Assuming you do want to stick with a database link, not all errors are caught when you create the link.
    Is the Development database in the tnsnames.ora file of the Development server? Do you have other database links, either in the Development server or pointing to it, that work? What is different about the ones that work, and the one that doesn't?
    Edited by: Frank Kulash on Oct 14, 2009 1:58 PM
    The more I think about this, the more I agree with the earlier respondent: synonymns are a good solution for this.
    To that suggestion you replied:
    On this way I might use "select * from SCHEMA.table" instead of "select * from table@SCHEMA"... I looking for an option to use the second way...Actually, the suggestion was that you say:
    select  *
    from    SCHEMA_table_ptr;where schema_table_ptr is a synonym.
    In Development, that synonym is defined as schema.table.
    In Production, that synonym is defined as table@SCHEMA
    Why are you "looking for an option to use the second way"?
    If you think that people reading the code should realize that the query is being done via a database link (at least in Production), then add a comment.

  • How can i run VisualScript of one URL against another URL

    hi folks,
    could anybody tell me how can we run the visual script of one url against another url ?
    eg: visual script recorded for http://www.abcd.com/index.html must be run against http://www.abcd.com/index1.html
    thanks in advance,
    pasumarthi

    pasumarthi,
    You can right click the address node select properties on page one and change the url there. Since the tool is DOM based all following urls will automatically update when you play the script back. You can also use the script updater utility (in the etest icon group) if you have 8.20.
    Hope this helps.

  • We have a PCI-6110S to run our VIs. But, we are planing to buy another card (PCI-6024E​) to run real time PID vi. So, if they are installed at the same computer, would it be a problem for LabVIEW to run both of them at the same time.

    We have PCI-6110 S series installed in our computer. We are planing to purchase PCI-6024 E series card. They will be both installed at the same computer.
    1) I am wondering if we run both of them at the same time, would we have any problem?
    2) To run PID real time, can any E series of PCI card be used?
    Thanks...

    Hello Baho,
    1) Using Traditional NI-DAQ, there could be problems with the fact that the NI-DAQ driver is not multi-threaded; meaning that while waiting for one operation to complete, the driver could cause another operation to time out. On the other hand, DAQmx is multi-threaded, and would eliminate this problem. At the time of this writing though, DAQmx does not yet support simultaneous-sampling boards like the PCI-6110S. A good solution then would be to use Traditional DAQ for the 6110S and DAQmx for the E-series board, and they would by default run in separate threads.
    2) No, using a PCI E-Series board, the LabVIEW VI would have to run in a Windows OS and would not be Real Time or run deterministically. You can run the PID program in Windows, but the
    results could be inconsistent. The advantage of a Real Time is that the OS is deterministic or that the OS allows you to tightly control or determine the maximum time any function takes to operate. This kind of control of the maximum operation time is not possible with non-Real Time OSs such as Windows.
    If you would like to get set up with a Real Time System, I suggest you contact your Technical Sales Representative.
    Regards,
    Chad Evans
    National Instruments

Maybe you are looking for