Ampersand substitution in create or replace procedure statement

Hi guys,.

I wonder why my replacement ampersand works in a create or replace statement of the stored procedure.

CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS


Cancel the DEFINITION DimSales;
Cancel the DEFINITION FactTable;
SET DimSales = 'TESTTAB;
SET FactTable = myfact;


BEGIN
*...*

Error (5,20): PLS-00103: encountered the symbol "=" when expected as follows: =. (@ %; not null default range character)


If I assign the value with: = I get the error "invalid table" thereafter for the statemnt of INSERTION:

CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS


Cancel the DEFINITION DimSales;
Cancel the DEFINITION FactTable;
SET DimSales: = ' x 2';
SET FactTable: = ' x 1';


BEGIN
INSERT INTO & DimSales (column1, column2,...)

Why not the ampersand substitution work in a stored procedure?

No problem with the carpet. Display. But you don't need to create and drop them again. Simply create a time and refresh just before departure if necessary. I expect the creation and updating of points of view is fast comparibly. Also access to the seller_id should be indexed.

Your original pl/sql block is slow due to several reasons. One might be that you agree to each line. Engage is an extremely slow process. He avoid as much as possible. Another part might be that you make all the changes of context of pl/sql. The obvious way to avoid this would be to BULK operations (bulk-select + Forall). It is not so difficult. The size of the collection must be limited to a lower amount.

Best way would be to measure the performance of pl/sql parts using a tool such as DBMS_PROFILER. Then you can decide what part is slow and must be granted.

A simple insert could be faster. Did you test that?

example not tested

