Create procedure

I would need help on this procedure, can someone please tell me why it is not compiling.
CREATE OR REPLACE PROCEDURE DAILY_TRANSACTIONS
--Parse variables
IS
v_VOL_SRC_ID VARCHAR2(6);
ins_PBASE_MCF VARCHAR2(6);
c_BTU_CONTENT VARCHAR2(5);
ins_PBASE_BTU VARCHAR2(6);
v_EQUIP_SK DIST.VC_GASVOLS.EQUIP_SK%TYPE;
v_GAVOL_DT DATE;
v_GAVOL_TRANS VARCHAR2(10);
v_BTU_CONTENT NUMBER(10,8);
v_PBASE_MCF NUMBER(7,4);
v_PBASE_BTU NUMBER(7,4);
v_PROD_CD VARCHAR2(2) := '20';
v_DISP_CD VARCHAR2(3);
v_WET_DRY_ACT_CD VARCHAR2(1) := 'D';
v_LINE_PRESS NUMBER(8);
v_VOLUME VARCHAR2(7);
v_HAND_CALC_IND VARCHAR2(1) := 'C';
v_GAS_END_DT DATE;
v_GAS_START_DT DATE;
ins_MMBTU_VOL VARCHAR2(11);
v_GAVOL_GATH_SK VARCHAR2(10);
v_GAVOL_PURCH_SK VARCHAR2(10);
v_FIELD_VOL_EST DIST.VC_GASVOLS.field_vol_est%TYPE;
v_VOL_ORIGIN VARCHAR2(1) := 'P';
v_DB_OWN_SK VC_GASVOLS.db_own_sk%TYPE DEFAULT NULL;
v_NULLBTU_CONTENT NUMBER(10);
CURSOR Gastrans_curs IS
SELECT gavol_dt, btu_content, pbase_mcf, pbase_btu, line_press, volume, gas_end_dt,
gas_start_dt
FROM VC_GASVOLS
WHERE GAVOL_DT > TO_DATE(SYSDATE - 35);
CURSOR Nullbtu_curs IS
SELECT pbase_mcf
FROM VC_GASVOLS WHERE PBASE_BTU is NULL;
CURSOR Voltrans_curs IS
SELECT 'CS_'| |substr(vol_src_assoc_sk,3,4)| |'_'| |vol_src_call_sheet
FROM VC_EQUIPMENT;
CURSOR Stanum_curs IS
SELECT CONCAT(VE.equip_sk, VG.equip_sk)
FROM dist.vc_equipment VE, dist.vc_gasvols VG
WHERE GAVOL_DT > TO_DATE(SYSDATE - 35);
-- open file and get handle right in declaration
fh1 CONSTANT UTL_FILE.FILE_TYPE := UTL_FILE.FOPEN (DATA_DIR, FILE_IN, 'R');
fh2 CONSTANT UTL_FILE.FILE_TYPE := UTL_FILE.FOPEN (DATA_DIR, FILE_IN| |'.ERR','W');
-- counter
line_counter INTEGER := 1;
BEGIN
LOOP
<<GetNewRec>>
trans_cnt := 0;
-- fetches records
UTL_FILE.GET_LINE (FH1, LINE_OUT);
line_counter := line_counter + 1;
--parse records
v_Vol_Src_Id := SUBSTR(line_out,6,6);
v_Gas_End_Dt := TO_DATE(YYYYMMDD);
v_Gas_Start_Dt := TO_DATE(YYYYMMDD);
v_Volume := RPAD(SUBSTR(LINE_OUT,30,7),7,'0');
v_Pbase_Mcf := RPAD(SUBSTR(LINE_OUT,49,5),5,'0');
Ins_Pbase_Mcf := CONCAT(SUBSTR(v_pbase_mcf,1,2), '.');
Ins_Pbase_Mcf := CONCAT(ins_pbase_mcf, SUBSTR(v_pbase_mcf,3,3));
v_btu_content := RPAD(SUBSTR(LINE_OUT,63,4),4,'0');
v_Wet_Dry_Act_Cd := SUBSTR(LINE_OUT,67,1);
v_Pbase_Btu := RPAD(SUBSTR(LINE_OUT,68,5),5,'0');
Ins_Pbase_Btu := CONCAT(SUBSTR(v_Pbase_Btu,1,2), '.');
Ins_Pbase_Btu := CONCAT(Ins_Pbase_Btu, SUBSTR(v_Pbase_Btu,3,3));
OPEN Stanum_curs;
FETCH Stanum_curs INTO v_station_nunber;
CLOSE Stanum_curs;
OPEN Voltrans_curs;
FETCH Voltrans_curs INTO v_gavol_trans;
CLOSE Voltrans_curs;
OPEN Gastrans_curs;
FETCH Gastrans_curs
INTO v_GAVOL_DT, v_BTU_CONTENT, v_PBASE_MCF, v_PBASE_BTU, v_LINE_PRESS,
v_VOLUME, v_GAS_END_DT, v_GAS_START_DT;
CLOSE Gastrans_curs;
IF v_pbase_btu is NULL THEN
BEGIN
OPEN Nullbtu_curs;
fetch Nullbtu_curs INTO v_BTU_CONTENT;
CLOSE Nullbtu_curs;
END;
END IF;
--calculate MMBTU as (volume*btu_content to two decimals)
IF v_pbase_mcf = v_pbase_btu THEN
BEGIN
c_BTU_CONTENT := SUBSTR(v_btu_content,1,1)&#0124; &#0124;'.'&#0124; &#0124;SUBSTR(v_btu_content,2,3);
ins_MMBTU_VOL := ROUND(TO_NUMBER(v_VOLUME) * TO_NUMBER(c_BTU_CONTENT));
end;
end if;
IF(ins_mmbtu_volume = '0000000' AND v_mcf_volume != '0000') THEN
BEGIN
UTL_FILE.PUT_LINE (fh2, line_out&#0124; &#0124;'volume = 0');
INSERT INTO DIST.GASVOL_ERRS (Vol_Src_Id, Gas_End_Dt, Gas_Start_Dt,
Volume, Pbase_Mcf, Ins_Pbase_Mcf, Btu_Content,
Wet_Dry_Act_Cd, Pbase_Btu, Ins_Pbase_Btu, ERR_MSG)
VALUES(v_Vol_Src_Id, v_Gas_End_Dt, v_Gas_Start_Dt, v_Volume,
v_Pbase_Mcf, v_Ins_Pbase_Mcf, v_Btu_Content,
v_Wet_Dry_Act_Cd, v_Pbase_Btu, v_Ins_Pbase_Btu, 'VOLUME = 0');
GOTO GetNewRec;
END;
end IF;
BEGIN
SELECT COUNT(*) INTO trans_cnt
FROM DIST.VC_GASVOLS
WHERE equip_sk = v_equip_sk
AND gas_start_dt = v_start_date
AND gas_end_date = v_end_date;
IF tra ns_cnt > 0 THEN
BEGIN
UTL_FILE.PUT_LINE (FH2, LINE_OUT&#0124; &#0124;'MULTIPLE TRANSACTIONS FOR'
&#0124; &#0124;v_gas_start_dt&#0124; &#0124;'-'&#0124; &#0124;v_gas_end_date);
INSERT INTO DIST.GASVOL_ERRS (vol_src_id, gas_End_dt, Gas_Start_dt,
volume, pbase_mcf, ins_pbase_mcf, btu_content, wet_dry_act_cd, pbase_btu,
ins_pbase_btu, err_msg)
VALUES(v_vol_src_id, v_gas_End_dt, v_Gas_Start_dt, v_volume,
v_pbase_mcf, v_ins_pbase_mcf, v_btu_content, v_wet_dry_act_cd,
v_pbase_btu, v_ins_pbase_btu, 'MULTIPLE TRANSACTIONS FOR'
&#0124; &#0124;v_gas_start_dt&#0124; &#0124;'-'&#0124; &#0124;v_gas_end_date);
GOTO GetNewRec;
END;
END IF;
BEGIN
INSERT INTO DIST.VC_DAILY_TRANSACTIONS
(STATION_NUMBER, RECORD_DATE, GAVOL_TRANS, BTU_CONTENT, PBASE_MCF,
PBASE_BTU, PRODUCT_CODE, WET_DRY_CODE, LINE_PRESSURE, MCF_VOLUME,
CALC_IND, END_DATE, START_DATE, MMBTU_VOLUME, VOLUME_ORIGIN, OWNER)
VALUES(v_STATION_NUMBER, v_RECORD_DATE, v_GAVOL_TRANS, v_BTU_CONTENT,
v_PBASE_MCF, v_PBASE_BTU, v_PRODUCT_CODE, v_WET_DRY_CODE, v_LINE_PRESSURE,
v_MCF_VOLUME, v_CALC_IND, v_END_DATE, v_START_DATE, v_MMBTU_VOLUME,
v_VOLUME_ORIGIN, v_OWNER);
end;
COMMIT;
END DAILY_transactionS;
null

Hi,
Without giving error message, how can we provide the solution? I will give u some tips.
Ok, In this proc. If u are using UTL_FILE package, U should do these things.
1. The INIT.ORA file contains UTL_FILE_DIR = * or that particular file path, where it resides (Since U can use.
2. U will have necessary O/S permission on that file. (compilation error means, it will not come to the scenario ).
with regards,
Boby Jose thekkanath,
[email protected]
Dharma computers(P) Ltd.
Bangalore- India.

Similar Messages

  • How to create procedure having delete statement with between function?

    I am very new in SQL Development, I want to create a procedure having two date variable start and end and these two variable i want to use in procedure body to delete data from a specific table between two date duration.
    Please guide
    Thanks,

    create procedure some_proc (start_date date, end_date date)
    as
    begin
         delete from your_table
                   where your_date_column between start_date and end_date;
    end some_proc;
    /

  • Create procedure is generating too many archive logs

    Hi
    The following procedure was run on one of our databases and it hung since there were too many archive logs being generated.
    What would be the answer? The db must remain in archivelog mode.
    I understand the nologging concept, but as I know this applies to creating tables, views, indexes and tablespaces. This script is creating procedure.
    CREATE OR REPLACE PROCEDURE APPS.Dfc_Payroll_Dw_Prc(Errbuf OUT VARCHAR2, Retcode OUT NUMBER
    ,P_GRE NUMBER
    ,P_SDATE VARCHAR2
    ,P_EDATE VARCHAR2
    ,P_ssn VARCHAR2
    ) IS
    CURSOR MainCsr IS
    SELECT DISTINCT
    PPF.NATIONAL_IDENTIFIER SSN
    ,ppf.full_name FULL_NAME
    ,ppa.effective_date Pay_date
    ,ppa.DATE_EARNED period_end
    ,pet.ELEMENT_NAME
    ,SUM(TO_NUMBER(prv.result_value)) VALOR
    ,PET.ELEMENT_INFORMATION_CATEGORY
    ,PET.CLASSIFICATION_ID
    ,PET.ELEMENT_INFORMATION1
    ,pet.ELEMENT_TYPE_ID
    ,paa.tax_unit_id
    ,PAf.ASSIGNMENT_ID ASSG_ID
    ,paf.ORGANIZATION_ID
    FROM
    pay_element_classifications pec
    , pay_element_types_f pet
    , pay_input_values_f piv
    , pay_run_result_values prv
    , pay_run_results prr
    , pay_assignment_actions paa
    , pay_payroll_actions ppa
    , APPS.pay_all_payrolls_f pap
    ,Per_Assignments_f paf
    ,per_people_f ppf
    WHERE
    ppa.effective_date BETWEEN TO_DATE(p_sdate) AND TO_DATE(p_edate)
    AND ppa.payroll_id = pap.payroll_id
    AND paa.tax_unit_id = NVL(p_GRE, paa.tax_unit_id)
    AND ppa.payroll_action_id = paa.payroll_action_id
    AND paa.action_status = 'C'
    AND ppa.action_type IN ('Q', 'R', 'V', 'B', 'I')
    AND ppa.action_status = 'C'
    --AND PEC.CLASSIFICATION_NAME IN ('Earnings','Alien/Expat Earnings','Supplemental Earnings','Imputed Earnings','Non-payroll Payments')
    AND paa.assignment_action_id = prr.assignment_action_id
    AND prr.run_result_id = prv.run_result_id
    AND prv.input_value_id = piv.input_value_id
    AND piv.name = 'Pay Value'
    AND piv.element_type_id = pet.element_type_id
    AND pet.element_type_id = prr.element_type_id
    AND pet.classification_id = pec.classification_id
    AND pec.non_payments_flag = 'N'
    AND prv.result_value &lt;&gt; '0'
    --AND( PET.ELEMENT_INFORMATION_CATEGORY LIKE '%EARNINGS'
    -- OR PET.element_type_id IN (1425, 1428, 1438, 1441, 1444, 1443) )
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN PET.EFFECTIVE_START_DATE AND PET.EFFECTIVE_END_DATE
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN PIV.EFFECTIVE_START_DATE AND PIV.EFFECTIVE_END_DATE --dcc
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN Pap.EFFECTIVE_START_DATE AND Pap.EFFECTIVE_END_DATE --dcc
    AND paf.ASSIGNMENT_ID = paa.ASSIGNMENT_ID
    AND ppf.NATIONAL_IDENTIFIER = NVL(p_ssn, ppf.NATIONAL_IDENTIFIER)
    ------------------------------------------------------------------TO get emp.
    AND ppf.person_id = paf.person_id
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN ppf.EFFECTIVE_START_DATE AND ppf.EFFECTIVE_END_DATE
    ------------------------------------------------------------------TO get emp. ASSIGNMENT
    --AND paf.assignment_status_type_id NOT IN (7,3)
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN paf.effective_start_date AND paf.effective_end_date
    GROUP BY PPF.NATIONAL_IDENTIFIER
    ,ppf.full_name
    ,ppa.effective_date
    ,ppa.DATE_EARNED
    ,pet.ELEMENT_NAME
    ,PET.ELEMENT_INFORMATION_CATEGORY
    ,PET.CLASSIFICATION_ID
    ,PET.ELEMENT_INFORMATION1
    ,pet.ELEMENT_TYPE_ID
    ,paa.tax_unit_id
    ,PAF.ASSIGNMENT_ID
    ,paf.ORGANIZATION_ID
    BEGIN
    DELETE cust.DFC_PAYROLL_DW
    WHERE PAY_DATE BETWEEN TO_DATE(p_sdate) AND TO_DATE(p_edate)
    AND tax_unit_id = NVL(p_GRE, tax_unit_id)
    AND ssn = NVL(p_ssn, ssn)
    COMMIT;
    FOR V_REC IN MainCsr LOOP
    INSERT INTO cust.DFC_PAYROLL_DW(SSN, FULL_NAME, PAY_DATE, PERIOD_END, ELEMENT_NAME, ELEMENT_INFORMATION_CATEGORY, CLASSIFICATION_ID, ELEMENT_INFORMATION1, VALOR, TAX_UNIT_ID, ASSG_ID,ELEMENT_TYPE_ID,ORGANIZATION_ID)
    VALUES(V_REC.SSN,V_REC.FULL_NAME,v_rec.PAY_DATE,V_REC.PERIOD_END,V_REC.ELEMENT_NAME,V_REC.ELEMENT_INFORMATION_CATEGORY, V_REC.CLASSIFICATION_ID, V_REC.ELEMENT_INFORMATION1, V_REC.VALOR,V_REC.TAX_UNIT_ID,V_REC.ASSG_ID, v_rec.ELEMENT_TYPE_ID, v_rec.ORGANIZATION_ID);
    COMMIT;
    END LOOP;
    END ;
    So, how could I assist our developer with this, so that she can run it again without it generating a ton of logs ? ?
    Thanks
    Oracle 9.2.0.5
    AIX 5.2

    The amount of redo generated is a direct function of how much data is changing. If you insert 'x' number of rows, you are going to generate 'y' mbytes of redo. If your procedure is destined to insert 1000 rows, then it is destined to create a certain amount of redo. Period.
    I would question the <i>performance</i> of the procedure shown ... using a cursor loop with a commit after every row is going to be a slug on performance but that doesn't change the fact 'x' inserts will always generate 'y' redo.

  • With create procedure, How to clear Shared pool

    Hi, I have a sql script file it contains
    more than 300,000 line code, I use this file
    to create procedure in the Oracle.
    When I execute this sql script file, I receive a error message " out of cursor". I know when I create procedure, the procedure's code is stores in the shared pool. So when the code is stores out of shared pool's size, I receive that error.
    But how can I clear shared pool? With commit statement, it won't be use.
    Thanks a lot.

    you may try:
    alter system flush shared_pool;
    null

  • How to use the default database service name on creating procedure for data

    how to use the default database service name on creating procedure for datagaurd client failover ??? all oracle doc says create a new service as below and enable at DB startup. but our client is using/wanted database default service to connect from application on the datagaurd environment (rac to non rac setup).please help.
    Db name is = prod.
    exec DBMS_SERVICE.CREATE_SERVICE (service_name => 'prod',network_name =>'prod',failover_method => 'BASIC',failover_type => 'SELECT',failover_retries => 180,failover_delay => 1);
    says already the service available.
    CREATE OR REPLACE TRIGGER manage_dgservice after startup on database DECLARE role
    VARCHAR(30);BEGIN SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
    IF role = 'NO' THEN DBMS_SERVICE.START_SERVICE('prod');
    END IF;
    END;
    says trigger created, but during a swithover still the service is listeneing on listener.
    tns entry.
    prod =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (LOAD_BALANCE = YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod2)(PORT = 1521)) ---> primary db entry
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = proddr)(PORT = 1521)) --> DR DB entry
    (CONNECT_DATA =
    (SERVICE_NAME = prod)
    thanks in advance.
    Edited by: 854393 on Dec 29, 2012 11:52 AM

    Hello;
    So in the example below replace "ernie" with the alias you want the client to use.
    I can show you how I do it :
    First an entry need to be added to the client tnsnames.ora that uses a SERVICE_NAME instead of a SID.
    ernie =
    (DESCRIPTION =
        (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = Primary.host)(PORT = 1521))
           (ADDRESS = (PROTOCOL = TCP)(HOST = Standby.host)(PORT = 1521))
           (CONNECT_DATA =
           (SERVICE_NAME = ernie)
    )Next the service 'ernie' needs to be created manually on the primary database.
    BEGIN
       DBMS_SERVICE.CREATE_SERVICE('ernie','ernie');
    END;
    /After creating the service needs to be manually started.
    BEGIN
       DBMS_SERVICE.START_SERVICE('ernie');
    END;
    /Several of the default parameters can now be set for 'ernie'.
    BEGIN
       DBMS_SERVICE.MODIFY_SERVICE
       ('ernie',
       FAILOVER_METHOD => 'BASIC',
       FAILOVER_TYPE => 'SELECT',
       FAILOVER_RETRIES => 200,
       FAILOVER_DELAY => 1);
    END;
    /Finally a database STARTUP trigger should be created to ensures that this service is only offered if the database is primary.
    CREATE TRIGGER CHECK_ERNIE_START AFTER STARTUP ON DATABASE
    DECLARE
    V_ROLE VARCHAR(30);
    BEGIN
    SELECT DATABASE_ROLE INTO V_ROLE FROM V$DATABASE;
    IF V_ROLE = 'PRIMARY' THEN
    DBMS_SERVICE.START_SERVICE('ernie');
    ELSE
    DBMS_SERVICE.STOP_SERVICE('ernie');
    END IF;
    END;
    /lsnrctl status - should show the new service.
    When I do this the Database will still register with the listener. I don't give that to the clients. That one will still be available but nobody knows about it. Meanwhile "ernie" moves with the database role.
    So in my example the default just hangs out in the background.
    Best Regards
    mseberg
    Edited by: mseberg on Dec 29, 2012 3:51 PM

  • Compilation error while creating procedure

    Hi,
    I am getting compilation error while creating procedure
    CREATE OR REPLACE My_CHANGEDATE IS
    error_string VARCHAR2(400) := NULL;
    BEGIN
    Create table set_temp as select * from set;
    CURSOR c1 is
         SELECT a.SETNUM, b.CHANGEDATE from
         set a, setsp_t2 b
         where a.setnum = b.setnum
         and trunc(a.changedate) < trunc(b.CHANGEDATE);
    BEGIN
         FOR rec IN c1 LOOP
              UPDATE set SET changedate = rec.changedate
              WHERE setnum = rec.setnum;
              Insert into set_temp select * from set where setnum = rec.setnum;
              END LOOP;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              NULL;
         WHEN OTHERS THEN
                   error_string := 'My_CHANGEDATE - '||SUBSTR(SQLERRM,1,350);
    DBMS_OUTPUT.PUT_LINE(error_string);
                   RAISE;
    END My_CHANGEDATE;

    I have taken your code and cleaned it up to be more readable. Please see the comments in the code.
    CREATE OR REPLACE My_CHANGEDATE
    IS
            error_string VARCHAR2(400) := NULL;
    BEGIN
            /* The only way to issue DDL in a procedure is to either user
             * DBMS_SQL or EXECUTE IMMEDIATE. Creating objects is generally
             * not needed or recommended in frequently run code.
            Create table set_temp as select * from set;    
            /* The cursor declarations need to go in the declaration section of the
             * procedure (between IS .. BEGIN).
            CURSOR c1 is                                   
            SELECT a.SETNUM, b.CHANGEDATE from
            set a, setsp_t2 b
            where a.setnum = b.setnum
            and trunc(a.changedate) < trunc(b.CHANGEDATE);
            BEGIN   /* Where is the END that goes with this begin? */
            /* Single record processing is generally not recommended. It is considered a "slow-by-slow" method. */
            FOR rec IN c1 LOOP
                    UPDATE set SET changedate = rec.changedate
                    WHERE setnum = rec.setnum;
                    Insert into set_temp select * from set where setnum = rec.setnum;
            END LOOP;
    EXCEPTION
            WHEN NO_DATA_FOUND THEN
                    NULL;
            WHEN OTHERS THEN
                    error_string := 'My_CHANGEDATE - '||SUBSTR(SQLERRM,1,350);
                    DBMS_OUTPUT.PUT_LINE(error_string);
                    RAISE;
    END My_CHANGEDATE;My general recommendations are as follows:
    1. Remove the CREATE TABLE from the procedure altogether.
    2. Don't use reserved words for object names (e.g. SET)
    3. Remove the record by record processing and consolidate it to a single UDPATE statement as follows (note untested):
    UPDATE  set s
    SET     changedate = (
                            SELECT  CHANGEDATE
                            FROM    SET A
                            ,       SETSO_T2 B
                            WHERE   A.SETNUM = B.SETNUM
                            AND     S.SETNUM = A.SETNUM
                            AND     TRUNC(A.CHANGEDATE) < TRUNC(B.CHANGEDATE)
    WHERE EXISTS(
                    SELECT  NULL
                    FROM    SET A
                    WHERE   A.SETNUM = S.SETNUM
                    )HTH!

  • "Run Script" (F5) Flacky Behavior with CREATE PROCEDURE and PACKAGE

    When I have the following create statement in a SQL Worksheet and run the script using "Run Script" (F5), I get the "PROCEDURE bogus Compiled." message. Why does it not tell me that there was a compile error? The procedure is marked with a little red "X" in the connections pane.
    CREATE OR REPLACE PROCEDURE bogus IS
    BEGIN
      x := 1;
    END;
    /Also, when I have the following command in a SQL Worksheet and run the script using "Run Script" (F5), I get the "PROCEDURE bogus Compiled." message. The difference is that I removed the slash after the CREATE PROCEDURE command. I can go into that procedure in the database via the Connections pane, click on the compile button, and the procedure compiles with no errors. Why does it not compile in a script when missing the slash?
    CREATE OR REPLACE PROCEDURE bogus IS
    BEGIN
      NULL;
    END;I noticed the same flaky behavior with CREATE PACKAGE BODY as well. This is in version 1.0.0.14.67 on Windows XP. Has this been fixed in the latest version?
    Mike

    I found a number of earlier posts on this (going back to at least v804), but I cannot find a thread with a response from the SQL Developer team - see:
    Package compilation error
    Succesful compilation message and Compiling Invalid Objects
    Creating a stored procedure from a file does not show compilation errors
    Re: Syntax Error Feedback
    I assume that it is just a bug with SQL Developer that it does not check for compilation errors when determining the status message to display (ie "PROCEDURE bogus Compiled"). At least now we get the little red cross on the navigator to tell us it is invalid :)

  • Creating procedures in forms

    I ahve to create 4 proceduers and call them in WHEN BUTTON PRESSED trigger.
    How can i create procedures at form level.
    I can create them in the database by sqlplus but then the procedures would be server specific.

    I can create them in the database by sqlplus but then
    the procedures would be server specific.Why would that be a problem ?

  • Security problem? (ORA-00942 error when creating procedure)

    First, in SQL*Plus connect as system user:
    SQL&gt;connect system/oracle
    Then, create table proctest for user scott and insert records:
    SQL&gt;create table scott.proctest ( name varchar2(10)) ;
    SQL&gt;insert into scott.proctest values ( 'bigboy' ) ;
    SQL&gt;select * from scott.proctest ;
    NAME
    bigboy
    Then, create procedure testproc for user system using table scott.proctest:
    SQL&gt;CREATE OR REPLACE PROCEDURE testproc AS
    2 v_name VARCHAR2(10) ;
    3 BEGIN
    4 SELECT Name INTO v_name FROM scott.proctest WHERE rownum &lt; 2 ;
    5 DBMS_OUTPUT.PUT_LINE( 'Name: ' || v_name ) ;
    6 END ;
    7 /
    Then, errs report:
    SQL&gt;show err;
    LINE/COL ERROR
    4/2 PL/SQL: SQL
    4/2 PL/SQL: SQL Statement ignored
    4/37 PL/SQL: ORA-00942: Table or view does not exist
    Then, explicitly grant select privilege on proctest to system:
    SQL&gt;grant select on scott.proctest to system ;
    And at this time compile the above precedure again, there's no errors.
    I have got some instruction that if a procedure wants to use some table,
    the owner of this procedure has to have corresponding privileges to use this table and
    these privileges have to be granted directly to the user. It doesn't work if
    the privileges are granted i.e. through roles.
    And in the example above the user has select on scott.proctest privilege but
    this privilege is granted through DBA role. So it doesn't work if
    I do not explicitly grant select privilege to system.
    My question is:
    Why does Oracle define this rule? Is it a kind of security consideration?

    Since stored procedures rely on privileges that are granted directly to the user, Oracle only needs to re-validate stored procedures when direct grants to the schema owner change. In general, the rate at which the privileges assigned to roles are changed is much higher than the rate at which privileges assigned to a particular user are changed, so this cuts down on on the cost of revalidating procedures.
    More importantly, Oracle roles can be assigned to users, but a user can also have non-default roles and password-protected roles. If Oracle allowed privileges through roles to affect the privileges of a stored procedure, handling these sorts of cases would be quite difficult and would result in far more confusion than in today's implementation.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • "GRANT CREATE PROCEDURE TO " not working

     
     Hi Team,
                  I am using SQL Server 2012 Developer Edition.Recently got request to grant permission to  "Create Stored Procedure" to a developer.When I execute this query "GRANT CREATE PROCEDURE TO [DEVELOPER];"
    It is not working again when the developer try to create a stored procedure Following error is displayed.I give the developer dbowner,ddladmin privileges also to test but the same below error is display.Can anybody guide me regarding this as it is high priority
    Msg 262, Level 14, State 18, Procedure test, Line 1
    CREATE PROCEDURE permission denied in database 'BASHA'.
     

                  Following are the output for both the select queries.
    1) BASHA  DATABASE 0CONNECT GRANT    
    2) db_ddladmin
    Membership in db_ddladmin should be sufficient. Below is a script that
    demonstrates two ways to grant a user rights to create procedures. You can
    use this script for your troubleshooting.
    Also, please post the output from "SELECT @@version".
    CREATE USER nisse WITHOUT LOGIN
    EXEC sp_addrolemember db_ddladmin, nisse
    go
    CREATE USER kajsa WITHOUT LOGIN
    GRANT CREATE PROCEDURE TO kajsa
    GRANT ALTER ON SCHEMA::dbo TO kajsa
    go
    EXECUTE AS USER = 'nisse'
    SELECT * FROM fn_my_permissions (NULL, 'DATABASE');
    go
    CREATE PROCEDURE bludder AS PRINT 1
    go
    REVERT
    go
    EXECUTE AS USER = 'kajsa'
    SELECT * FROM fn_my_permissions (NULL, 'DATABASE');
    go
    CREATE PROCEDURE blidder AS PRINT 1
    go
    REVERT
    go
    SELECT p.name, db_name(), dp.class_desc, dp.major_id, dp.permission_name,
    dp.state_desc
    FROM sys.database_permissions dp
    JOIN sys.database_principals p ON p.principal_id = dp.grantee_principal_id
    WHERE p.name IN ('nisse', 'kajsa')
    SELECT m.name, r.name
    FROM sys.database_principals m
    JOIN sys.database_role_members rm ON m.principal_id =
    rm.member_principal_id
    JOIN sys.database_principals r ON r.principal_id = rm.role_principal_id
    WHERE m.name IN ('nisse', 'kajsa')
    go
    DROP USER nisse
    DROP USER kajsa
    DROP PROCEDURE bludder, blidder
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How Create procedure or function with ADO ?

    Hello,
    How Create procedure or function with ADO?It's my question.
    Thanks.
    Henri

    This message if post by Taiwan-ChangHaw-Oracle-Stored-Procedure-For-Business-Rule-Club
    public bool ConnectDatabase()
    try
    { string strConnectionString =
    "Provider=OraOLEDB.Oracle" +";"+
         "Data Source=" + ConnectionParams.Datasource +";"+
    "User Id =" + ConnectionParams.Username +";"+
    "Password =" + ConnectionParams.Password;
         m_conn=new ADODB.Connection();
         m_conn.ConnectionString=strConnectionString;
         m_conn.Open("","","",0); //i_"YYAOl Open the connection
    catch(Exception e)
    {     System.Windows.Forms.MessageBox.Show(e.Message);
         return false;
    return true; //YYAOl_B>3I9&connected successfully
    public void InsertDescription(string p_product,string p_language,string p_tname,string p_tdescription)
    { string sql="{Call inserttranslateddescription(?,?,?,?,?)}";
    try
    { ADODB._Command cmd=new ADODB.Command();//Create a command object
    cmd.ActiveConnection=m_conn; //Set its active connection to open connection
    ADODB.Properties properties=cmd.Properties;//Get the command properties into ADODB Properties object
    IEnumerator ienum=properties.GetEnumerator();//Get an enumerator on above properties
    ADODB.Property singleprop;
    while(ienum.MoveNext()) //iterate through the enumerator
         {singleprop=(ADODB.Property)ienum.Current;//Get the current property from enumerator
         string propname= singleprop.Name; //Get the name of current property
         if(propname.Equals("NDatatype")) //if the property is 'NDatatype' set its value to true
         singleprop.Value=true;
    cmd.CommandType=ADODB.CommandTypeEnum.adCmdText;
    int pid=Int32.Parse(p_product);
    ADODB._Parameter langid     =cmd.CreateParameter("langid",          ADODB.DataTypeEnum.adChar,ADODB.ParameterDirectionEnum.adParamInput, 100,p_language);
    ADODB._Parameter productid =cmd.CreateParameter("productid",     ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamInput, 100,pid);
    ADODB._Parameter tname =cmd.CreateParameter("tname",          ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tname);
    ADODB._Parameter tdescription=cmd.CreateParameter("tdescription",ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tdescription);
    ADODB._Parameter check          =cmd.CreateParameter("check",          ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamOutput,100,0);
    cmd.Parameters.Append(langid);
    cmd.Parameters.Append(productid);
    cmd.Parameters.Append(tname);
    cmd.Parameters.Append(tdescription);
    cmd.Parameters.Append(check);
    cmd.CommandText=sql;
    //Execute the command to insert product details in database
    object recs;
    object param=p_language;
    cmd.Execute(out recs,ref param,1);
    ienum.Reset();
    while(ienum.MoveNext()) //iterate through enumerator
    { singleprop=(ADODB.Property)ienum.Current;//Get the current property in to Property object
    string propname= singleprop.Name; //Get the name of current property
    if(propname.Equals("NDatatype")) //if it is 'NDatatype' set its value to true
    singleprop.Value=false;
    IEnumerator iprop=cmd.Parameters.GetEnumerator();//Get the enumerator for command parameters
    while(iprop.MoveNext()) //loop through enumerator
    { //Get the current parameter in enumerator
    ADODB._Parameter checkval=(ADODB._Parameter)iprop.Current;
    if(checkval.Name.Equals("check")) //if the parameter is 'check'
    if(checkval.Value.ToString().Equals("0")) //If check's value is zero data was inserted
    System.Windows.Forms.MessageBox.Show("Product details Inserted successfully");
    else
    System.Windows.Forms.MessageBox.Show("Product Details Updated");//else data was updated
    catch(Exception e)
    System.Windows.Forms.MessageBox.Show(e.Message);//Display any error message
    }

  • How to create procedure

    hi
    i have a little problem with creating procedure
    i have a table
    create table t
    t_id int,
    t_name varchar(22)
    insert into t values(1,'AA');
    and then i try to create procedure for insert into this table
    create or replace procedure my_proc(pt_id int,pt_name varchar(22))
    as begin
    insert into t values(pt_id,pt_name);
    end;
    but i receive an error
    please help me anybody

    Diman wrote:
    hi
    i have a little problem with creating procedure
    i have a table
    create table t
    t_id int,
    t_name varchar(22)
    insert into t values(1,'AA');Thanks for posting the CRATE TABLE and INSERT statements; that's very helpful!
    and then i try to create procedure for insert into this table
    create or replace procedure my_proc(pt_id int,pt_name varchar(22))
    as begin
    insert into t values(pt_id,pt_name);
    end;
    but i receive an errorWhy not post the error message?
    please help me anybodyWhen you give the datatype of an argument, you can't qualify it with a length (like VARCHAR *(22)* ); just give the type (VARCHAR)
    create or replace procedure     my_proc
    (   pt_id       int
    ,   pt_name     varchar          -- no size
    as begin
        insert into t (t_id,   t_name)
                values (pt_id,  pt_name);
    end;By the way, it's a good idea to explicitly name the columns in an INSERT statement. It helps prevent bugs, and it keeps you procedure working if you forget to change it when you add columns to the table.

  • Cant create procedure over OracleCommand. any HELP?

    Hi eweryone. This is my firs post here and i am new in oracle. I have a problem with .NET oracle commands. I want to create procedures or a package in run time. here is my simple c# code :
    OracleConnection con = new OracleConnection();
    Source=DBTEST_METUSSERVER";
    con.ConnectionString = "User Id=SYSTEM;Password=orcl;" + "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=metusserver)" + "(PORT=1521))(CONNECT_DATA=(SID=dbtest)));"; con.Open();
    string sqlstr = "CREATE PROCEDURE SA.ACTIONDELETEALL2 IS \r\n";
    sqlstr += "BEGIN \r\n";
    sqlstr += "DELETE FROM ACTION_HISTORY; \r\n";
    sqlstr += "END ACTIONDELETEALL2; \r\n/\r\n";
    OracleCommand cmd = new OracleCommand(sqlstr, con);
    cmd.ExecuteNonQuery();
    this code works and stores my procedure with errors as INVALID.
    the error is this :
    //Line # = 1 Column # = 33 Error Text = PLS-00103:
    Encountered the symbol "" when //expecting one of the following:
    // begin function package pragma procedure subtype type use // <an identifier> form // current cursor external language
    Also when I execute this code with sql plus it stores my procedure successfully and VALID.
    Any ideas?

    Also when I execute this code with sql plus it stores my procedure successfully and VALID.remove the use of \r and \n and also the last slash character that you are adding at the end. That is needed by the SQL*Plus to tell it to send the entire above string to the database. You do not need it when doing it via your program.

  • Requirment for creating procedure

    Hello Team
                       Can some one please suggest me what are the specific comditions or scenarios for which we need to create procedures in SAP HANA . If anyone suggest with practical scenario then it would be a plus .
    Regards

    Hi Prag,
    You can co relate the use of a database procedure with a function module or a BAPI in your abap system. When there are multiple processes involved in an execution path which can be reused across the landscape or complex calculation logics are involved in the process, we are supposed to use procedures . Because the business logic may not be achievable by writing database queries . 
    Sreehari

  • Create procedure statement Hangs in 11g database, doesn't hang in 10.2

    I have installed 11g on a windows workstation and created a new database. I then attempted to import a schema from a tried and tested 10.2 database, this hung.
    I pinpointed the cause of the hang to a create procedure sstatement within the import file.
    I removed the procedure from the 10.2 database, re-exported and imported sucessfully in to the 11g database minus the rogue prrocedure.
    I now have a create statement for the procedure thats causing the hangs, and this hangs when I try and run it - it runs fine against my 10.2 database?
    I can comment large chunks of the create procedure statment out so I get an anonymous block that runs, and pinpoint the hang down to the inclusion of the the line marked below
    (starting FOR UPDATE OF...........).
    I cant work out whats going on, I'm no programmer by the way!
    Any pointers would be greatly appreciated.
    Nick
    declare
    job_rec job_table%ROWTYPE;
    err_msg varchar2(2000);
    abort_msg varchar2(2000);
    l_ok boolean := TRUE;
    l_bat_job varchar2(14) := 's2_novate_RIC';
    LINES DELETED FOR PURPOSE OF POSTING CURSOR c_sah IS
         SELECT
              sah_next,
              sah_table_key,
              sah_old_status,
              sah_new_status,
              sah_processed_ind,
              sah_processed_date,
              sah_processed_time
         FROM senatordba.sah_status_audit_history
         JOIN (SELECT distinct to_char(spd_next) spd_next
              FROM senatordba.spd_std_risk_dets
              JOIN senatordba.rso_risk_system_options
              ON rso_spd_next = spd_next
              AND spd_ric_code = l_ric_code
              AND coalesce(l_uw_year, spd_yr) = spd_yr
              AND coalesce(l_risk_ref, spd_ref) = spd_ref
         ON spd_next = sah_table_key
         AND sah_table_code = 'SPD'
         AND sah_status_table_code = 'NOV'
         AND sah_processed_ind = 'N';
    FOR UPDATE OF sah_processed_ind, sah_processed_date, sah_processed_time;               <---------if this line is commented out runs OK, if left in, it hangs??
    r_sah c_sah%ROWTYPE;
    begin
    open c_sah;
    close c_sah;
    end;

    Hi Nick, no one else has answered so I thought I'd answer my own question, it appears that I was hitting Oracle bug 9294110. had to uninstall 11.2 and install 11.0.7 instead. very annoyed that I wasted ages diagnosing this known problem. The following test should replicate the hang
    connect / as sysdba
    create user test identified by test default tablespace users temporary tablespace temp;
    grant connect, resource to test;
    connect test/test
    create table a_tab
    ( col001 number, col002 number, col003 number, col004 number);
    create table b_tab( col001 number);
    -- the next statement hangs forever
    select
    a.col002,
    a.col003,
    a.col004
    from
    a_tab a
    left outer join b_tab
    on a.col001 = b_tab.col001
    for update of a.col002,
    a.col003,
    a.col004;

  • Why thr r 2 options Is/As while creating procedure or function

    why there are 2 options avialable IS/AS while creating procedure or function ?
    Like
    create or replace procedure test (p_nbr NUMBER) AS
    create or replace procedure test (p_nbr NUMBER) IS
    tried both the options observed same result..
    Is thr any differnce between IS and AS ?

    SShubhangi wrote:
    why there are 2 options avialable IS/AS while creating procedure or function ?
    Like
    create or replace procedure test (p_nbr NUMBER) AS
    create or replace procedure test (p_nbr NUMBER) IS
    tried both the options observed same result..
    Is thr any differnce between IS and AS ?Technically... there is no difference.
    In terms of the English language, it would depend what you're describing...
    [ do some action ] AS follows...
    [ this object ] IS defined like this...
    So in programming language terms you could say that:
    create or replace procedure test (p_nbr NUMBER) AS...reads more naturally than
    create or replace procedure test (p_nbr NUMBER) IS...because it is an "action" of creating or replacing something.
    whereas, for example, a procedure in a package...
    procedure test (p_nbr NUMBER) IS...is more clear than
    procedure test (p_nbr NUMBER) AS...because this is stating what the procedure IS, rather than an action of creating it. (the package itself would be "create package ... AS")
    As far as Oracle is concerned though, it doesn't care, they are both interchangable. For me personally, I like to use the one that makes it clearly readable.

Maybe you are looking for