Update/insert into table in another schema

Hello

I have a custom table that is located in another schema used by our dashboard for custom tables. I want to allow users to add/edit users and the security groups for dashboards.

I see two possible solutions to this issue, I was wondering if anyone has done so and has a better solution or pointers.

Possible solutions:

1. move the table to the APEX workspace. Not desirable, would lead to changes in the Production for the pools of connections in the repository.

2. create a temporary table where you would load the security table data when the user wishes to add/modify records in the security table and then use triggers to update the table by using the synonym to the table.

Any help would be appreciated.

Thank you
Rob

Modify the procedure to look like to...

create or replace PROCEDURE UPDATE_TABLE(p_table IN VARCHAR2,
                                         p_column IN VARCHAR2,
                                         p_value IN VARCHAR2,
                                         p_condition IN VARCHAR2)
AS
v_sql_stmt VARCHAR2(4000);
BEGIN
  v_sql_stmt := 'UPDATE ' || p_table || '  SET ' || p_column || ' = ' || p_value || ' WHERE ' || p_condition;
  EXECUTE IMMEDIATE v_sql_stmt;
  COMMIT;
END UPDATE_TABLE;

{code}

Edited by: Tyson Jouglet on Sep 25, 2008 8:03 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

Tags: Database

Similar Questions

  • create existing table in another schema

    Hi master,

    We are using oracle 10g R2 on linux.

    I have a scheme say user1 with many tables, starting with

    BC_ (50 PICTURES)

    PC_ (20 TABLES)

    LC_ (30 TABLES) etc.,.

    now, I want to create these tables in another schema with their constraints and their privileges in another schema.

    as I want to generate a create table script, which will create a table that begins with "BC_" only. another script will create table starting with "PC_" only. and like that.

    is it possible with the command

    create the table AS
    Select * from (old scheme). (table_name);

    can we use query sub in it to be more precise?

    and it will transfer all its privileges and grants the new schema?


    Thanks and greetings
    VD

    It is possible to CREATE TABLE as SELECT from a different scheme but CREATE TABLE as SELECT will transfer only the data and the structure of the base (column names and data types) table, no constraints.
    I think, you have two options to do this easily:
    (1) use SQLDeveloper (GUI) or a procedure from PL/SQL DBMS_METADATA. GET_DDL to generate the SQL script to create table with constraints, you can use INSERT INTO new table (columns) column SELECT FROM oldschema.oldtable
    DBMS_METADATA Description: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm#i1019414

    (2) export a schema data, import it into the other using Data Pump or exp/IMP.
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14215/dp_export.htm#i1007466

  • READ the TABLE of another schema

    Hello
    pls help me.

    I want to read the table of another schema that is declared in the application of the apex.

    SELECT * FROM DBA_ROLE_PRIVS;
    (SELECT * FROM sys.) DBA_ROLE_PRIVS: auch bad)

    The owner of this table is SYS.

    Error: The Table is unknown or cannot be found.

    my real schema is GCs.

    How is the select statement for this case for reading in the table (or tableview) of another schema?
    many and many thanks for your help.
    TL

    The SYS schema is a special schema in Oracle. You must explicitly grant the user rights by selecting tables and views sys.

  • INSERT INTO table (columns...) with table_tmp in select... ...

    Hi guru,.

    Is less than a valid SQL | Statement of PLSQL? or several instructions and what it does?

    insert into table (col1, col2, col3, col4)
    with table_tmp as
    (select ccol1, ccol2, ccol3, ccol4, ccol5, ccol6
    from table1, table2 t2 t1
    where t1.id = t2.id
    and t2.start > sysdate()
    )
    Select tcol1, tcol2, tcol3, tcol4
    of table_tmp tt1, table3 t3
    where tt1.id = tt3.id;

    I checked the SQL quick reference card and don't see anything similar to this... I wonder where I can find a better book of reference for the syntax.

    Thanks in advance
    KH

    user5885318 wrote:
    Is less than a valid SQL | Statement of PLSQL? or several instructions and what it does?

    It inserts data into the table

    insert into table (col1, col2, col3, col4)

    (ok, ignoring the fact that you can't have a table named table)

    using the select statement located below

    with table_tmp as
    (select ccol1, ccol2, ccol3, ccol4, ccol5, ccol6
    from table1, table2 t2 t1
    where t1.id = t2.id
    and t2.start > sysdate()
    )
    Select tcol1, tcol2, tcol3, tcol4
    of table_tmp tt1, table3 t3
    where tt1.id = tt3.id;

    I checked the SQL quick reference card and don't see anything similar to this... I wonder where I can find a better book of reference for the syntax.

    SQL reference documentation contains the complete syntax for Oracle SQL, so how can you find a better reference for the syntax. I think your concept to better is all simply because you are not familiar with things and don't know where to find things. SQL is a huge beast, so you cannot expect to find things very quickly in all cases, especially if you don't really know what you are looking for.

    I'm guessing you are struggling to find information about the clause "WITH"?

    It is called subquery factoring and lie under the SELECT statement in the SQL reference:

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_10002.htm#i2161315

    An equivalent statement without the WITH clause (using your insert as a base statement)...

    insert into table(col1, col2, col3, col4)
    select tcol1, tcol2, tcol3, tcol4
    from (select ccol1, ccol2, ccol3, ccol4, ccol5, ccol6
          from table1 t1, table2 t2
          where t1.id=t2.id
          and t2.start > sysdate()
         ) tt1
         , table3 t3
    where tt1.id=tt3.id;
    

    The done WITH clause takes the subquery in the main query. This is useful if the same subquery is needed more than once in the main query.

  • Insert into table fault

    When I use the function 'insert into array' index(like 5), it does not work. When I put the index zero, it works, and inserts the new item at the end of the table. ?. ?

    Hello

    I think the problem is that you have not initialized your table to which you will add an element. You must double clik and adds a number. You can inicialize, only the last element and the other elements will also be inicialized.

    Try looking at the photo.

    Hope it helps

  • The values of cursor two corresponding and insertion into tables

    I ' am using sql developer oracle 11g.

    I have 3 tables called

    PRODUCT_NOTIFICATION

    RECORD

    PCS_NOTIFICATION

    --------------------

    PRODUCT_NOTIFICATION

    IDTITLEMessage
    21sale50% discount on all brand products

    RECORD

    IDREGNAMEACTIVATIONCODESTATUSMOBILENUM
    747407931107TESTTHERE12345
    39717371107TESTuco1THERE6789

    Now, I want to take only the message of product_notification table column and

    pick up the registered customer of registration table where the activationcode_status = 'Y '.

    PCS_NOTIFICATION

    Output of desire in the PCS_NOTIFICATION TABLE

    IDMOBILENUMMessage
    11234550% discount on all brand products
    2678950% discount on all brand products

    THEN insert the message in pcs_notification.

    It is the procedure goes as...

    create or replace

    PROCEDURE sp_notification)

    p_out_msg OUT VARCHAR2

    )

    AS

    CURSOR C_product_notification

    IS

    Select the description of product_notification;

    -Search for registered customer

    CURSOR C_registered

    IS

    Select * from registration where activation_code = 'Y ';

    for k C_INSERT

    LOOP

    THEN

    BEGIN

    If C_product_notification = C_registered THEN

    INSERT INTO PRODUCT_CLOUD_NOTIFICATION VALUES () - stuck here

    ---------------------

    ---------------------------------

    --------------------------------------

    Goal is to send the generic message for every individual mobile numbers of registered customers.

    Help, please...

    Create a sequence object to fill PCS_NOTIFICATION.ID. allows you to call him PCS_NOTIFICATION_ID_SEQ.

    Now all you need is a simple insert statement.

    insert into pcs_notification (id, mobilenum, message)
    select pcs_notification_id_seq.nextval, r.mobilenum, pn.message
      from product_notification pn
      cross join registration r
     where r.activationcodestatus = 'Y';
    
  • grant the select privilege on the table in another schema by role error

    Hello
    I have a problem with the granting of privileges to another schema
    I have A user who has only 1 system priv: connect, which has a private: create session;
    I created a role X, which I have the privilege: select on a table to a diagram B customer.
    I then conceded this X role to A user.
    I can't select * B.customers when im connected to A
    identification of information like it that I'm missing?
    Thank you
    Rgds

    >
    but whenever I put a default role, the other is automatically set to zero-defects

    How did you receive the two default roles?
    >
    By running the code I posted above as user SYS.

    Drop your user and start again and use the code I posted.

  • Update/Insert into mapping

    Hello world

    I need your help please. I would like to make a mapping update/insert.
    I have a target with 12 fields table. The first 6 fields are defined as unique constraint ONE LOOK. The other 6 fields are normal attributes. It is only a mapping between a table source and target.
    My problem is: if I run the map, the first time it will insert all correct records in the target table. If I run this mapping it will end again with this warning:
    ORA-00001: unique constraint (SCHEMAUSER. UNIQUE_KEY) violated
    I already found this link in the forum: Re: conversion of MERGE statements in maps
    As I clicked on the target table and selected "UNIQUE_KEY" (my constraint name) for "Game by constraint" in the table on the left operator properties.
    My properties for all my 6 unique constraint fields are:
    Load the column when new line: No.
    Update operation: =.
    Matches columns when new line: YES
    Charge when inserting line column: YES
    Corresponds to the column when you delete lines: YES

    My properties for my attribute fields are:
    Load the column when new line: YES
    Update operation: =.
    Matches columns when new line: No.
    Charge when inserting line column: YES
    Corresponds to the column when you delete lines: No.

    I think I have a problem in one of these properties.
    Once again my problem: I'm not able to run the map without warnings to insert new records for table or update the existing ones.
    Please help me.

    Thank you
    David

    This has always worked for me.
    Doesd solution is:
    Right-click the mapping-> configuration-> default operating mode = baseline.

    But what is causing the performance degradation.

    Click on generate option in the Menu
    Then generation result
    Select intermediate
    After that, select the output of the filter Group
    Run this result in the database and verify that you get double in six columns.

  • the display of tables in another schema in the database

    I started using the SQl Developer 1.5.
    We can connect to a database of oracle with success, expanding the tables, it displays the list of tables in a schema.

    We have another schema in the database. In the query Panel, when type us the name of the other schema as the CHT. then a few table names appear in the intellisense.


    How can show us the list of tables to another within the same database schema.

    Welcome.

    Please also take some time for correct/good answers to award points.

  • Insert into table primary key (automatic numbering) for back in class resultset

    Hello

    I connect to Oracle 10 g via JDBC (ojdbc14.jar is).
    My SQL statement is:

    INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test');
    SELECT Student_studentId_SEQ. NEXTVAL FROM DUAL;

    FYI - the Student table has a trigger to support the generation of a primary key (integer) based on a sequence when a new record is inserted.

    The above will do (from the point of view of Java app) is to create a school record and automatically select the student card and student card is accessible via the resultset in Java.

    I get the error message ' ORA-00911: invalid character '. Can you please help?


    Kind regards
    Jason

    Published by: user10394130 on October 13, 2008 02:40

    As I said already try using a refcursor like that.

    DECLARE
    seqNbr_studentId NUMBER (12): = 0;
    stud_cur SYS_REFCURSOR;
    BEGIN
    INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test')
    StudentId INTO seqNbr_studentId RETURN;
         
    Stud_cur OPEN to SELECT seqNbr_studentId OF MODEL;
    END;

    Thank you
    Knani.

  • Referencing Tables in another schema

    APEX 4

    http://i.imgur.com/WDwSC.jpg

    Is it true that you cannot reference another schema objects (i.e. ONLY the scheme of the application's default analysis)?

    I also noticed that this button "Requester" will lead you to QB page where only the analysis scheme appears.

    Thank you

    RalphK,

    Not true. Make sure that your analysis schema has grants appropriate to perform the action you want on an object in another schema. If this is not enough and you need access to another scheme of your workspace and then talk to your apex admins and it adds the schema to your workspace. Workspaces can be mapped to multiple schemas. It is not a one to one relationship.

    Thank you

    Janet Tyson

  • How to allow a user to view all the tables from another schema?

    I have a 'vic4ever' scheme where I have created all my tables. Now, I create a new user named "nvvp1". So, I want to enable nvvp1 display all tables in a schema vic4ever. But I don't know how to do! Or I need to run this command for each table?
    Grant select on vic4ever.table1 to nvvp1;
    Grant select on vic4ever.table2 to nvvp1;
    ....

    Thank you

    Yes, that's what you have to do, but you could speed up a bit:

    BEGIN
    FOR cur_rec IN (SELECT table_name FROM ALL_TABLES WHERE UPPER(owner) = 'NVVP1')
      LOOP
        EXECUTE IMMEDIATE 'Grant select on vic4ever.' || cur_rec.table_name || ' to nvvp1';
      END LOOP;
    END;
    /
    
  • Using Merge and collection of update/insert a table

    See any problem with this, or does anyone have a better solution? I am trying to insert or update a table using the values in the collection:
    BEGIN
    
    
    
    MERGE INTO TBL d
    
    USING (select c001, c002, c003, c004,c005 from htmldb_collections where collection_name='P77_COLLECTION') s
    
    ON (d.login_id = s.c001)
    
    WHEN MATCHED THEN
    
    UPDATE 
    
    SET d.case = s.c002
    
    WHERE d.collection_type = 'Exchange'
    
    WHEN NOT MATCHED THEN
    
    INSERT TBL (d.login_id, d.case, d.work_order, d.status, d.wo_close_date, d.collection_type)
    
    VALUES (s.c001, s.c002, s.c003, s.c004, s.c005,'Exchange');
    
    
    
    END;
    I get the following fake error message:

    ORA-06550: line 12, column 8: PL/SQL: ORA-00926: lack of keyword VALUES ORA-06550: line 4, column 1: PL/SQL: statement ignored

    Thank you
    -Abe

    You don't have to INTO or the name of the table, just WHEN NOT MATCHED THEN INSERT (col1, col2,...) VALUES (val1, val2,...)

  • How is it, I can't insert into table inside the function?

    If I have a simple function that takes the same data with SELECT... IN... and then the information I need to insert back to the same table, but the error message says I can't insert, update, delete on a table I'm working on, but I understand that is SELECT... Will be actually copy the data from a select query in these variables that I use in my SQL function. So why, after completing Select I can't update in my SELECT stopped working already on the table.

    Procedures may not be called from a SQL statement.

    However, you can [call procedures PHP | http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks_sps.html].

    Justin

  • How to listen to a couple of times (with different names) table in another schema?

    Hello guys,.

    I replicate a table schema (SCH_1) (TAB_1) on the basis of data source (named DB_1) twice on the schema (SCH_2) on the basis of data target (DB_2) with two different names (TAB_1 and TAB_1_SHORT). TAB_1_SHORT on db target must be a subset (eg. WHERE STATUS = 1) of TAB_1!

    How to do? can someone help me?

    I tried to realize that in this way:

    (1) creation of 1 capture process with the rule 1 table on source db (without any rule of subset to capture all changes) for table TAB_1

    (2) creating a process of spreading with no rules

    (3) creation 1 apply the process with a rule in table for table TAB_1 without any subset_rule but with the transformation of the pattern of SCH_1 to SCH_2 (DBMS_STREAMS_ADM. RENAME_SCHEMA) = > it works correctly!

    (4) creating a subset_rule (WHERE STATUS = 1), a transformation of the pattern of SCH_1 to SCH_2 (DBMS_STREAMS_ADM. RENAME_SCHEMA) and a transformation of tablename from TAB_1 to TAB_1_SHORT (DBMS_STREAMS_ADM. RENAME_SCHEMA) for table TAB_1_SHORT = > does not work, no errors posted in dba_apply_error!

    in another chance, I tried to turn the table and the schemaname in the process of capture, with the effect that my first table TAB_1 would not be listened to again.

    I don't know what the problem is. I think it must be possible to publish a table for two different targettables in the same pattern on an another db, is not it?

    I hope that the greetings
    Flo

    Hello

    Adding a normal table rule and also a subset rule would not work because the rule would be evaluated only once in the set of positive rules. If the normal rule is evaluated first, then the subset rule and the rest of the rules would not be assessed at all that's why it would not work.

    This can be done using one of the following methods:

    Method 1:

    1 use the declarative transformation on the capture/apply and rename SCH_1 to SCH_2 scheme.
    2. now, on the site apply, define a DML for SCH_2.TAB_1 Manager
    3 al ' DML Handler, do the following:
         
    a. get the value of the STATUS column
    b. check if the value of STATUS = 1, if yes, then change the name of the object to TAB_1_SHORT and run the LCR.
    (c) another thing not to change the name of the object (leave it as it is, TAB_1) and run the LCR.
              
    Method 2:

    1. Add a DML for SCH_1.TAB_1 Manager
    2. in the DML handler perform:
         
    method of set_object_owner use of LCR$ _ROW_RECORD to rename the owner at the SCH_2
    b. get the value of the STATUS column
    c. check if the value of STATUS = 1, if yes, then change the name of the object to TAB_1_SHORT and run the LCR.
    (d) another thing not to change the name of the object (leave it as it is, TAB_1) and run the LCR.

    Please let me know if you need examples of code.

    Thank you
    Florent

Maybe you are looking for