INSERT /*+append */
INTO &DimSales (K_Sales,REG,BVL,DS, VS,RS,GS,VK)
(SELECT trim(leading '0' from RS||GS) ,REG, BVL,DS, VS,RS,GS,VK
from &FactTable f
join &testsales s on f.SellerNo =s.Seller_No;

commit;

You can run the other issues, but this is generally the fastest approach. Try to avoid the separate if possible. This requires a sort and will slow down the insert of a lot.

Published by: Sven w. on November 30, 2010 17:10

Tags: Database

Similar Questions

  • SQL > create or replace procedure sp_Validate3 (p_acr_no IN varchar2 2)

    Hi all

    11.2.0.1

    Can you help me to debug what is that pl/sql code error? Thank you
    SQL> create or replace procedure sp_Validate3(p_acr_no    IN  varchar2
      2                                         ,p_recordset OUT sys_refcursor
      3                                         ) as
      4  begin
      5   open p_recordset for
      6      select am.acr_no as acr_no
      7            ,'TEST' as lastname
      8            ,nvl(a.or_no,'0') as ecc_orno
      9            ,nvl(b.or_no,'0') as rp_orno
     10            ,nvl(c.or_no,'0') as ar_orno
     11      from   tab t
     12                        join acr_master     am on (trim(acr_no) = p_acr_no)
     13             left outer join payment_master a  on (payment_type = 'ECC' and trim(acr_no) = p_acr_no)
     14             left outer join payment_master b  on (payment_type = 'RP'  and trim(acr_no) = p_acr_no)
     15             left outer join payment_master c  on (payment_type = 'AR'  and trim(acr_no) = p_acr_no);
     16  end;
     17  / 
     
    Warning: Procedure created with compilation errors.
     
    SQL> show error
    Errors for PROCEDURE SP_VALIDATE3:
     
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    6/5      PL/SQL: SQL Statement ignored
    13/80    PL/SQL: ORA-00918: column ambiguously defined
    SQL>
    create table acr_master(acr_no varchar2(10))
    
    drop table payment_master
    
    create table payment_master(or_no varchar2(10),acr_no varchar2(10),payment_type varchar2(10))
    
    /* Formatted on 06/06/2013 6:06:58 PM (QP5 v5.126.903.23003) */
    CREATE OR REPLACE PROCEDURE sp_Validate3 (p_acr_no      IN     VARCHAR2,
                                              p_recordset      OUT sys_refcursor)
    AS
    BEGIN
       OPEN p_recordset FOR
          SELECT   am.acr_no AS acr_no,
                   'TEST' AS lastname,
                   NVL (a.or_no, '0') AS ecc_orno,
                   NVL (b.or_no, '0') AS rp_orno,
                   NVL (c.or_no, '0') AS ar_orno
            FROM               tab t
                            JOIN
                               acr_master am
                            ON (TRIM (acr_no) = p_acr_no)
                         LEFT OUTER JOIN
                            payment_master a
                         ON (payment_type = 'ECC' AND TRIM (acr_no) = p_acr_no)
                      LEFT OUTER JOIN
                         payment_master b
                      ON (payment_type = 'RP' AND TRIM (acr_no) = p_acr_no)
                   LEFT OUTER JOIN
                      payment_master c
                   ON (payment_type = 'AR' AND TRIM (acr_no) = p_acr_no);
    END;
    /
    
    SQL> show error
    Errors for PROCEDURE SP_VALIDATE3:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    6/5      PL/SQL: SQL Statement ignored
    13/80    PL/SQL: ORA-00918: column ambiguously defined
    SQL>
    
    --In the below code after keeping alias names of the tables, the procedure compiled successfully 
    
    /* Formatted on 06/06/2013 6:06:58 PM (QP5 v5.126.903.23003) */
    CREATE OR REPLACE PROCEDURE sp_Validate3 (p_acr_no      IN     VARCHAR2,
                                              p_recordset      OUT sys_refcursor)
    AS
    BEGIN
       OPEN p_recordset FOR
          SELECT   am.acr_no AS acr_no,
                   'TEST' AS lastname,
                   NVL (a.or_no, '0') AS ecc_orno,
                   NVL (b.or_no, '0') AS rp_orno,
                   NVL (c.or_no, '0') AS ar_orno
            FROM               tab t
                            JOIN
                               acr_master am
                            ON (TRIM (acr_no) = p_acr_no)
                         LEFT OUTER JOIN
                            payment_master a
                         ON (a.payment_type = 'ECC' AND TRIM (a.acr_no) = p_acr_no)
                      LEFT OUTER JOIN
                         payment_master b
                      ON (b.payment_type = 'RP' AND TRIM (b.acr_no) = p_acr_no)
                   LEFT OUTER JOIN
                      payment_master c
                   ON (c.payment_type = 'AR' AND TRIM (c.acr_no) = p_acr_no);
    END;
    /
    
  • Procedure crashes while create or replace!

    Dear all,

    My Oracle 11 g RAC database is.

    I made some changes in one of my procedure and tried to recreate it using the CREATE or REPLACE procedure...

    The statement hangs for a long time and simultaneity in OEM increases up to a very high level. I tried to find blocking sessions, but for some time, there was no session blocking.

    I also tried to stop the activities on the tables used in this procedure.

    Please suggest me what can I do in this situation. I also tried directly from the server running the query.

    Best regards, Imran

    Oh, layout of the dining Forum, I copied correctly ;)

    In fact, it is not equal to '<>' operator & no '=' equql, please correct & let me know if useful

    Once again his lack below, will give you session killin commnd

    Select / * + CHOOSE * / ' alter system kill session "' | a.SID | ',' | a.Serial #| " « ; »
    session v$, $ v b access
    where a.sid = select
    and b.type<>'does not EXIST.
    and (b.owner is not null) and (b.owner<>'SYSTEM') and (b.owner<>'SYS') and serial No. <> 1
    and upper (b.object) like '% VSNL_CORP_TASK_READY_CMPL % ';

    Thank you
    Ajay more
    http://moreajays.blogspot.com

  • Date of entry into procedure statement

    Hi all.


    a DVICE me please what is the error in this statement 'a' in this procedure. the procedure to obtain the name of the table and date from the user and execute it.
    I think that my error for the format of the date in a statement. So, please give me the correction if you can.



    CREATE OR REPLACE PROCEDURE sp (table_name in varchar2, date_begin to date DEFAULT null)
    is
    type bulk_collect is table of index varchar2 (1000) by PLS_INTEGER;
    v_bluk1 bulk_collect;
    v_bluk2 bulk_collect;
    a varchar2 (300);
    c varchar2 (30);

    Start
    c: = table_name;
    r: = ' select rowid, id of ' | c | ' where date_of_ins > = ' | to_date(date_begin,'''dd/mm/yyyy'''); 

    immediately run a bulk collect into v_bluk1, v_bluk2;
    b in v_bluk1.first... loop v_bluk1. Last
    dbms_output.put_line (v_bluk1 (b));
    end loop;

    end;
    /




    SQL > exec sp ('emp', to_date (' 1/2/2006 ',' dd/mm/yyyy'));
    START sp ('emp', to_date (' 1/2/2006 ',' dd/mm/yyyy')); END;

    *
    ERROR on line 1:
    ORA-00904: "FEB": invalid identifier
    ORA-06512: in the 'END. "SP", line 13
    ORA-06512: at line 1

    Published by: Isabelle Sep 8, 2012 11:23

    Change according to your need...

    bkd@Oracle>ed
    Wrote file afiedt.buf
    
      1  CREATE OR REPLACE PROCEDURE sp(table_name in varchar2,dt IN date)
      2  is
      3  type bulk_collect is table of varchar2(1000) index by PLS_INTEGER;
      4  v_bluk1 bulk_collect;
      5  v_bluk2 bulk_collect;
      6  a varchar2(1000);
      7  begin
      8  a:= 'select last_name from  '|| table_name ||' where hire_date <= :dt';
      9  dbms_output.put_line (a);
     10  execute immediate a bulk collect into v_bluk1  using dt;
     11  dbms_output.put_line (a);
     12  for b in 1..v_bluk1.count loop
     13  dbms_output.put_line (v_bluk1(b));
     14  end loop;
     15* end;
    bkd@Oracle>/
    
    Procedure created.
    
    bkd@Oracle>exec sp('employees',to_date('01/02/2012','dd/mm/yyyy'));
    select last_name from  employees where hire_date <= :dt
    select last_name from  employees where hire_date <= :dt
    OConnell
    Grant
    Whalen
    Hartstein
    Fay
    

    Concerning
    Biju

    Published by: biju2012 on Sep 9, 2012 12:47 AM

    Correction: Replace for b in v_bluk1.first... v_bluk1. Last loop b loop 1.v_bluk1.count

  • How to create a stored procedure to delete and create table

    Version: Oracle 10g

    I am trying to create a stored procedure that is delete it and create a table based on a select statement. I can create the table, but I can't let it go.

    CREATE or REPLACE procedure EC_LOAD is
    Start
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    Of
    sales_revenue;
    end ecload;

    I need to drop the Sales_table before inserting the values. How can I do this?

    user610131 wrote:

    I need to drop the Sales_table before inserting the values. How can I do this?

    If you drop off where you insert it :)? Do you mean DELETE or TRUNCATE?

    If table can be truncated (and don't forget TRUNCATE is DDL then he will commit):

    CREATE OR REPLACE procedure EC_LOAD is
    begin
    EXECUTE IMMEDIATE 'TRUNCATE TABLE Sales_table';
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    from
    sales_revenue;
    end ecload;
    

    Otherwise, use DELETE:

    CREATE OR REPLACE procedure EC_LOAD is
    begin
    DELETE Sales_table;
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    from
    sales_revenue;
    end ecload;
    

    SY.

  • trying to get used to sql * more running and creating a simple procedure

    Hello all;

    I'm getting used to sql * more after using for a while using pl/sql developer.

    I am trying to create a simple procedure and run it. See my procedure below
    create or replace procedure test(t in varchar2(200), limit in number(30))
    begin
    select tbl_report.id from tbl_report where tbl_report.id like '|| t ||%' and rownum <= limit;
    end test;
    and then I type in run hr.test ("J", 10); to run this and then press ENTER, and it does nothing. How can I run and create a simple procedure in sql * more

    Hello

    In addition to all the good points, others have done:

    When you issue a SELECT statement in SQL * Plus (or any other front end) two things happen:
    (1) a result set, containing the results of your query, is produced, and
    (2) this result set is displayed.
    Given that these two things are always done together, it is easy to forget that they are two different things.
    In PL/SQL, you must explicitly do something to catch the result set, and you must explicitly do something else to view it (if you want to display it).

    A simple way to get the result set is to use a cursor FOR loop, to extract a line at a time and run code with this line in a record variable (called the country in the example below).
    View the results is to call dbms_output.put_line.

    Here is an example:

    CREATE OR REPLACE PROCEDURE     test
    (       t       IN      VARCHAR2
    ,     lmt      IN     NUMBER          -- LIMIT is an Oracle keyword; best not to use it as a variable name
    )
    IS
    BEGIN
        FOR  country  IN ( SELECT  country_name
                          FROM    hr.countries
                     WHERE   country_name     LIKE t || '%'
                     AND     ROWNUM          <= lmt
                   )
        LOOP
            dbms_output.put_line (  country.country_name
                        || ' = country_name'
                        );
        END LOOP;
    END test;
    /
    SHOW ERRORS
    

    You can use variables, such as t and lmt, in the query without using dynamic SQL, as long as the variables do not have the same names as the columns in the table. In this case, t and lmt are good names; country_name or region_id wouldn't. (In fact, t is a reputable insofar as it cannot be confused with a column in the table of the country. T is not a good reputation in the sense that it does not give much information about what contains the variable, or how it is used. Why not call the variable target_name or name_a_trouver?

    You can run the SQL procedure * more like this:

    SET     SERVEROUTPUT     ON
    
    EXEC  test ('I', 2);
    

    If you issue the SET SERVEROUTPUT ON command, then you will not see the output of dbms_output. You must only issue the command SET SERVEROUTPUT ON once per session, but nothing bad happens if you do it more than once.

    When I ran the procedure as stated above, I got this output:

    Israel = country_name
    India = country_name
    

    Notice that "The Italy" does not appear, because lmt has 2.

    Do not create your own procedures, tables or other objects in the HR schema, or among all the other patterns created by Oracle. Create your own schema and create procedures and other objects in it.

  • Create a stored procedure to convert a temporary table to the current table

    I have a table in oracle, named motor_assist2 with columns:
    NAME
    ADDRESS
    PHONE
    CITY
    STATE
    ZIP
    FRIENDSHIP
    SERVICE
    WAIT_TIME
    CONT_SERVICE
    COMMENTS
    DATETIME
    TECHNICIAN1_RADIO
    TECHNICIAN1_NAME
    LOCATION
    COUNTY_NAME
    COUNTY_ABBR
    MAV_TROOP
    TECHNICIAN2_RADIO
    TECHNICIAN2_NAME
    ID
    BEG_DATE
    END_DATE
    MONTH
    YEAR

    I have an another table (motor_assist9) in excel with similar columns I want to insert this data into my table (motor_assist2) current using a procedure but do not know how to do it. Can someone help me? Thank you

    Deanna

    If the number of columns and the order of the columns match on both tables, you can use:

    insert into motor_assist2 select * from motor_assist9;
    

    If this isn't the case, you will need to specify which columns of the source and/or destination:

    insert into motor_assist2 (destination, column, list)
           select source, column, list from motor_assist9;
    

    To make a wrap just stored as appropriate procedure insert the statement with the following code:

    create or replace procedure procedure_name as
    begin
      
    end;
    /
    
  • Synonym of ALTER with Create or replace synonym

    Oracle 9i Release 2 database

    I need to change the thesaurus during execution to point to a new owner of the table. But I'm running into errors of "insufficient privileges".

    SQL> select grantee,owner,table_name,privilege from dba_tab_privs
      2  where table_name IN ('OE4PNFGETDATA','OEBGGETDATA','OEGETDATA');
    
    GRANTEE       OWNER     TABLE_NAME        PRIVILEGE
    ------------- --------- ----------------- -----------
    OEMUSER       OEM2      OE4PNFGETDATA     EXECUTE
    OEMUSER       OEM2      OEBGGETDATA       EXECUTE
    OEMUSER       OEM2      OEGETDATA         EXECUTE
    OEMUSER       OEM1      OEBGGETDATA       EXECUTE
    OEMUSER       OEM1      OEGETDATA         EXECUTE
    OEMUSER       OEM1      OE4PNFGETDATA     EXECUTE
    
    SQL> sho user
    USER is "OEMUSER"
    SQL> select synonym_name,table_owner,table_name from user_synonyms ;
    
    SYNONYM_NAME                   TABLE_OWNER                    TABLE_NAME
    ------------------------------ ------------------------------ ------------------------------
    OE4PNFGETDATA                  OEM1                           OE4PNFGETDATA
    OEBGGETDATA                    OEM1                           OEBGGETDATA
    OEGETDATA                      OEM1                           OEGETDATA
    
    

    I need to change the owner of the table to OEM2. Using create or replace synonym in a procedure:

    CREATE OR REPLACE PROCEDURE oemuser.p_switch_users (  i_nonactive_user  IN  VARCHAR2
                                                        , o_msg             OUT VARCHAR2 )
    AS
       v_synonym_name VARCHAR2(30) ;
       v_table_owner  VARCHAR2(30) := i_nonactive_user ;
       v_table_name   VARCHAR2(30) ;
       v_sql          VARCHAR2(255);
    BEGIN
       FOR   rec   IN   ( select synonym_name, table_owner, table_name from user_synonyms )
       LOOP
          v_synonym_name := rec.synonym_name ;
          v_table_name   := rec.table_name   ;
          v_sql := 'CREATE OR REPLACE SYNONYM ' || v_synonym_name || ' FOR ' || v_table_owner || 
                   '.' || v_table_name ;
          EXECUTE IMMEDIATE v_sql ;
    
       END LOOP ;
       
       o_msg := 'Completed successfully' ;
       
       EXCEPTION
          WHEN  others  THEN
             o_msg := 'Error_Stack...' || Chr(10) ||
                      DBMS_UTILITY.FORMAT_ERROR_STACK ;
             RAISE ;
    END p_switch_users ;
    /
    
    var o_msg varchar2(512)
    var i_user varchar2(10)
    exec :i_user := 'OEM2'
    
    exec p_switch_users(:i_user,:o_msg)
    
    ORA-01031: insufficient privileges
    ORA-06512: at "OEMUSER.P_SWITCH_USE
    RS", line 
    
    

    I have not tried to drop the synonyms and re - create, but I expect the same error. Any suggestions?

    Hello

    the owner of the procedure should the privilege of creating its own synonyms if i_nonactive_user is defined on its own behalf (this case has no interest), and he has the privilege to create ANY synonym in other... At first glance, I would say that this is not a good idea.

    Note: you can also save a job: no need to redefine a synonym to point to the same thing, so I would limit synonyms selected in the loop:

    FOR rec IN (SELECT u.synonym_name, u.table_owner, u.table_name

    U user_synonyms

    WHERE u.table_owner! = v_table_owner

    )

    Best regards

    Bruno Vroman

  • Cannot create the plsql procedure, fails at the cursor

    He was a working procedure that would take ID and then copy the data from the source to the destination parameter parameter. Now I would like to have the NAME as a parameter, I changed the code to accommodate the new settings. But I'm not able to create the procedure. I get error 3-CURSOR (in bold red). I would really appreciate if someone can take a look and let me know what the problem is.

    Thanks in advance

    3 errors

    1 PLS-00103: encountered the symbol "CUR_V_HSP_COLUMN_DETAIL" during the expected in the following way:

    := . ( @ % ;

    The symbol ': = ' was replaced by 'CUR_V_HSP_COLUMN_DETAIL' continue.

    2 PLS-00103: encountered the symbol "NUMBER" when expecting one of the following conditions:

    (

    The symbol "(" was substituted for "NUMBER" to continue.

    3 PLS-00103: encountered the symbol "NUMBER" when expecting one of the following conditions:

    (

    CREATE or REPLACE procedure EPM_PLAN_PLANSAMP. Copy_Details_test1 - Arguments

    ( IN VARCHAR2, HSP_object in_From_Version_Name.) Object_name - Version of

    in_From_Scenario_Name IN VARCHAR2, HSP_object. Object_name - scenarios of

    in_From_Year_Name IN VARCHAR2, HSP_object. Object_name - year from

    in_To_Version_Name IN VARCHAR2, HSP_object. Object_name - Version to

    in_To_Scenario_name IN VARCHAR2, HSP_object. Object_name - scenarios

    in_To_Year_Name IN VARCHAR2 - HSP_object. Object_name - year to

    )

    IS

    number of v_From_Object_Id; -Version of

    number of s_From_Object_Id; -Scenarios of

    number of y_From_Object_Id; -The year of

    number of v_To_Object_Id; -Version to

    number of s_To_Object_Id; -Scenarios to

    number of y_To_Object_Id; -The year to

    BEGIN

    Select object_id in v_From_Object_Id

    of hsp_object

    where type_objet = 35

    and object_name = in_from_version_name;

    Select object_id in s_From_Object_Id

    of hsp_object

    where type_objet = 31

    and object_name = in_from_scenario_name;

    Select object_id in y_From_Object_Id

    of hsp_object

    where type_objet = 38

    and object_name = in_from_year_name;

    Select object_id in v_To_Object_Id

    of hsp_object

    where type_objet = 35

    and object_name = in_to_version_name;

    Select object_id in s_To_Object_Id

    of hsp_object

    where type_objet = 31

    and object_name = in_to_scenario_name;

    Select object_id in y_To_Object_Id

    of hsp_object

    where type_objet = 38

    and object_name = in_to_year_name;

    -Select Details of support for the current Version

    CURSOR Cur_V_HSP_COLUMN_DETAIL (cV_From_Object_Id in NUMBER, cS_From_Object_Id number) IS

    Select DETAIL_ID in the EPM_PLAN_PLANSAMP. HSP_COLUMN_DETAIL where DIM5 = cV_From_Object_Id AND DIM1 = cS_From_Object_Id;

    li_DETAIL_ID NUMBER;

    Li_Next_DETAIL_ID NUMBER;

    FETCH_STATUS NUMBER: = 0;

    v_step_name varchar2 (200);

    v_rec_cnt number: = 0;

    number of v_cnt;

    v_err varchar2 (2000);

    -----------------------------------------Begin Copy Version ---------------------------

    BEGIN

    -Removed next version if already exists

    v_step_name: = 'delete the HSP_COLUMN_DETAIL_ITEM ";

    Remove from HSP_COLUMN_DETAIL_ITEM

    Where DETAIL_ID in (Select DETAIL_ID from HSP_COLUMN_DETAIL

    Where = v_To_Object_Id AND DIM1-DIM5 = s_To_Object_Id);

    v_cnt: = number of lines sql %;

    insert into t_copy_supporting_dtls_log values (v_step_name, v_cnt, 1, sysdate, 'success');

    v_step_name: = 'delete the HSP_COLUMN_DETAIL ";

    Remove from HSP_COLUMN_DETAIL

    where = v_To_Object_Id AND DIM1-DIM5 = s_To_Object_Id;

    v_cnt: = number of lines sql %;

    insert into t_copy_supporting_dtls_log values (v_step_name, v_cnt, 1, sysdate, 'success');

    Open Cur_V_HSP_COLUMN_DETAIL (v_From_Object_Id, s_From_Object_Id);

    v_step_name: = "Insert";

    LOOP

    Look FOR Cur_V_HSP_COLUMN_DETAIL IN li_DETAIL_ID;

    WHEN the OUTPUT Cur_V_HSP_COLUMN_DETAIL % NOTFOUND;

    -Find the next detail_id

    Select Max (DETAIL_ID) + 1 IN HSP_COLUMN_DETAIL Li_Next_DETAIL_ID;

    -Insert in the Table HSP_COLUMN_DETAIL

    Insert into HSP_COLUMN_DETAIL (DETAIL_ID, PLAN_TYPE, DIM1, DIM2, DIM3, DIM4, DIM5, 6,

    DIM7, DIM8, DIM9, DIM10, DIM11, DIM12, DIM13, DIM14, DIM15,

    DIM16, DIM17, DIM18, DIM19, DIM20)

    Select Li_Next_DETAIL_ID, PLAN_TYPE, S_To_Object_Id, DIM2, DIM3, DIM4, V_To_Object_Id, 6.

    DIM7, DIM8, DIM9, DIM10, DIM11, DIM12, DIM13, DIM14, DIM15,

    DIM16, DIM18, DIM19, DIM17, DIM20

    Of HSP_COLUMN_DETAIL

    Where DETAIL_ID = li_DETAIL_ID;

    v_rec_cnt: = v_rec_cnt + sql rowcount %;

    -Insert in the Table HSP_COLUMN_DETAIL_ITEM

    Insert into HSP_COLUMN_DETAIL_ITEM (DETAIL_ID, VALUE, POSITION, GENERATION, OPERATOR, LABEL)

    Select VALUE, POSITION, GENERATION, OPERATOR, Li_Next_DETAIL_ID, LABEL

    From HSP_COLUMN_DETAIL_ITEM where DETAIL_ID = li_DETAIL_ID;

    v_rec_cnt: = v_rec_cnt + sql rowcount %;

    END LOOP;

    Close Cur_V_HSP_COLUMN_DETAIL;

    insert into t_copy_supporting_dtls_log values (v_step_name, v_rec_cnt, 1, sysdate, 'success');

    commit;

    exception when others then

    Rollback;

    v_err: = substr (sqlerrm, 1, 2000);

    insert into t_copy_supporting_dtls_log values (v_step_name, 0, -1, v_err, sysdate);

    commit;

    END;

    END;

    /

    You DECLARE the cursor before using it.

  • Create the stored procedure with the table from another throw diagram PLS-00201

    Oracle 10g. I'm new on procedures, so maybe I'm missing something obvious.

    The ABC schema owner has table T2001_WRITEOFF. The SYSDBAs given SIUD Some_Update_Role and granted this role to developer user IJK. IJK user then created a private synonym T2001_WRITEOFF for ABC. T2001_WRITEOFF. It worked with the usual SQL DML commands.

    When I try to create a simple procedure, it throws PLS-00201 identifier "T2001_WRITEOFF" must be declared and the points of the 2nd line.

    create or replace procedure woof1(
      fooname
    in T2001_WRITEOFF.territory%TYPE,  <=== error points here
      bardesc
    IN T2001_WRITEOFF.ind_batch_submit%TYPE) IS
    BEGIN
      
    INSERT into T2001_WRITEOFF
      
    VALUES ( fooname, bardesc);
    END woof1;
    /


    What I am doing wrong?


    Thank you

    JimR


    Grant the necessary rights directly to the user (not through a role):

    http://asktom.Oracle.com/pls/asktom/asktom.download_file?p_file=6551289900368934430

  • Create a stored procedure

    This procedure works fine, but I want to make a stored procedure to schedule it to run over time. I'd appreciate any help?

    SET SERVEROUTPUT SIZE 1000000
    declare
    cursor obj_cursor (objname Varchar2) is
    Select object_name, object_type, owner
    from dba_objects
    where owner = 'ITA '.
    and object_type IN ('TABLE', 'SEE')
    and object_name like '% JOB_;

    cursor c_job_status is
    SELECT ownerid jobid, starttime, endtime
    OF ita.tpis32_job_status
    WHERE starttime < sysdate - 800
    AND num_lines > 10000000;
    WK_SQL VARCHAR2 (500);
    WK_JOBSTR VARCHAR2 (500);
    BEGIN
    for c_job loop c_job_status
    wk_jobstr: = 'JOB_ | c_job. JobID | '%';
    for wk_rec loop obj_cursor (wk_jobstr)
    If wk_rec.object_type = "TABLE" then
    wk_sql: = 'drop table' |' ITA.' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    end if;
    If wk_rec.object_type = "DISPLAY" then
    wk_sql: = 'drop view ' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    -Wk_sql EXECUTE IMMEDIATE.
    end if;
    end loop;
    end loop;
    end;
    I tried this, but it did work ' t:
    create or replace procedure delete_table is
    SET SERVEROUTPUT SIZE 1000000
    declare
    cursor obj_cursor (objname Varchar2) is
    Select object_name, object_type, owner
    from dba_objects
    where owner = 'ITA '.
    and object_type IN ('TABLE', 'SEE')
    and object_name like '% JOB_;

    cursor c_job_status is
    SELECT ownerid jobid, starttime, endtime
    OF ita.tpis32_job_status
    WHERE starttime < sysdate - 800
    AND num_lines > 10000000;
    WK_SQL VARCHAR2 (500);
    WK_JOBSTR VARCHAR2 (500);
    BEGIN
    for c_job loop c_job_status
    wk_jobstr: = 'JOB_ | c_job. JobID | '%';
    for wk_rec loop obj_cursor (wk_jobstr)
    If wk_rec.object_type = "TABLE" then
    wk_sql: = 'drop table' |' ITA.' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    end if;
    If wk_rec.object_type = "DISPLAY" then
    wk_sql: = 'drop view ' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    -Wk_sql EXECUTE IMMEDIATE.
    end if;
    end loop;
    end loop;
    end delete_table;
    create or replace procedure delete_table is
    cursor obj_cursor(objname Varchar2) is
    select object_name, object_type, owner
    from dba_objects
    where owner = 'ITA'
    and object_type IN ('TABLE', 'VIEW')
    and object_name like 'JOB_%';
    
    cursor c_job_status is
    SELECT jobid, ownerid, starttime, endtime
    FROM ita.tpis32_job_status
    WHERE starttime < sysdate - 800
    AND num_lines > 10000000;
    WK_SQL VARCHAR2(500);
    WK_JOBSTR VARCHAR2(500);
    BEGIN
    for c_job in c_job_status loop
    wk_jobstr := 'JOB_' ||c_job.jobid||'%';
    for wk_rec in obj_cursor(wk_jobstr) loop
    if wk_rec.object_type = 'TABLE' then
    wk_sql := 'drop table ' ||'ita.'|| wk_rec.object_name || ';';
    dbms_output.put_line(wk_sql);
    end if;
    if wk_rec.object_type = 'VIEW' then
    wk_sql := 'drop view ' || wk_rec.object_name || ';';
    dbms_output.put_line(wk_sql);
    --EXECUTE IMMEDIATE wk_sql;
    end if;
    end loop;
    end loop;
    end delete_table;
    
  • Create or replace Stored procedure

    Hi all

    11.2.0.1

    I have the HR schema/user, who is the owner of all tables in the app.

    Then, all his paintings are also granted to BATCH - HR user with corresponding synonyms.

    This batch user will be used by computer operators to run reports of generations.

    For security reasons, they are not allowed to CONNECT to HR, but only to the BATCH - RH.

    My question is, can I create a stored procedure to the BATCH - RH which has only synonymous all tables?

    Or is it a good design to install it on human resources?

    Stored procedures recommend to operate only on base tables?

    Thank you

    Petra k.

    You can use everywhere in PL/SQL or external programs, because synonym is nothing more than a name new/more existing object; i.e. scott.emp table can have synonym1, synonym2, synonym3, etc.

    For more information: CREATE SYNONYM

    Concerning

    Girish Sharma

  • Create a stored procedure in the settings view

    I want to be able to create a view with the parameters of a stored procedure.

    Oracle 11g.

    don't know how to use the variable in immediate execution.

    CREATE OR REPLACE

    PROCEDURE TEST_GENERIC (TBL IN VARCHAR2, VWNAME IN VARCHAR2)

    AS

    BEGIN

    RUN IMMEDIATELY "CREATE OR REPLACE VIEW VWNAME AS SELECT SYSDATE FROM TBL";

    COMMIT;

    END;

    exec ('BIRD', 'DUAL') TEST_GENERIC

    Thanks for any help

    Hello

    Single quotes enclose a literal string; in other words, the text between the quotes literally means what it says, without reference to any variables.

    So, when you say:

    RUN IMMEDIATELY "CREATE OR REPLACE VIEW VWNAME AS SELECT SYSDATE FROM TBL";

    CREATE the word literally means to CREATE.  You may or may not have also a variable called CREATE, but that is irrelevant.

    The word OR means OR literally.  You may or may not have also a variable called operation GOLD, but that is irrelevant.

    REPLACE the word literally means REPLACE.  You may or may not have also a variable called to REPLACE, but that is irrelevant.

    ...

    The TBL Word literally means TBL.  You may or may not have also a variable called TBL, but that is irrelevant.

    If you want to reference a variable called TBL, then use TBL outside single quotes, like this:

    ...

    sql_text: = "CREATE or REPLACE VIEW VWNAME AS SELECT SYSDATE FROM '

    ||  TBL;

    dbms_output.put_line (sql_text |) "= sql_text before EXECUTE IMMEDIATE');   -For debugging

    EXECUTE IMMEDIATE sql_text.

    ...

    On the rare occasions when you use dynamic SQL statements, always put the dynamic SQL statement in a string variable (for example, sql_text, above) so that you can easily display for debugging purposes and to ensure that the command you are viewing is the same exact command that you should run.

    I guess the code you posted is a first test version of something that will be much, much different when it is finished.  Creating objects from database (such as views) in PL/SQL is almost always a terrible idea, and it seems that opinion that this code is attempting to produce would be very useful, anyway.

  • problem when creating a trigger: SQL statement ignored

    Hello people,

    I am trying to create a trigger, but it is not created. Instead, I get the error message that a SQL statement at line 22 was ignored. It's the line indicating IF num2 = 1 THEN. I'd be happy if someone could point me in the right direction or solve my problem.

    CREATE OR REPLACE TRIGGER TriggerLogement BEFORE INSERT OR update ON tenants
    FOR EACH LINE
    DECLARE
    NUM INTEGER;
    num2 INTEGER;
    NUM3 INTEGER;
    paysLocataire VARCHAR2 (255);
    categorieLocataire VARCHAR2 (1);
    BEGIN
    SELECT COUNT (ns) IN the number OF tenants WHERE nomBat =: new.nomBat;

    IF num > 0 THEN
    SELECT paid IN the country OF sports WHERE ns =: new.ns;
    SELECT COUNT (country) IN number OF athletes sp, tenants lo WHERE sp.ns = lo.ns AND paysLocataire AND lo.nomBat = pays =: new.nomBat;
    IF num = 0 THEN
    raise_application_error (-20000, "building already in use for another nationality");
    ON THE OTHER
    SELECT COUNT (ns) IN num2 OF tenants WHERE nLogement =: new. NLogement AND nomBat =: new.nomBat;
    IF num2 = 2 THEN
    raise_application_error (-20000, 'full accommodation');
    ON THE OTHER
    IF num2 = 1 THEN
    CateogrieLocataire INTO SELECT category OF athletes WHERE ns = new.ns;
    SELECT COUNT (ns) IN num3 FROM tenant lo, sportsmen sp WHERE lo.ns = sp.ns
    AND lo.nLogement =: new. NLogement AND lo.nomBat =: new.nomBat AND sp.categorie = categorieLocataire;
    IF num3 = 0 THEN
    raise_application_error ("-20000, ' already in use for the other sex");
    END IF;
    END IF;
    END IF;
    END IF;
    END IF;
    END;

    If you need more information or if you have any questions about my posts please leave your questions or comments. I hope this isn't how completely wrong to enforce some constraints that I can't do with CONSTRAINT and CHECK in the schema definition.

    Thanks for your help and your attention.

    Sebastian

    Hello

    Whenever you have a problem that raises an error, display the full error message; do not paraphrase just part of it.

    In the triggers line numbers from the first statement DECLARE or BEGIN, so line 22 of your trigger is:

    SELECT categorie INTO cateogrieLocataire FROM Sportifs WHERE ns = new.ns;
    

    You are missing a colon before 'new': it should be:

    SELECT categorie INTO cateogrieLocataire FROM Sportifs WHERE ns = :new.ns;
    

    A FOR EACH ROW trigger on tenants cannot ask tenants. It's a shame: there are many useful things, you could do if that were allowed, but it's not.
    I'm not sure of what all queries. At least one of them:

    SELECT  COUNT (ns)
    INTO    num2
    FROM    Locataires
    WHERE   nLogement = :new.NLogement
    AND     nomBat    = :new.nomBat;
    
    IF num2 = 2 THEN
        raise_application_error(-20000,'accomodation full');
    

    can be replaced by a UNIQUE constraint. (Constraints are better than triggers, in any case.)

    If you can't do what you want with constraints, you can leave anyone directly INSERT or update the table: force them to use a procedure stored instead. You can have an INSTEAD OF trigger on a view, which is essentially the same, but allows you to use DML commands.

    If you need help, post some sample data and some examples of DML operations that must be allowed, given the data and some examples of DML operations that should not be allowed.

  • Create Or Replace function error

    Hello

    I do the search of texts using Oracle SQL Developer: ODMiner... I imported the "WEBLOG" data into a table... These weblog data consists of the activity of users, date, time, url, etc. The first step I took was to use a function to convert the date and time I have in the data table, in a number representing the 40 minutes since 01/01/1990. I did it by dividing by 2400 (seconds in 40 minutes). The main objective is to have a period of time for the sessions.
    I used the following code,

    (SsnDate) CREATE or REPLACE FUNCTION
    DEFAULT VARCHAR2 03/01/18 EFFECTIVE DATE,
    TIME IN VARCHAR2
    ) RETURN NUMBER
    AS
    BEGIN
    RETURN TRUNC ((to_date(DATE||) e '|| TIME, ' Hh: mm: DD-MM-YY ')-to_date('01-JAN-1990','DD-MON-YYYY')) * (86400/2400);
    END ssnDate;

    This is what appeared in the newspaper after the execution of the statement,

    SsnDate compiled FUNCTION
    WARNING: the execution is completed with warning

    After that, I tried to create a VIEW to change the DATE and TIME with the ssnDate that was created earlier and concatenate the CS_URI_STEM (which is the accessible resource) and CS_URI_QUERY (which is the query, if any, the client was trying to perform) in a new field called WEB_LINK.

    This is the code used

    CREATE OR REPLACE VIEW WEBLOG_VIEWS ("C_IP", "WEB_LINK", "CS_USER_AGENT", "SESSION")
    AS
    SELECT ssnDate (LOG_DATE, LOG_TIME) AS "SESSION."
    C_IP,
    CS_USER_AGENT,
    (CS_URI_STEM |'?) ' || CS_URI_QUERY) AS WEB_LINK
    OF THE WEB BLOG.

    Now that I got the following error...

    Error from the 1 in the command line:
    CREATE OR REPLACE VIEW WEBLOG_VIEWS ("C_IP", "WEB_LINK", "CS_USER_AGENT", "SESSION")
    AS
    SELECT ssnDate (LOG_DATE, LOG_TIME) AS "SESSION."
    C_IP,
    CS_USER_AGENT,
    (CS_URI_STEM |'?) ' || CS_URI_QUERY) AS WEB_LINK
    WEBLOG
    Error in the command line: 3 column: 38
    Error report:
    SQL error: ORA-00923: KEYWORD not found where expected
    00923 00000 - "FROM keyword not found where expected"
    * Cause:
    * Action:

    I do not understand where I am going wrong with this... It comes to the data preparation step that requires me to prepare the data before applying the techniques of modeling or algorithms... The next step might be to group the data, based on the time of the session, ip and the user agent of each session as well as the fields web_links visited by the user of the session.

    I would be really grateful for all entries on where I'm wrong and all the solutions for it!

    Good. Please close the message.

    Concerning
    Girish Sharma

Maybe you are looking for

  • HP designjet T790: hP FIRMWARE T70

    my printer got 79.2:04.Restart that the printer.if problem persists, call HP support.please help me solve this problem

  • series of 100 ReadyNas rn104 principle capacity hard drive

    Hello I have a disc of 4 Tb. still one of 3 Tb. more I can put in my rn104

  • ReadyNAS NV + power supply

    We have a ReadyNAS NV + which no longer works. It seems that the power was cut off. Read the forum and here it seems that it is the common problem with this model. Someone at - it repair the power supply by replacing the bad capacitors? I'd like to s

  • I would like to implement skpye

    I would like to set up Skype. I thought I had done this before, but I also Logitech which would interfere with Skype? If yes you said to me how to add my son on Skype. He doesn't have a logitech [Moved from comments]

  • Windows Malicious Software Removal Tool - October 2011 (KB890830) bug

    Hello! After you install this update on my system I couldn't start over.My system has 2 to 3 monitors video cards. When I tried to start it, I saw the windows logo and the indicator of loading of the screen where it asks for the password never appear