How can I execute Dynamic SQL statement in Forms?

Hi All,
I have to execute dynamic SQL statement from Forms
Below statement I have to execute
"EXECUTE IMMEDIATE v_stmt INTO v_return;".
Googled for the same got results saying, Better use Database function or procedures to execute these Dynamic Statements but We want to execute in forms only.
Can any one help me..
Thanks,
Madhu

So in short you are trading code obfuscation for maintainability and the ability to share code between tools? If from somewhere else you need a procedure already implemented in database PL/SQL (and now ported to forms) this would mean you'd need to implement it in every other tool. In times where you might want to integrate your forms with $other_technology and putting stuff on the database is the first step to share functionality you just go the opposite way? And all that because someone is afraid that somebody might steal your source code? I am sorry to be blunt, but this is just plain stupid.
Leaving aside that some things like Analytic Functions, Bulk processing or execute immediate are not even available in forms your software consists of how many LOC? How long does it take to bring a new developer up to speed with your source code? Imagine how long that would take for a developer who doesn't have coleagues who know their way around.
And just so you know: I work for a ISV selling a closed-source product as well. We have 200+ customers all over the planet. We are well aware that wrapped packages can be reverse engineered. The premise is: stored procedures can be reused in every tool we have, if it makes sense to put stuff on the database by all means do it. If someone would want to reverse engineer our software I'd wish him good luck as some parts are implemented in such a hilarious complicated way I have troubles understanding them (and quite frankly I refuse to understand certain parts, but that's another story). I do work for almost 10 years for that ISV.
In any case the possible solutions have already been mentioned: you have exec_sql, create_group_from_query and forms_ddl to execute dynamic SQL in forms whereas forms_ddl is a one way street and most certainly not the thing you need or want. Take a look at the documentation for the other 2 things.
cheers

