DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: execute immediate proc

  1. #1
    Join Date
    May 2006
    Posts
    6

    execute immediate proc

    I have a table called planet_a1 with columns
    module_name
    query_to_get_expected_results
    query_to_get_actual_results
    query_to_get_diff


    I must write a procedure that gets the module name
    query the expected results
    query the actual results
    and get the diff
    if diff is greater than zero
    then email diff

    is this proc below correct? Please advise

    declare
    l_module pls_integer := 'LFACS_REFRESH';
    l_expected number(2);
    l_actual number(2);
    l_diff number(2);

    cursor get_values is
    select * from planet_al;

    for i in v_cursor
    loop

    begin
    execute immediate 'select i.expected_query_results'
    into l_expected
    using l_module ;

    execute immediate 'select i.query_actual_results'
    into l_actual
    using l_module;

    execute immediate 'select i.query_to_get_diff'
    into l_diff
    using l_module;


    if l_diff > 0
    then

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    is this proc below correct? Please advise
    NO.

    Why don't you try it?
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

  3. #3
    Join Date
    Nov 2003
    Location
    Ohio
    Posts
    51
    Something like this might be a little closer to what you want.
    You can search asktom.oracle.com for examples on how to handle email from plsql.

    It's not clear from your post what 'LFACS_REFRESH' is or if
    it's even needed. I'm assuming that the planet_a1 table is
    already populated with the expected and actual results and the
    difference. I'm assuming there's only one entry in the table
    per module since you provide no information about it.

    begin

    for i in (select * from planet_al)
    loop

    if i.query_to_get_diff > 0
    then

    -- send email

    end if;

    end loop;

    end;
    ____________________
    Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width