Execute procedure over database link

Hi,
I''m working on a package where you can select the required database, paste some query and with clicking on a button it will execute and create an explain plan for this query.
Therefore i've create a procedure on each database that put's the explain plan in the PLAN_TABLE.
To do this i need to execute this prodecure from the package. I use the following code:
DBA_OWNER.DB_PCD_EXPLAIN_PLAN@DBA_LINK_533.WORLD(p_query);
This is working fine as this database link allready exists to the required database. But i want to make the database link name variable. I've allready created the dynamic database link:
l_link varchar2(20) := 'DBA_LINK';
l_link_nr number(4) := dbms_random.value(0,1000);
l_db varchar2(20) := l_link||'_'||l_link_nr;
l_statement varchar2(4000);
begin
l_statement := 'create database link '||l_db||' connect to **** identified by ***** using '''||p_database||'.WORLD''';
execute immediate l_statement ;
So now i have the dynamic databaselink that is created each time i call the package.
now i want to use this databaselink to call the procedure. this is where it goes wrong.
The code i'm using:
DBA_OWNER.DB_PCD_EXPLAIN_PLAN@l_db(p_query);
is not acceoted when i build the package.
The follwoing error message is showed.
PACKAGE BODY DBA_OWNER.PCK_EXPLAIN_PLAN
On line: 66
PLS-00352: Unable to access another database 'L_DB'
Does someone know how to use this variable to execute the procedure on the remote db?

Any procedures you call have to be accessible at compile time, so the database link must also exist at compile time.
You can get around this by putting your procedure call to DB_PCD_EXPLAIN_PLAN inside dynamic SQL, the same as you are doing to create the database link. Dynamic SQL is not checked until runtime.
Think about the risk if this procedure is exploited. You are creating a way for someone to run arbitrary code in an any database in your environment, with presumably a highly-privileged ID, if it can run an explain plan against any schema in any target database.
This is exposing some significant security issues. Read up on SQL injection, and have someone else review the code for security issues before deploying this.