Similar Messages

  • How can I write a SQL statement which checks if a table exists?

    How can I write a SQL statement which tells me whether a table exists?

    execute an sql query: select * from <tablename>
    catch the exception n check whether the erroe code
    matches the one that occurs for table doesn't exist
    that's itHow is your answer any different from the one given in the first reply?
    It isn't.
    As WorkForFood says DatabaseMetaData has a bunch of methods for getting information about tables but this is more useful when you don't know the names of any of the tables.. it sounds like you do so I would concur SELECT from table is probably the quickest way to go. If it helps the Xopen error should be either S1000 or 42S01 (I think) but I would try and see if there is a specific vendor code for table not found/not exists error and check for that.

  • How can i use one SQL statement to solve problem?

    How can i use one SQL statement to solve the question below?
    For a Table named A, there is a column named F(char type).
    Now select all the records where F like '%00' and update their F value to '%01'
    Just one SQL statement.Do not use PL/SQL block.
    How to do that?
    Thanks.

    What is the data volume for this table?
    Do you expect lots of rows to have '%00' as their value?
    Following two statements come to mind. Other experts would be able to provide better alternatives:
    If you have index on SUBSTR(f, 2):
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) || '01'
    WHERE  substr(f,
                  -2) = '00';If most of the rows have pattern '%00':
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) ||
               DECODE(SUBSTR(f,
                             -2),
                      '00',
                      '01',
                      SUBSTR(f,
                             -2));

  • Execute Dynamic SQL statement using procedure builder

    i want to execute a dynamic SQL statment using procedure builder not using forms
    because my statement depending on a variable table name
    i know that i can do that from forms using
    FORMS_DDL('SQL_STAT');
    but i wanna to use the procedure builder
    which function i should use and how?
    please explain in example if you don't mind.
    thanks

    Hi,
    You can very well use DBMS_SQL Package supplied by Oracle for doing this.
    Search for DBMS_SQL in OTN. You will get all info regarding this.
    Regards.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by itslul:
    i want to execute a dynamic SQL statment using procedure builder not using forms
    because my statement depending on a variable table name
    i know that i can do that from forms using
    FORMS_DDL('SQL_STAT');
    but i wanna to use the procedure builder
    which function i should use and how?
    please explain in example if you don't mind.
    thanks<HR></BLOCKQUOTE>
    null

  • Execute dynamic sql  statement

    Hi all
    CREATE TABLE  XX_OFFICE_USER_IMP
        ID              NUMBER,
        OFFICE          VARCHAR2(10 BYTE),
        USER_NAME       VARCHAR2(10 BYTE),
        BANK_ACCOUNT_ID NUMBER,
        TRANSFERED      NUMBER
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (421,'0000','F0000',10029,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (422,'0000','F0000',10031,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (423,'0000','F0000',10033,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (424,'0000','F0000',10036,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (425,'0000','F0000',10037,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (426,'0000','F0000',10039,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (427,'0000','F0000',10041,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (428,'0000','F0000',10046,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (429,'0000','F0000',10048,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (430,'0000','F0000',10067,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (431,'0000','F0000',10072,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (432,'0000','F0000',10087,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (433,'0000','F0000',10092,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (434,'0000','F0000',10008,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (435,'0000','F0000',10012,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (436,'0000','F0000',10013,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (437,'0000','F0000',10014,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (438,'0000','F0000',10017,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (439,'0000','F0000',10019,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (440,'0000','F0000',10024,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (441,'0000','F0000',10025,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (442,'0000','F0000',10001,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (443,'0000','F0000',10002,null);
    CREATE TABLE XXBG_CASIER_CASH
        CASHIER         VARCHAR2(32 BYTE),
        BANK_ACCOUNT_ID NUMBER(38,0)
    declare
    v_exe_grant varchar2(32767 char);
    begin
    for i in (select * from xx_office_user_imp where office = '0000') loop
      insert into XXBG_CASIER_CASH values (i.user_name, i.bank_account_id);
      v_exe_grant :=
                     'create user '  || i.user_name || ' identified by ' || i.user_name || ';'
                  || 'GRANT create session to ' || i.user_name || ';'
                  || 'GRANT select on apps.XXBG_CE_STATEMENT_HEADERS_CASH to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.FND_USER TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.dFND_DESCR_FLEX_COL_USAGE_TL TO ' || i.user_name || ';'
                  || 'GRANT select on apps.fnd_descr_flex_column_usages to ' || i.user_name || ';'
                  || 'GRANT select on apps.fnd_descriptive_flexs to ' || i.user_name || ';'
                  || 'GRANT select on apps.fnd_descriptive_flexs_tl to ' || i.user_name || ';'
                  || 'GRANT select on ce.ce_statement_headers to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.fnd_doc_sequence_assignments TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.CE_STATEMENT_HEADERS_S TO ' || i.user_name || ';'
                  || 'GRANT EXECUTE ON APPS.XXBG_GET_NEXTVAL TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.CE_STATEMENT_LINES TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_CE_STATEMENT_LINES TO ' || i.user_name || ';'
                  || 'GRANT select on apps.CE_BANK_ACCOUNTS to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.CE_BANK_BRANCHES_V TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.XXBG_CASIER_CASH TO ' || i.user_name || ';'
                  || 'GRANT EXECUTE ON APPS.XXBG_ST TO ' || i.user_name || ';'
                  || 'GRANT select on ce.xxbg_ce_statement_lines_detail to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.ce_transaction_codes TO ' || i.user_name || ';'
                  || 'GRANT select on ce.ce_statement_lines_s to ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.XXBG_CE_STATEMENT_LINES_DET_SQ TO ' || i.user_name || ';'
                  || 'GRANT select on apps.xx_pko_lines to ' || i.user_name || ';'
                  || 'GRANT SELECT ON apps.xx_rko_lines TO ' || i.user_name || ';'
                  || 'GRANT select on apps.XX_INVOICE_RELATIONS_CASH to ' || i.user_name || ';'
                  || 'GRANT select on APPS.PO_VENDOR_SITES_ALL to ' || i.user_name || ';'
                  || 'GRANT select on ap.AP_INVOICE_LINES_INTERFACE_S to ' || i.user_name || ';'
                  || 'GRANT select on ap.AP_INVOICE_LINES_INTERFACE to ' || i.user_name || ';'
                  || 'GRANT select on APPS.ap_distribution_set_lines_all to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_INVOICES_INTERFACE_S TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_INVOICES_INTERFACE TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_DISTRIBUTION_SETS_ALL  TO ' || i.user_name || ';'
                  || 'GRANT select on apps.ce_lookups  to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_CUST_SITE_USES_ALL to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_LOCATIONS to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_PARTIES to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_PARTY_SITES to ' || i.user_name || ';'
                  || 'GRANT SELECT ON AR.HZ_CUST_ACCT_SITES_ALL TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON AR.HZ_CUST_ACCOUNTS TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_CLAIMS_V TO ' || i.user_name || ';'
                  || 'GRANT select on apps.xxbg_insis_agents_v to ' || i.user_name || ';'
                  || 'GRANT select on ce.xxbg_cash_doc_types to ' || i.user_name || ';'
                  || 'GRANT select on AP.AP_BANK_ACCOUNTS_ALL to ' || i.user_name || ';'
                  || 'GRANT SELECT ON AP.AP_BANK_BRANCHES TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.FND_DESCR_FLEX_CONTEXTS TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.FND_DESCR_FLEX_CONTEXTS_TL TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_SUPPLIERS to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.per_employees_x TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.fnd_doc_seq_categories_ap_v TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_LC_INVOICE_TYPES_V to ' || i.user_name || ';'
                  || 'GRANT SELECT ON ce.xxbg_ce_statement_lines_sq to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_STATEMENT_HEADERS_CASH to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_INSIS_POLICY_V TO ' || i.user_name || ';'
                  || 'GRANT insert  ON ce.ce_statement_lines to ' || i.user_name || ';'
                  || 'GRANT INSERT  ON CE.XXBG_CE_STATEMENT_LINES_DETAIL TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.AP_INVOICES_INTERFACE TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.AP_INVOICE_LINES_INTERFACE TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.XX_RKO_LINES TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.XX_PKO_LINES TO ' || i.user_name || ';'
                  || 'GRANT delete on ce.xxbg_ce_statement_lines_detail to ' || i.user_name || ';'
                  || 'GRANT update on ce.XXBG_CE_STATEMENT_LINES_DETAIL to ' || i.user_name || ';'
                  || 'GRANT DELETE ON CE.CE_STATEMENT_LINES TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON CE.CE_STATEMENT_HEADERS TO ' || i.user_name || ';'
                  || 'GRANT update on CE.CE_STATEMENT_HEADERS to ' || i.user_name || ';'
                  || 'GRANT update on ce.CE_STATEMENT_LINES to ' || i.user_name || ';'
                  || 'GRANT select on apps.XX_AGENTS_NO_V to ' || i.user_name || ';' ;
      execute immediate v_exe_grant;
    update xx_office_user_imp
      set transfered = 1
      where id = i.id
    v_exe_grant := '';
    end loop;
    end;
    /After execute the PL/SQL block i receive the error:
    Error report:
    ORA-00911: invalid character
    ORA-06512: at line 79
    00911. 00000 -  "invalid character"
    *Cause:    identifiers may not start with any ASCII character other than
               letters and numbers.  $#_ are also allowed after the first
               character.  Identifiers enclosed by doublequotes may contain
               any character other than a doublequote.  Alternative quotes
               (q'#...#') cannot use spaces, tabs, or carriage returns as
               delimiters.  For all other contexts, consult the SQL Language
               Reference Manual.
    *Action:Any ideas? I think i call execute immediate correctly.
    DB Version: 11g
    Unfortunately i cannot provide you with the sql of the other tables to create them.... Maybe you should try without all the grants... :)
    Thanks in advance,
    Bahchevanov.
    Edited by: bahchevanov on Oct 11, 2012 6:14 AM

    bahchevanov wrote:
    Any ideas? Sure. EXECUTE IMMEDIATE executes a single statment while you are trying to execute whole bunch. So use:
    execute immediate 'create user '  || i.user_name || ' identified by ' || i.user_name;
    execute immediate 'GRANT create session to ' || i.user_name;
    execute immediate 'GRANT select on apps.XXBG_CE_STATEMENT_HEADERS_CASH to ' || i.user_name;
    .SY.

  • How to execute multiple SQL statements thru frontend?

    With SQL Server database, you can execute multiple SQL statements.
    Ex.
    SQLCommand cmd = new SQLCommand();
    cmd.CommandText = "SELECT * FROM EMP; SELECT * FROM DEPT";
    cmd.ExecuteXXX();
    Note that for SQL Server, ";" (semocolon) is used as a separator.
    What separator is required for Oracle ? Or rather, can I execute multiple SQL statements against Oracle database (10g) ?
    (Why I want to do it is a totally diff. subject !)
    Thanks,
    Ami.

    Hello,
    You could use an anonymous PL/SQL block to batch multiple statements.
    If you want to use SELECT statements, you would open a REF CURSOR for each SELECT and return the REF CURSOR to your application. INSERT, UPDATE, and DELETE statements can just be passed as is.
    A simple REF CURSOR example might look like:
    begin
      open :v_refcursor1 for select * from emp;
      open :v_refcursor2 for select * from dept;
    end;Where v_refcursor1 and v_refcursor2 are parameters defined as a REF CURSOR type.
    Hope that helps a bit...
    - Mark

  • HOW CAN I EXECUTE DINAMIC SENTENCES FROM FORMS

    HOW CAN I EXECUTE DYNAMIC SENTENCES FROM FORMS.
    Ex.
    I would like to execute this commands from table SENTENCES
    COL1
    set_item_property (item1, enabled , property_true )
    set_item_property (item2, enabled , property_true )
    set_item_property (item3, enabled , property_false )
    Regards
    Message was edited by:
    jcruizcarrera
    Message was edited by:
    jcruizcarrera

    ... but you could imagine a sort of workaround...
    PROCEDURE Set_Item
        PC$Item     In Varchar2
       ,PN$Property In Number
       ,PC$Value    In Varchar2
    ) IS
    BEGIN
       Set_Item_Property( PC$Item, PN$Property, PC$Value ) ;
    END;That you can call like this:
      Set_Item( 'BL.BUTTON', LABEL, 'Hello' ) ;Francois

  • Need help on Dynamic SQL Cursor in Forms

    Hi All,
    I am trying to execute Dynamic SQL Cursor in forms using EXEC_SQL built in.
    I have a cursor for example:
    'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order
    My code is
    cur_num := Exec_SQL.Open_cursor;
    sql_order := 'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order;
    EXEC_SQL.PARSE(cursor_number, sql_order);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,1,ln_Supp_Id);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,2,ls_Suppl_Name,30);
    EXEC_SQL.DEFINE_COLUMN(cur_num ,24,ls_exchange,20);
      sql_count := EXEC_SQL.EXECUTE(cur_num );
      While EXEC_SQL.FETCH_ROWS(cur_num ) > 0 Loop
            EXEC_SQL.COLUMN_VALUE(cur_num ,1,ln_Supp_Id);
            EXEC_SQL.COLUMN_VALUE(cur_num ,2,ls_Suppl_Name);
            EXEC_SQL.COLUMN_VALUE(cur_num ,24,ls_exchange);
    End Loop;
    EXEC_SQL.CLOSE_CURSOR(cur_num );
    In this case I have to write 24 Define Columns and 24 Column value. Is there any way to assign them to %rowtype at one time as I need all coulmn of the table.
    I had similar case on multiple tables.
    Please help me
    Thanks,
    Maddy

    I need this dynamic sql because p_supplier and p_order values changes at run time
    I do not understand. Is this a simplified sample or the real thing? You do know that you can pass variables to cursors:
    cursor test is
    select * from supplier where supplier = p_supplier and processing_order = p_order;
    or does e.g. p_supplier hold other parts of the query?
    cheers

  • How can I open a cursor for dynamic sql statement

    Hi,
    I'm facing issues opening a cursor for dynamic sql statement : PLS-00455: cursor 'RESULT1' cannot be used in dynamic SQL OPEN statement.
    CREATE OR REPLACE FUNCTION DEMO
    (MN_I in VARCHAR)
    return AB_OWNER.ABC_Type.NonCurTyp is
    RESULT1 AB_OWNER.ABC_Type.NonCurTyp;
    sql_stmt VARCHAR2(4000);
    BEGIN
    sql_stmt := 'SELECT * FROM AB_OWNER.DUN WHERE JZ_I in ('||mn_i||') ORDER BY app.ACC_I';
    OPEN RESULT1 FOR sql_stmt;
    END IF;
    return RESULT1;
    END DEMO;
    What changes should I make in the code so that it doesn't fail? I can't change the definition of RESULT1 cursor though.

    Gangadhar Reddy wrote:
    I used SYS REFCURSOR and was able to implement successfully.How many times did you run this successful implementation that does not use bind variables?
    Because this is what will happen when it runs a lot.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17766/e2100.htm#sthref1874
    http://forums.oracle.com/forums/search.jspa?q=%2BORA-04031%20%2Bbind&objID=c84&dateRange=all&rankBy=10001&start=30
    And you will have to regularly restart the server, or possibly slightly less invasive, flush the shared pool.
    Flushing Shared Pool regularly
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1516005546092
    >
    Ok, this is an easy one to diagnose.
    You are not using bind variables. This is terrible. Flushing the shared pool is a bad
    solution -- you are literally killing the performance on your box by not using them.
    If I was to write a book on how to build “non scalable applications in Oracle”, this
    would be the first and last chapter. This is a major cause of performance issues and a
    major inhibitor of scalability in Oracle. The way the Oracle shared pool (a very
    important shared memory data structure) operates is predicated on developers using bind
    variables. If you want to make Oracle run slowly, even grind to a total halt – just
    refuse to use them.
    >
    But, please feel free to go ahead with this successful implementation.
    I just hope anyone else who reads this doesn't make the same mistake.

  • How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?

    Hi 
    I have a stored procedure. It can be executed like this
    exec test @p = 1;
    exec test @p = 2
    exec test @p = n;
    n can be hundred.
    I want the sp being executed in parallel, not sequence. It means the 3 examples above can be run at the same time.
    If I know the number in advance, say 3, I can create 3 different Execution SQL Tasks. They can be run in parallel.
    However, the n is not static. It is coming from a table. 
    How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
    I think about using script task. In the script, I get the value of n, and the list of p, from the table, then running a loop with. In the loop, I create a threat and in the threat, I execute the sp like : exec test @p = p. So the exec test may
    be run parallel. But I am not sure if it works.
    Any idea is really appreciated.

    Hi nam_man,
    According to your description, you want to call stored procedures in parallel, right?
    In SSIS, we can create separate jobs with different stored procedures, then set the same schedule to kick the jobs off at the same time. In this way, we should be careful to monitor blocking and deadlocking depending on what the jobs are doing.
    We can also put all stored procedures in SSIS Sequence container, then they will be run in parallel.
    For more information about SSIS job and Sequence container, please refer to the following documents:
    http://www.mssqltips.com/sqlservertutorial/220/scheduling-ssis-packages-with-sql-server-agent/
    https://msdn.microsoft.com/en-us/library/ms139855(v=sql.110).aspx
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • How to execute dynamic if statement...

    Hi All,
    My PL/SQL Blocks looks like this
    declare
    i_string :='if 3>20 then 1 else 2 end if;' varchar2(100);
    begin
    end;
    Between begin and end i want a piece of code which executes that if statement and sends 2 as output in dbms_output.put_line since 3 is not >20 .Basically i want to know how to execute dynamic if statement.Please help
    Thanks,
    Preethi

    Hi,
    i agree with Cyn. Dynamic SQL is often a bad idea. Try to avoid it.
    Dynamic PL/SQL is even worse. If you really must do something dynamic, at least try to cast it as SQL rather than PL/SQL.
    Does this do what you want?
    CREATE OR REPLACE FUNCTION     eval_case
    (     in_txt     IN     VARCHAR2
    RETURN     NUMBER
    DETERMINISTIC
    IS
         return_val     NUMBER;
         sql_txt          VARCHAR2 (1000);
    BEGIN
         sql_txt := 'SELECT  CASE '
              ||           in_txt
              || '         END'
              || '  FROM  dual';
         EXECUTE IMMEDIATE sql_txt INTO return_val;
         RETURN     return_val;
    END     eval_case;
    SHOW ERRORSYou might use the function above like this:
    declare
         i_string  varchar2(100) :='WHEN 3>20 THEN 1 ELSE 2';
    begin
         dbms_output.put_line (  TO_CHAR (eval_case (i_string))
                        || ' = results of eval_case ('''
                        || i_string
                        || ''')'
    end;
    /

  • How to execute multiple sql statements

    hi all
    i am wondering if i can execute multiple sql statements in one shot with >> execute immediate command
    for example:
    i define the variable as X := sql statement
    Y := sql statement
    z := sql statement
    can i do execute immediate (X,Y, Z);
    if yes how ?? and if not any possible alternate
    thanks

    Starting with Ganesh's code
    DECLARE
       l_statement                 VARCHAR2 (2000);
       v_passwd                    VARCHAR2 (200);
       v_username                  VARCHAR2 (200) := 'test';
       v_pwd_key                   VARCHAR2 (200) := 'lwty23';
       v_dblink_name               VARCHAR2 (2000);
       v_dblink_drop               VARCHAR2 (2000);
       v_dblink_create             VARCHAR2 (2000);
       v_dblink_check_connection   VARCHAR2 (2000);
       l_number                    NUMBER;
    BEGIN
       --<<c_instance>>
       FOR c_instance IN (SELECT *
                            FROM v_oracle_instances
                           WHERE environment = 'Developement')
       LOOP
          SELECT encpwd_owner.display_db_encpwd (v_username,
                                                 c_instance.host_name,
                                                 c_instance.instance_name,
                                                 v_pwd_key)
            INTO v_passwd
            FROM DUAL;
          v_dblink_name := c_instance.host_name || '_' || c_instance.instance_name;
          v_dblink_create :=
                ' CREATE DATABASE LINK '
             || v_dblink_name
             || ' CONNECT TO '
             || v_username
             || ' '
             || 'IDENTIFIED BY '
             || v_passwd
             || ' USING'
             || ' ''(DESCRIPTION=
    (ADDRESS=(PROTOCOL=TCP)(HOST= '
             || c_instance.host_name
             || ')(PORT='
             || c_instance.LISTENER_PORT
             || '))(CONNECT_DATA=(SID='
             || c_instance.instance_name
             || ')))''';
          v_dblink_check_connection := 'select 1 from global_name@' || v_dblink_name || '.QCM';    --- Notice this change. I am simply selecting 1. That should be enough to test the database link.
          v_dblink_drop := 'drop database link ' || v_dblink_name || '.QCMTLAF';
          -- l_statement := 'BEGIN ' || v_dblink_create ';' || v_dblink_check_connection ';' || v_dblink_drop '; END ;'
          BEGIN
              EXECUTE IMMEDIATE (v_dblink_create);
              DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Created');
         EXCEPTION
            WHEN others THEN
               dbms_output.put_line( 'Failed to create the database link ' || v_dblink_name  );
               dbms_output.put_line( dbms_utility.format_error_backtrace() );
               INSERT INTO error_table( column_list )
                 VALUES( <<list of values>> );
         END;
          EXECUTE IMMEDIATE (v_dblink_check_connection) INTO l_number;    --- Notice this.
          DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Tested');
          BEGIN
             EXECUTE IMMEDIATE (v_dblink_drop); 
             DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Dropped');
          EXCEPTION
             WHEN others THEN
               dbms_output.put_line( 'Failed to drop the database link ' || v_dblink_name  );
               dbms_output.put_line( dbms_utility.format_error_backtrace() );
               INSERT INTO error_table( column_list )
                 VALUES( <<list of values>> );
         END;
       END LOOP;
    END;But I agree with the point that others have brought up that it really doesn't make sense to create and drop a database link like this.
    Justin

  • How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt

    Hi,
    I have a procedure with OUT variable is %ROWTYPE
    How can I execute the following procedure on SQL prompt.
    (without creating anonymous block)
    CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
    V_REC IN OUT EMP%ROWTYPE)
    AS
    BEGIN
    SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
    END;
    Thanks & Regards,
    Naresh

    as previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
    With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
    declare
    l_rec EMPLOYEES%ROWTYPE;
    begin
    zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
    DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
    DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
    end;
    first_name = Steven
    last_name = King

  • How can I execute a statement before a VO is running

    JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660
    I use ADF BC
    how can I execute a statement before a VO is running

    thanks for the answer
    i use a logon function before I run a VO
    after a certain time will be disconnected
    and I have to call the function again
    sorry for my English
    public String logon(String username, String password){
    CallableStatement st = null;
    this.username = username;
    this.password = password;
    try {
    st = getDBTransaction().createCallableStatement("begin ep_security.LogOn(?,?); end;",0);
    st.setObject(1, username);
    st.setObject(2, password);
    st.executeUpdate();
    this.getDBTransaction().commit();
    } catch (SQLException e) {
    System.out.println("ERROR "+e.getMessage());
    this.addWarning(new JboWarning("Quote retrieved successfully"));
    System.out.println("...RETURN ERROR");
    return "error";
    } finally {
    if (st != null) {
    try {
    // 7. Close the statement
    st.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }

  • Preparing Dynamic SQL statement for inserting in Pro*C

    Hi Friends,
    From quite some time i am struggling writing Dynamic SQL statement for dynamic insert and update in Pro*C.
    Can somebody go through my code and suggest me the rigth way of doing.
    Right now it throws an error saying " Error while updating ORA-00904: invalid column name "
    Please help me.
    Girish.
    int main()
    EXEC SQL BEGIN DECLARE SECTION;
    char *uid ="scott/tiger";
    static char sqlstmt[129];
    struct /* DEPT record */
    int dept_num;
    char dept_name[15];
    char location[14];
    } dept_rec;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL WHENEVER SQLERROR DO sql_error();
    EXEC SQL CONNECT :uid;
    dept_rec.dept_num = 50;
    strcpy(dept_rec.dept_name,"ADMIN");
    strcpy(dept_rec.location,"IN");
    strcpy(sqlstmt,"UPDATE dept set DNAME = dept_rec.dept_name where DEPTNO = dept_rec.dept_num");
    EXEC SQL EXECUTE IMMEDIATE:sqlstmt;
    EXEC SQL COMMIT;
    exit(0);
    void sql_error()
    printf("\nError while updating %s",sqlca.sqlerrm.sqlerrmc);
    EXEC SQL ROLLBACK;
    }

    A bit rusty here but this is how I see it.
    Think of it this way ..
    all Oracle is going to see is:
    UPDATE dept set DNAME = dept_rec.dept_name where DEPTNO = dept_rec.dept_num
    Its NOT going to know what dept_rec.dept_name is or dept_rec.dept_num is ..
    it doesnt go back and fill in those values.
    You need something like
    strcpy(sqlstmt,"UPDATE dept set DNAME = \"");
    strcat(sqlstmt,dept_rec.dept_name);
    strcat(sqlstmt,"\" where DEPTNO = ");
    strcat(sqlstmt,dept_rec.dept_num);
    printf(sqlsmt); # Just to be sure the update statement look right during testing.

Maybe you are looking for

  • Acrobat Connect Pro 7.5 will not open MS Outlook 2010

    I have recently updated my OS to Windows 7. Acrobat Connect Pro 7.5 will not open MS Outlook 2010 with the preformatted email message after submitting via the Email Invitations button. MS Internet Explorer 8.0 goes to a blank page. Is there a compati

  • XSLT debugging

    Does JDeveloper provide any debugging capability to debug XSL Transformation? Any support on XSLT 2.0?? --Nimchi                                                                                                                                          

  • HT201303 hello! how can i change the  security question?

    I have the prolem about new devide, when i want to buy something with the new iphone, they going to ask 02 security questions. But i can't remember, so how can i change it? thanks a lot.

  • Error restarting OBIEE services after deploying a RPD.

    Hi all, I have recently performed OBIEE installation and, when a repository is deployed and all services restarted comes an error like this one and BI Server status is down: Operation Failed: start; OracleInstance: instance1; Component: coreapplicati

  • How customize the customization page?

    Hi all, in the component wizard there's a page to customize the customization page. But if this is not enough, is there any other way than editing the package in the database? I should need to change the detail captions, for example, the the to be di