Similar Messages

  • Execute procedure over db link

    I am trying to execute a stored procedure over database link and I get the following error
    DBMS_APPLY_ADM.SET_UPDATE_CONFLICT_HANDLER@DBCS(
    ERROR at line 12:
    ORA-06550: line 12, column 2:
    PLS-00306: wrong number or types of arguments in call to 'SET_UPDATE_CONFLICT_HA
    NDLER'
    ORA-06550: line 12, column 2:
    PL/SQL: Statement ignored
    However when I execute the same peice of code by logging on to the server the code executes successfully. "DBCS" is the database link name.
    CODE which I am executing over DB LINK
    DECLARE
    COL_NAME DBMS_UTILITY.NAME_ARRAY;
    CURSOR C1 IS
    SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS WHERE OWNER='SCOTT' AND TABLE_NAME='DEPT';
    BEGIN
    OPEN C1;
    FETCH C1 BULK COLLECT INTO COL_NAME;
    CLOSE c1;
    DBMS_APPLY_ADM.SET_UPDATE_CONFLICT_HANDLER@DBCS(
    OBJECT_NAME => 'SCOTT.DEPT',
    METHOD_NAME => 'OVERWRITE',
    RESOLUTION_COLUMN => COL_NAME(1),
    COLUMN_LIST => COL_NAME);
    END;
    CODE without DB LINK (executed this on db where db link is pointing too.
    DECLARE
    COL_NAME DBMS_UTILITY.NAME_ARRAY;
    CURSOR C1 IS
    SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS WHERE OWNER='SCOTT' AND TABLE_NAME='DEPT';
    BEGIN
    OPEN C1;
    FETCH C1 BULK COLLECT INTO COL_NAME;
    CLOSE c1;
    DBMS_APPLY_ADM.SET_UPDATE_CONFLICT_HANDLER(
    OBJECT_NAME => 'SCOTT.DEPT',
    METHOD_NAME => 'OVERWRITE',
    RESOLUTION_COLUMN => COL_NAME(1),
    COLUMN_LIST => COL_NAME);
    END;
    Please guide.

    orausern wrote:
    Hi,
    We are on Oracle 11.2.0.2 on Solaris 10. I have two databases on this version of Oracle. From one db I have execute a stored procedure via db link to another database. The store procedure has dynamic sqls (execute immediate) and it uses commit statement as part of the code. Is it alllowed to execute this procedure over db link? I am not aware on the implications on stored proc execution over db link and will be thankful for help.
    Thanks,if no error is thrown, why are you looking for problems where none exist?

  • Can we create pl/sql code over database link?

    Hi All,
    We are using Oracle 9i database.
    I want to know if we can create or modify pl/sql code (procedue, package, etc) over the database link? That means - can we create a procedure in remote database using the db link?
    Thanks,
    Dnyanesh

    yes, I can connect to the remote database directly and create/modify the packages.
    But I want the users not to create them using the db link.
    Is there any way to create the pl/sql package over database link?
    Thanks,
    Dnyanesh

  • Interactive report performance problem over database link - Oracle Gateway

    Hello all;
    This is regarding a thread Interactive report performance problem over database link that was posted by Samo.
    The issue that I am facing is when I use Oracle function like (apex_item.check_box) the query slow down by 45 seconds.
    query like this: (due to sensitivity issue, I can not disclose real table name)
    SELECT apex_item.checkbox(1,b.col3)
    , a.col1
    , a.col2
    FROM table_one a
    , table_two b
    WHERE a.col3 = 12345
    AND a.col4 = 100
    AND b.col5 = a.col5
    table_one and table_two are remote tables (non-oracle) which are connected using Oracle Gateway.
    Now if I run above queries without apex_item.checkbox function the query return or response is less than a second but if I have apex_item.checkbox then the query run more than 30 seconds. I have resolved the issues by creating a collection but it’s not a good practice.
    I would like to get ideas from people how to resolve or speed-up the query?
    Any idea how to use sub-factoring for the above scenario? Or others method (creating view or materialized view are not an option).
    Thank you.
    Shaun S.

    Hi Shaun
    Okay, I have a million questions (could you tell me if both tables are from the same remote source, it looks like they're possibly not?), but let's just try some things first.
    By now you should understand the idea of what I termed 'sub-factoring' in a previous post. This is to do with using the WITH blah AS (SELECT... syntax. Now in most circumstances this 'materialises' the results of the inner select statement. This means that we 'get' the results then do something with them afterwards. It's a handy trick when dealing with remote sites as sometimes you want the remote database to do the work. The reason that I ask you to use the MATERIALIZE hint for testing is just to force this, in 99.99% of cases this can be removed later. Using the WITH statement is also handled differently to inline view like SELECT * FROM (SELECT... but the same result can be mimicked with a NO_MERGE hint.
    Looking at your case I would be interested to see what the explain plan and results would be for something like the following two statements (sorry - you're going have to check them, it's late!)
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two),
    sourceqry AS
    (SELECT  b.col3 x
           , a.col1 y
           , a.col2 z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5)
    SELECT apex_item.checkbox(1,x), y , z
    FROM sourceqry
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two)
    SELECT  apex_item.checkbox(1,x), y , z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5If the remote tables are at the same site, then you should have the same results. If they aren't you should get the same results but different to the original query.
    We aren't being told the real cardinality of the inners select here so the explain plan is distorted (this is normal for queries on remote and especially non-oracle sites). This hinders tuning normally but I don't think this is your problem at all. How many distinct values do you normally get of the column aliased 'x' and how many rows are normally returned in total? Also how are you testing response times, in APEX, SQL Developer, Toad SQLplus etc?
    Sorry for all the questions but it helps to answer the question, if I can.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • Report over database link error

    Good morning all.
    I have a database link LINKA from USERA on LOCALSERVER to USERB on REMOTESERVER.
    (create database link LINKA connect to USERB identified by mypassword using validtns)
    In USERC on REMOTESERVER I have a TABLEX, with grant all on TABLEX to USERB on REMOTESERVER.
    In USERB on REMOTESERVER I have a view TABLEXV, select * from USERC.TABLEX
    From USERA on LOCALSERVER I can select * from TABLEXV@LINKA. In fact I can insert/update/delete tablexv from USERA.
    I also have a view TABLEXV on USERA, select * from TABLEXV@LINKA. I can also select/insert/update/delete from USERA.TABLEXV.
    So far so good - all working as expected.
    Then, my APEX app on LOCALSERVER, interactive report, parsing schema USERA, querying TABLEXV, I get the following:
    when "Exclude Link Column", I get the error "The requested URL /pls/apex/f was not found on server.
    when "Link to Single Row View", report displays correctly.
    when "Link to Custom Target", I get the error "The requested URL /pls/apex/f was not found on server.
    When I run the select * from TABLEXV as a regular report (i.e. not interactive), I also get the error.
    So the only time I get the report displayed correctly is using IR and "Link to Single Row View".
    However, clicking on the link (for Single Row View) I get "The requested URL /pls/apex/wwv_flow.show was not found on this server.".
    To summarize:
    - accessing table via view over database link
    - works outside of apex without issue
    - inside only works when Link to Single Row View set
    - But clicking on link fails
    I could live with just having the Link to Singe Row View option if I could disable displaying of the icon so that the user cant click on it.
    APEX 3.2.00.27
    EE Database - 10.2.0.3 (yes I know out of support)
    Remote EE Database - 10.2.0.5
    Real object names replaced to protect the innocent!
    Anyone got any clues?
    I have used remote tables many times in my APEX applications and never had this issue.
    Thanks,
    Rob @ very confused .com

    Good morning all.
    I have a database link LINKA from USERA on LOCALSERVER to USERB on REMOTESERVER.
    (create database link LINKA connect to USERB identified by mypassword using validtns)
    In USERC on REMOTESERVER I have a TABLEX, with grant all on TABLEX to USERB on REMOTESERVER.
    In USERB on REMOTESERVER I have a view TABLEXV, select * from USERC.TABLEX
    From USERA on LOCALSERVER I can select * from TABLEXV@LINKA. In fact I can insert/update/delete tablexv from USERA.
    I also have a view TABLEXV on USERA, select * from TABLEXV@LINKA. I can also select/insert/update/delete from USERA.TABLEXV.
    So far so good - all working as expected.
    Then, my APEX app on LOCALSERVER, interactive report, parsing schema USERA, querying TABLEXV, I get the following:
    when "Exclude Link Column", I get the error "The requested URL /pls/apex/f was not found on server.
    when "Link to Single Row View", report displays correctly.
    when "Link to Custom Target", I get the error "The requested URL /pls/apex/f was not found on server.
    When I run the select * from TABLEXV as a regular report (i.e. not interactive), I also get the error.
    So the only time I get the report displayed correctly is using IR and "Link to Single Row View".
    However, clicking on the link (for Single Row View) I get "The requested URL /pls/apex/wwv_flow.show was not found on this server.".
    To summarize:
    - accessing table via view over database link
    - works outside of apex without issue
    - inside only works when Link to Single Row View set
    - But clicking on link fails
    I could live with just having the Link to Singe Row View option if I could disable displaying of the icon so that the user cant click on it.
    APEX 3.2.00.27
    EE Database - 10.2.0.3 (yes I know out of support)
    Remote EE Database - 10.2.0.5
    Real object names replaced to protect the innocent!
    Anyone got any clues?
    I have used remote tables many times in my APEX applications and never had this issue.
    Thanks,
    Rob @ very confused .com

  • Error not getting while executing procedure via db link

    Hi,
    I am executing a database procedure remotely via database link from SQL prompt (SQL > EXECUTE REPLICATE_DATA@DBLK_SALE), and while getting any connectivity issue system is not giving any error (it is just showing as not responding)..
    if I am executing the same procedure directly in the remote database then it is giving error as
    ORA-02055: distributed update operation failed; rollback required
    ORA-02068: following severe error from DBLK_SALE
    ORA-03135: connection lost contact
    Can someone can help me on this
    Regards

    Dear 823755,
    You can think the Database link as a new sqlplus session to the distributed database. You should have defined a user to connect to that remote database and the user has to have the necessary privileges to revoke the relevant object. Does it have that privilege? Can you even connect to the remote database instance?
    SQL> SELECT * FROM DUAL@DBLK_SALE;Regards.
    Ogan

  • Stored procedure with database link with "from table(...)"

    Hi guys,
    I've been told I can't create views on a database by the design team and so have to use this stored procedure to obtain the values.
    select HAN_ID, HAN_DS, GLOBAL_IN, LOCAL_IN
    from table(cast(ODADMIN.ODP00002_QUERY.Execute001@DBLINK(11312,'EN') as
    ODADMIN.ODP00002_001_Array@DBLINK)) WHERE LOCAL_IN = 'Y';I've been told that it works when you remove the database links (so on the actual database) when you remove the cast part. I've tried it with my link and with/without the cast part but it doesn't work. With the example above I get the error: ORA-00907: missing right parenthesis.
    When I remove the CAST-AS and the additional parenthesis it brings i get the error: ORA-00904: "ODADMIN"."ODP00002_QUERY"."EXECUTE001": invalid identifier
    When I do table( *"* ODADMIN.ODP00002_QUERY.Execute001@MWW_DEV(11312,'EN') *"* )... -- wrapping the call in speech marks I get: ORA-00972: identifier is too long
    Anyone see what's wrong? Thanks for any help.
    Mike

    Hi Ben,
    Asking now. By a view I mean one local to the database; I could create one on APEX but then I use the database link twice instead of just 1.
    His reasoning Ben:
    Firstly, Maintenance. We will have to maintain additional views (at additional code). Secondly, if the view has a JOIN, then you can't update through it (without complexities). If we have to get the View to pass the data to a Procedure (that's a pain). Also, standards..
    All update occur via either a Procedure, or a Base view, across over 1000 tables
    That's the standard, and doing things differently is costly long term
    People will not know how it works, it will have to be explained, maintained..etc.
    If the Application has the Business Rules, then updates via Base Views, that's a more standard way of developing. Also, if you update via this view, you'll update multiple rows in one call, which is in-effficient if only ONE row needs to change. Therefore, single row updates from the Application is more efficient
    The procedure is as follows:
    --SET SERVEROUTPUT ON
    DECLARE
    nPBusLoc       NUMBER(5):=11312;
    sPHanId        VARCHAR2(3):='SB1';
    sPLngId        VARCHAR2(2):='EN';
    sPDesc         VARCHAR2(30);
    sPAllowAlloc   VARCHAR2(1);
    sPShowEnq      VARCHAR2(1);
    sPAllowDel     VARCHAR2(1);
    sPShowScan     VARCHAR2(1);
    sPGlobalLocal  VARCHAR2(1);
    sPReturnCd     VARCHAR2(2);
    sPReturnTx     VARCHAR2(100);                  
    BEGIN
    ODADMIN.ODP00001.getHandlingCodes
                           (nPBusLoc    --  IN   NUMBER
                          ,sPHanId      -- IN   VARCHAR2
                          ,sPLngId      -- IN   VARCHAR2
                          ,sPDesc       -- OUT  VARCHAR2
                          ,sPAllowAlloc -- OUT  VARCHAR2
                          ,sPShowEnq    -- OUT  VARCHAR2
                          ,sPAllowDel   -- OUT  VARCHAR2
                          ,sPShowScan   -- OUT  VARCHAR2
                          ,sPGlobalLocal-- OUT  VARCHAR2
                          ,sPReturnCd   -- OUT  VARCHAR2
                          ,sPReturnTx   -- OUT  VARCHAR2                                    
    DBMS_OUTPUT.PUT_LINE('nPBusLoc                 = '||nPBusLoc              );
    DBMS_OUTPUT.PUT_LINE('sPHanId                  = '||sPHanId               );
    DBMS_OUTPUT.PUT_LINE('sPLngId                  = '||sPLngId               );
    DBMS_OUTPUT.PUT_LINE('sPDesc                   = '||sPDesc                );
    DBMS_OUTPUT.PUT_LINE('sPAllowAlloc             = '||sPAllowAlloc          );
    DBMS_OUTPUT.PUT_LINE('sPShowEnq                = '||sPShowEnq             );
    DBMS_OUTPUT.PUT_LINE('sPAllowDel               = '||sPAllowDel            );
    DBMS_OUTPUT.PUT_LINE('sPShowScan               = '||sPShowScan            );
    DBMS_OUTPUT.PUT_LINE('sPGlobalLocal            = '||sPGlobalLocal         );
    DBMS_OUTPUT.PUT_LINE('sPReturnCd               = '||sPReturnCd            );
    DBMS_OUTPUT.PUT_LINE('sPReturnTx               = '||sPReturnTx            );
    END;
    /Mike
    Edited by: Dird on 27-Aug-2009 01:50

  • Calling remote procedure through database link

    Hi,
    I have a procedure in a package with a type I delcared as follows:
    Database1 :
    create or replace package p1
    is
    TYPE dependents_rec IS RECORD (
    name VARCHAR2 (80),
    dob date);
    TYPE dependents IS TABLE OF dependents_rec
    INDEX BY BINARY_INTEGER;
    procedure proc1 (p_id in number,
    p_dependents out dependents );
    end;
    On another database database2 i want to call the above procedure from within a procedure in a package that works as a wrapper package with similar structure.
    I recieve the error "Wrong number or types of parameters" error because type dependents is not the same as within the package in database 1.
    How can I call the procedure p1.proc1 over a database link ?
    Thank you

    Hi,
    On database1:
    CREATE OR REPLACE PACKAGE types_pkg is
    TYPE dependents_rec IS RECORD (
    NAME VARCHAR2 (80),
    sex NUMBER (1),
    birth_date DATE,
    birth_place NUMBER (3),
    status NUMBER (1),
    unique_id VARCHAR2 (15)
    TYPE dependents IS TABLE OF dependents_rec
    INDEX BY BINARY_INTEGER;
    end;
    CREATE OR REPLACE PACKAGE wrapper_pkg_demo
    AS
    PROCEDURE read_person_no (
    p_person_id NUMBER,
    p_dependent_info OUT types_pkg.dependents
    END;
    CREATE OR REPLACE PACKAGE BODY wrapper_pkg_demo
    AS
    PROCEDURE read_person_no (
    p_person_id NUMBER,
    p_dependent_info OUT types_pkg.dependents
    IS
    BEGIN
    person_pkg.read_person_no (p_person_id, p_dependent_info);
    END;
    END;
    On database 2:
    CREATE OR REPLACE PACKAGE person_pkg
    AS
    PROCEDURE read_person_no (
    p_person_id NUMBER,
    p_dependent_info OUT types_pkg.dependents@database1
    END;
    CREATE OR REPLACE PACKAGE body person_pkg
    AS
    PROCEDURE read_person_no (
    p_person_id NUMBER,
    p_dependent_info OUT types_pkg..dependents@database1
    IS
    BEGIN
    null;
    END;
    END;
    When compiling the package body on database 1
    ORA-04052: error occurred when looking up remote object TYPES@MOI
    ORA-00604: error occurred at recursive SQL level 1
    ORA-02019: connection description for remote database not found
    Noting that the database link are working properly and when compiling the package on database 2, it compile successfully
    Thank you

  • Unable to execute Map from Database link

    Hi
    Been trying to research this issue but have had no luck in finding an answer. Here is the situation:
    We have an apex application that resides on database "A"
    Our OWB Design Repository (11.1.0.7) and Runtime Environment both exist on database "B"
    Maps exists and execute under normal procedures as the "ETL" user on database "B", However we would like to allow the "APEX" user to execute a map from database "A" across a database link to a user that can execute the map without any issue.
    When we try to execute the map across the database link from toad or sqlplus we get no error returned, the procedure runs and kicks off a map execution (as seen in ALL_RT_AUDIT_EXECUTIONS) or from the control center executions. However the Map execution immediately fails with no explanation as to why??
    what makes even less sense is that the user on database "B" that the database link connects to.. can execute the same procedure all day long if logged directly into database "B".. but the moment you try to call it across the database link.. it errors with no message as to why.
    We are calling the "WB_WORKSPACE_MANAGEMENT.SET_WORKSPACE".. so that is not the issue.. I am assuming this is either a bug.. or we are missing an additional call/privilege. The user for the database link is a registered user in the workspace, obviously this works since the database link user can run the procedure if logged in locally to database "B"
    Any thoughts???

    Figured out our problem..
    Found RETURN_CODE column in ALL_RT_AUDIT_EXECUTIONS table.. point to -2064 which is an ora-2064
    NOTE 1026597.6 - CALLING REMOTE PACKAGE RECEIVES ORA-2064 explains that a commit is issued in a coordinated session from an RPC procedure call with OUT parameters or function call. Action: simplify remote update statement.
    The problem here is that "Commit Control" was set to Automatic for the mappings we were calling. Oracle does not like when a transaction is initiated on database "A" and has a commit issued on database "B" from the map.
    Makes sense.. we switched the commit control to "Manual" and are able to process correctly by issuing a commit from the session on database "A"
    Hope this helps anyone that runs into this issue themselves..

  • Run process flow over database link

    Hi guys,
    I have two projects here, A and B. Each project has its own process flow, lets say Process A (in project A)and process B(in project B). I need to run process B in process A, so I use the database link, and WB_RT_API_EXEC.run_task function. But when I run the process, I get the following error:
    ORA-20001: Task not found - Please check the Task Type, Name and Location are correct.
    ORA-06512: at "OWBRTR2.WB_RT_API_EXEC", line 704
    does anyone have some idea how to fix this? or any other suggestions for how to do it? thanks.

    Hi Gowtham,
    I am using the following function to send execution details of the process-flow. This process-flow is having 20 mappings. This is working fine.
    The cIient requirment is to pass email-IDs from a back-end table(sam_mail_notification) with columns(smtp, from_address and to_address), right now the function is working on static(constant) values.
    I had modified the function according to the requirement, can you please have a look at the function, and tell me is it correct. Because the values should come from database table. will this function work.
    I got the following error, while deploying,
    ORA-06550: line 55, column 1:
    PLS-00103: Encountered the symbol "END" when expecting one of the following:
    FUNCTION SEND_SUMMARY1()
    RETURN NUMBER
    --initialize variables here
    -- main body
    retval number := 0; --default
    crlf CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
    pSender VARCHAR2(30) := '[email protected]';
    pRecipient VARCHAR2(30) := '[email protected]';
    pSubject VARCHAR2(100) := 'Process REsults for: '||to_char(sysdate,'dd/mm/yyyy');
    mesg VARCHAR2(32767);
    mail_conn utl_smtp.connection;
    cursor getResults is
    select AREA.OBJECT_NAME,
    AREA.CREATED_ON,
    AREA.UPDATED_ON,
    aramr.ELAPSE_TIME,
    NUMBER_RECORDS_SELECTED,
    NUMBER_RECORDS_INSERTED,
    NUMBER_RECORDS_UPDATED,
    NUMBER_ERRORS,
    AREA.RETURN_RESULT,
    AREA.EXECUTION_AUDIT_STATUS,
    MESSAGE_SEVERITY,
    MESSAGE_TEXT
    from
    all_Rt_audit_executions area,
    all_Rt_audit_map_runs aramr,
    all_rt_audit_exec_messages err
    where AREA.execution_audit_id = ARAMR.execution_audit_id(+) AND
    AREA.execution_audit_id = err.execution_audit_id(+)
    and
    trunc(area.created_on) = trunc(sysdate)
    AND AREA.OBJECT_NAME IS NOT NULL AND AREA.TASK_TYPE!='ProcessFlow'
    AND area.top_level_execution_audit_id =(select max(top_level_execution_audit_id)from all_Rt_audit_executions
    where execution_name = (select execution_name from all_Rt_audit_executions where task_type ='ProcessFlow' and top_level_execution_audit_id =
    (select max(top_level_execution_audit_id) from all_Rt_audit_executions)));
    Cursor getMailDetails is select
    mailhost
    pSender,
    pRecipient
         from sam_mail_notification;
    BEGIN
    for maild in getMailDetails
    loop
    mail_conn := utl_smtp.open_connection(mailhost, 25);
    mesg := 'Date: ' ||TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss') || crlf ||
    'From: <'|| pSender ||'>' || crlf ||
    'Subject: '|| pSubject || crlf ||
    'To: '||pRecipient || crlf || '' || crlf ||
    end loop;
    'MAPNAME START_TIME END_TIME ELAPSED SELECTED INSERTED UPDATED ERRORS RESULT AUDIT_STSTUS SEVERITY MESSAGE_TEXT'||crlf ;
    for rec in getResults
    loop
    mesg:=mesg || rpad(rec.OBJECT_NAME,30)||
    rpad(to_char(rec.CREATED_ON, 'HH24:MI:SS DD-MON-YY'),20)||
    rpad(to_char(rec.UPDATED_ON, 'HH24:MI:SS DD-MON-YY'),24)||
    rpad(to_char(rec.ELAPSE_TIME),7)||
    rpad(to_char(rec.NUMBER_RECORDS_SELECTED),8)||
    rpad(to_char(rec.NUMBER_RECORDS_INSERTED),10)||
    rpad(to_char(rec.NUMBER_RECORDS_UPDATED),10)||
    rpad(to_char(rec.NUMBER_ERRORS),5)||
    rpad(to_char(rec.RETURN_RESULT),8)||
    rpad(to_char(rec.EXECUTION_AUDIT_STATUS),10)||
    rpad(to_char(rec.MESSAGE_SEVERITY),10)||
    rpad(to_char(rec.MESSAGE_TEXT),200)||crlf;
    end loop;
    utl_smtp.helo(mail_conn, mailhost);
    utl_smtp.mail(mail_conn, pSender);
    utl_smtp.rcpt(mail_conn, pRecipient);
    utl_smtp.data(mail_conn, mesg);
    utl_smtp.quit(mail_conn);
    return retval;
    EXCEPTION
    WHEN OTHERS THEN
    return 1;
    END;
    Regards,
    Kumar

  • Column reference over database link.

    Hi,
    Is it possible to reference a table column across a database link?
    Ex: var1 table.column%TYPE@dblink
    Thanks
    Chad

    Chad,
    Glad it worked ..
    Taking this thread a step further ..
    If you have the privileges to create synonyms then you could do the following:
    create synonym mySynonym
    for table@dblink
    Then use the synonym in the PL/SQL code as follows:
    var1 mySynonym.column%TYPE;
    This will avoid repetitive typing of table.column@dblink and if the dblink name changes then you have to make the change in only one place - the synonym
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • Slow Query over Database Link with Bind Variable

    I have a query over a DB link, with all tables on the remote database.
    If I use a bind variable (from Toad), the query takes 4 minutes. If I replace the bind variable with a constant or substitution variable, it takes 1 second.
    The query runs fine when run directly on the remote database using bind variable.
    9.2.0.7

    Look up "Bind variable peeking"
    What's happened is you have an execution plan that differs from the one with the constant. Why? My bet is that Oracle "peeked" at the bind variable to help it decide which execution plan to build. It then cached it. It probably cached an execution with an index when it should be doing a full table scan or a hash join instead of a nested loop. It's hard to say specifically what it is.
    Try this, flush your shared pool and rerun the query with the bind and let us know if it takes 1 second or 4 minutes. If it takes 1 second, then that was probably it.
    Read part 2 of Tom Kyte's blog post on what it is and it's behavior.
    http://tkyte.blogspot.com/2007/09/sqltracetrue-part-two.html

  • Interactive report performance problem over database link

    Hi gurus,
    I have an interactive report that retrieves values from two joined tables both placed on the same remote database. It takes 45 seconds to populate (refresh) a page after issuing a search. If I catch the actual select that is generated by apex ( the one with count(*) over ()...) and run it from sql environment, it takes 1 or 2 seconds. What on earth does consume the rest of the time and how to speed this up? I would like to awoid creating and maintaining local materialized views if possible.
    Regards
    Samo

    Hi
    APEX normally needs to return the full result set for the purposes of pagination (where you have it set to something along the lines of show x-y of z), changing this or the max row count can affect performance greatly.
    The driving site hint would need to refer to the name of the view, but can be a bit temperamental with this kind of thing. The materialize hint only works for sub-factored queries (in a 'WITH blah AS(SELECT /*+ MATERIALIZE */ * FROM etc. etc.)). They tend to materialize anyway and its best not to use hints like that for production code unless there is absolutely no other option, but just sub factoring without hints can often have a profound effect on performance. For instance
    WITH a AS
    SELECT c1,
            c2,
            c3,
            c4,
            c5
    FROM schema1.view1)
    , b AS
    SELECT c1,
            c2,
            c3
    FROM schema1.view2)
    SELECT *
    FROM a, b
    WHERE a.c5 = b.c3May produce a different plan or even just sub factoring one of the external tables may have an effect.
    You need to try things out here and experiment and keep looking at the execution plans. You should also change Toads row fetch setting to be all 9's to get a real idea of performance.
    Let me know how you get on.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)
    Edited by: Munky on Sep 29, 2009 1:41 PM

  • Remote call to a procedure over DB Link - Datatype mismatch

    Hi All,
    I've a procedure taking an array as input parameter. I invoked this procedure from other DB using a DB link but got DATATYPE mismatch error. I've given same name to the array type in both the DBs and used the same UID.
    Please help me out.
    Regards,
    MK
    CREATE OR REPLACE TYPE type_market_places IS table OF VARCHAR2 (100);
    CREATE OR REPLACE PROCEDURE racsf_populate_site (p_in_mrktplaces type_market_places)
    IS
       --lv_sql   VARCHAR2 (32000);
    BEGIN
    END;
    ------Invoking the procedure from the other DB using DB link
    DECLARE
      P_IN_MRKTPLACES type_market_places;
    BEGIN
      select col1 bulk collect into P_IN_MRKTPLACES;
      RACSF_POPULATE_SITE@DB_link ( P_IN_MRKTPLACES );
      COMMIT;
    END;

    You call DATA TYPE from DB_link datatype
    try this, please
    DECLARE
      P_IN_MRKTPLACES type_market_places@DB_link;
    BEGIN
      select col1 bulk collect into P_IN_MRKTPLACES;
      RACSF_POPULATE_SITE@DB_link ( P_IN_MRKTPLACES );
      COMMIT;
    END;

  • Select query over database link hanging

    Hi All,
    I have been looking all over the internet and all over this forum but i could not find the solution for my issue given below.
    There are a number of distributed databases (Oracle 10g) over a private network. Sending and receiving data amongst all the databases work fine. But when one particular database A tries to receive data from database B, it hangs and then the famous old error TNS LOST CONTACT.
    Basically, this has been implemented by creating a batchjob. This worked fine for years and now suddenly this is not working only for the two specific databases.
    It is just a simple select query being hit on the remote database. This is called through a function in the package, which builds the dynamic select query using DBMS_SQL package.
    It actually hangs when doing DBMS_SQL.PARSE ();
    The same function when called in a pl/sql block from database A, works perfectly fine and receives the required data from database B. This was tried with Oracle SQLDeveloper, TOAD and SQLPLUS.
    Things seems to be working fine, but actually unaware of the problem. I tried all the suggestions provided over the metalink also.
    Require your help urgently.
    Thanks
    Akhil.

    Hi Rajat,
    The user uses DEFAULT profile. The details of the parameter are:
    PROFILE RESOURCE_NAME RESOURCE_TYPE LIMIT
    DEFAULT COMPOSITE_LIMIT KERNEL UNLIMITED
    DEFAULT SESSIONS_PER_USER KERNEL UNLIMITED
    DEFAULT CPU_PER_SESSION KERNEL UNLIMITED
    DEFAULT CPU_PER_CALL KERNEL UNLIMITED
    DEFAULT LOGICAL_READS_PER_SESSION KERNEL UNLIMITED
    DEFAULT LOGICAL_READS_PER_CALL KERNEL UNLIMITED
    DEFAULT IDLE_TIME KERNEL UNLIMITED
    DEFAULT CONNECT_TIME KERNEL UNLIMITED
    DEFAULT PRIVATE_SGA KERNEL UNLIMITED
    DEFAULT FAILED_LOGIN_ATTEMPTS PASSWORD 10
    DEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITED
    DEFAULT PASSWORD_REUSE_TIME PASSWORD UNLIMITED
    DEFAULT PASSWORD_REUSE_MAX PASSWORD UNLIMITED
    DEFAULT PASSWORD_VERIFY_FUNCTION PASSWORD NULL
    DEFAULT PASSWORD_LOCK_TIME PASSWORD UNLIMITED
    DEFAULT PASSWORD_GRACE_TIME PASSWORD UNLIMITED
    Thanks
    Akhil

Maybe you are looking for

  • Regarding Renaming INDEX Partitions

    Hi All, I have the following syntax for renaming table partitions/subpartitions : ALTER TABLE SMTP_MSG_TRAFFIC_FCT RENAME PARTITION FOR (20100310) TO BASE_FACT_20100310; ALTER TABLE SMTP_MSG_TRAFFIC_FCT RENAME SUBPARTITION FOR (20100310,19) TO BASE_F

  • Invalid identifier results from an sql statement in php

    hello there, i'm trying to access data from an oracle 11g database via oci and php 5.3.8. i'm getting the ORA-00904 (invalid identifier) error when executing the following statement: $stid = oci_parse($conn, 'select * from table1 where column1 = "XYZ

  • Calling WS from WebLogic server 8.1 that is behind a Proxy server

    Hi, I have a web application deployed on WebLogic server 8.1 sp1. And my server is behind a http proxy server. Now one of the components in the application makes a web service call to a service located external to the system, and it always throws "ja

  • Patch Policy for EBS

    Does anyone have a comprehensive list of all technology that requires security patching in the oracle EBS and supporting infrastructure? I'd prefer comments as opposed to endless links. And possibly if you could provide a split of what Oracle will pa

  • Having install issue: acrobat pro xi (trial)

    I keep having problems installing acrobat pro xi trial version. Initially the error code I got was Error 16...after numerous re-install attempts the installation is interrupted and I am forced to hit "Finished" to exit from the install window.  If I