Doubt on user procedure used in dml handler?

I am calling a user procedure in dml handler of apply process.I dont want my apply to apply changes.Instead i want to insert in a table <history_row_lcrs> the values which are captured by captured process.
history_row_lcrs table has columns (date_t date, deptno number,dname varchar2(10), loc varcha2(10))
deptno,dname,loc are the values captured as streams on dept table.
I want to know the syntax to extract these values from LCR.(that is,to accomodate in the insert statement where i have written<what?>)
CREATE OR REPLACE PROCEDURE history_dml(in_any IN SYS.ANYDATA)
IS
lcr SYS.LCR$_ROW_RECORD;
rc PLS_INTEGER;
BEGIN
-- Access the LCR
rc := in_any.GETOBJECT(lcr);
-- Insert information in the LCR into the history_row_lcrs table
INSERT INTO strmadmin.history_row_lcrs VALUES
(SYSDATE,<what??>,<what?>,<what?>); --------
-- Apply row LCR
lcr.EXECUTE(false);
END;
/

Once a DML handler for an object is called by APPLY, the user procedure has complete control of what to do with the LCR.
In your case, use the example provided in the streams documentation on how to view the contents of an LCR and use that in your INSERT statement. See the partial code snippet below:
Finally, you need to remove lcr.execute(FALSE) to prevent apply from applying the change.
CREATE OR REPLACE PROCEDURE print_any(data IN ANYDATA) IS
tn VARCHAR2(61);
str VARCHAR2(4000);
chr VARCHAR2(1000);
num NUMBER;
dat DATE;
rw RAW(4000);
res NUMBER;
BEGIN
IF data IS NULL THEN
DBMS_OUTPUT.PUT_LINE('NULL value');
RETURN;
END IF;
tn := data.GETTYPENAME();
IF tn = 'SYS.VARCHAR2' THEN
res := data.GETVARCHAR2(str);
ELSIF tn = 'SYS.CHAR' then
res := data.GETCHAR(chr);
ELSIF tn = 'SYS.VARCHAR' THEN
res := data.GETVARCHAR(chr);
ELSIF tn = 'SYS.NUMBER' THEN
res := data.GETNUMBER(num);
ELSIF tn = 'SYS.DATE' THEN
res := data.GETDATE(dat);
END IF;
END print_any;
CREATE OR REPLACE PROCEDURE history_dml(in_any IN SYS.ANYDATA)
IS
lcr SYS.LCR$_ROW_RECORD;
old_val SYS.LCR$_ROW_RECORD;
new_val SYS.LCR$_ROW_RECORD;
sql_text varchar2(4000) := 'insert into history_dml values (sysdate, ';
rc PLS_INTEGER;
BEGIN
-- Access the LCR
rc := in_any.GETOBJECT(lcr);
if lcr.get_command_type()='INSERT' then
-- Insert will only have new values, Update will have both old and new values and
-- Delete will only have old values.
new_val := lcr.get_values('NEW');
FOR i IN 1..new_val.COUNT LOOP
IF new_val(i) IS NOT NULL THEN
-- Make sure you put any quotes and commas here.
-- You can also create separate variables for the columns in the insert and
-- assign their values using print_any
sql_text := sql_text || print_any(oldlist(i).data);
END IF;
END LOOP;
execute immediate sql_text;
EXCEPTION
<handle any errors here>
END;

Similar Messages

  • Trouble Setting Up DML Handler for Journaling

    Hi Pat,
    I am trying to setup a simple DML handler for journaling of a table and cannot get it to work. Configuration is as follows:
    Source table
    Target table - updated via basic replication setup, this works fine.
    Target table journal - This table looks just like the original with additional columns for meta data about the transaction (i.e. trans_time, trans_type, trans_id..etc). Note: Did not use nested table technology.
    The problem is in compiling the user procedure for the DML handler we get an error on the INSERT part of the code:
    PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got -
    The code is listed below and the error points to the usage of the lcr.GET_VALUE package regardless of the column.
    Can you tell me if this is a correct usage of that package/procedure? Can you provide any better examples of DML handlers,preferbly for journaling? I understand from another thread you may have a new set of doc coming out. Maybe that can help me?
    I have a WORD doc w/pics that can better articulate the situation if it will help. Any direction is truely appreciated.
    Best Regards,
    Tom
    P.S. Is Oracle consulting spun up on this technology? We are not adverse to having profesional help to reduce our spinup time.
    CREATE OR REPLACE PROCEDURE contact_point_journal_dml(in_any IN SYS.ANYDATA)
    IS
    lcr SYS.LCR$_ROW_RECORD;
    rc PLS_INTEGER;
    BEGIN
    -- Access the LCR
    rc := in_any.GETOBJECT(lcr);
    -- Insert information in the LCR into the contact_point_journal table
    INSERT INTO strmuser.contact_point_journal
    VALUES
    (lcr.GET_VALUE('NEW', 'CONTACT_POINT_ID'),
    lcr.GET_VALUE('NEW', 'EFFECTIVE_DT'),
    lcr.GET_VALUE('NEW', 'VERSION'),
    lcr.GET_VALUE('NEW', 'CREATED_BY'),
    lcr.GET_VALUE('NEW', 'CREATED_TS'),
    lcr.GET_VALUE('NEW', 'CONTACT_CODE_ID'),
    lcr.GET_VALUE('NEW', 'ADDRESS1'),
    lcr.GET_VALUE('NEW', 'ADDRESS2'),
    lcr.GET_VALUE('NEW', 'ADDRESS3'),
    lcr.GET_VALUE('NEW', 'ADDRESS4'),
    lcr.GET_VALUE('NEW', 'CITY'),
    lcr.GET_VALUE('NEW', 'COUNTY'),
    lcr.GET_VALUE('NEW', 'STATE_PROVINCE_CODE_ID'),
    lcr.GET_VALUE('NEW', 'POSTAL_CODE'),
    lcr.GET_VALUE('NEW', 'COUNTRY_CODE_ID'),
    lcr.GET_VALUE('NEW', 'GEO_CODE'),
    lcr.GET_VALUE('NEW', 'OTHER_CONTACT_POINT_VALUE'),
    lcr.GET_VALUE('NEW', 'EXPIRATION_DT'),
    lcr.GET_VALUE('NEW', 'LAST_MODIFIED_BY'),
    lcr.GET_VALUE('NEW', 'LAST_MODIFIED_TS'),
    SYSDATE,
    lcr.GET_COMMAND_TYPE(),
    lcr.GET_TRANSACTION_ID(),
    lcr.GET_SCN(),
    lcr.GET_SOURCE_DATABASE_NAME(),
    lcr.GET_OBJECT_OWNER(),
    lcr.GET_OBJECT_NAME(),
    '1',
    'A'
    -- Apply row LCR
    -- Command type code may be '03' instead of 'insert' ???
    -- Is the syntax correct for SET statement ???
    lcr.SET_COMMAND_TYPE('INSERT');
    lcr.EXECUTE(true);
    END;

    Hi Tom,
    The GET_VALUE method of an LCR$ROW_RECORD returns a SYS.ANYDATA type.
    You need to specify one of the static access functions to get the value of the correct type.
    Here is your dml_handler with the modifications:
    CREATE OR REPLACE PROCEDURE contact_point_journal_dml(in_any IN SYS.ANYDATA)
    IS
    lcr SYS.LCR$_ROW_RECORD;
    rc PLS_INTEGER;
    BEGIN
    -- Access the LCR
    rc := in_any.GETOBJECT(lcr);
    -- Insert information in the LCR into the contact_point_journal table
    INSERT INTO strmuser.contact_point_journal
    VALUES
    (lcr.GET_VALUE('NEW', 'CONTACT_POINT_ID').AccessNumber(),
    lcr.GET_VALUE('NEW', 'EFFECTIVE_DT').AccessDate(),
    lcr.GET_VALUE('NEW', 'VERSION').AccessNumber(),
    lcr.GET_VALUE('NEW', 'CREATED_BY').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'CREATED_TS').AccessTimestamp(),
    lcr.GET_VALUE('NEW', 'CONTACT_CODE_ID').AccessNumber(),
    lcr.GET_VALUE('NEW', 'ADDRESS1').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'ADDRESS2').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'ADDRESS3').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'ADDRESS4').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'CITY').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'COUNTY').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'STATE_PROVINCE_CODE_ID').AccessNumber(),
    lcr.GET_VALUE('NEW', 'POSTAL_CODE').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'COUNTRY_CODE_ID').AccessNumber(),
    lcr.GET_VALUE('NEW', 'GEO_CODE').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'OTHER_CONTACT_POINT_VALUE').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'EXPIRATION_DT').AccessDate(),
    lcr.GET_VALUE('NEW', 'LAST_MODIFIED_BY').AccessVarchar2(),
    lcr.GET_VALUE('NEW', 'LAST_MODIFIED_TS').AccessTimestamp(),
    SYSDATE,
    lcr.GET_COMMAND_TYPE(),
    lcr.GET_TRANSACTION_ID(),
    lcr.GET_SCN(),
    lcr.GET_SOURCE_DATABASE_NAME(),
    lcr.GET_OBJECT_OWNER(),
    lcr.GET_OBJECT_NAME(),
    '1',
    'A'
    -- Apply row LCR, too
    lcr.EXECUTE(true);
    END;

  • DML Handler issue

    I am having a streams environment which is replicating say scott.emp bewteen to two database on two diffrent machine.
    I have a dml handler user procedure having body :-
    CREATE OR REPLACE PROCEDURE emp_dml_handler(in_any IN ANYDATA) IS 
    lcr          SYS.LCR$_ROW_RECORD;
      rc           PLS_INTEGER;
      command      VARCHAR2(30);
      old_values   SYS.LCR$_ROW_LIST;
    BEGIN   
      -- Access the LCR
      rc := in_any.GETOBJECT(lcr);
      -- Get the object command type
      command := lcr.GET_COMMAND_TYPE();
        -- Set the command_type in the row LCR to INSERT
      lcr.SET_COMMAND_TYPE('INSERT');
      -- Set the object_name in the row LCR to EMP_DEL
      lcr.SET_OBJECT_NAME('EMPLOYEE_AUDIT');
      -- Set the new values to the old values for update and delete
      IF command IN ('DELETE', 'UPDATE') THEN
          -- Get the old values in the row LCR
          old_values := lcr.GET_VALUES('old');
          -- Set the old values in the row LCR to the new values in the row LCR
          lcr.SET_VALUES('new', old_values);
          -- Set the old values in the row LCR to NULL
          lcr.SET_VALUES('old', NULL);
    END IF;
      -- Add a SYSDATE for upd_date
      lcr.ADD_COLUMN('new', 'UPD_DATE', ANYDATA.ConvertDate(SYSDATE));
      -- Add a user column
      lcr.ADD_COLUMN('new', 'user_name',
                                lcr.GET_EXTRA_ATTRIBUTE('USERNAME') );
      -- Add an action column
      lcr.ADD_COLUMN('new', 'ACTION', ANYDATA.ConvertVarChar2(command));
    -- Make the changes
      lcr.EXECUTE(true);
    commit;
    END;whn i associate this dml handler with my streams environment, it stops replicating the changes although inserts the data into audit table (using this dml handler)
    Can any body tell me why this is happening??
    If i unset this dml handler replication starts taking place.
    I am using 10Gr2.
    Thnaks
    Kapil

    Woot, we found the issue. Although the DML was running we forgot to add "SQL INSERT action" to the "Database Manipulation Request" property of the button.
    Cheers,
    Ghoulies

  • DML handler in streams.

    IS there any way to get the users information in a dml handler of streams?
    I want in my log table, the information about the user also who had performed the DML in an stream environment.
    My approach for DML handler is just like ...
    ----Log table
    CREATE TABLE strmadmin.history_row_lcrs(
    timestamp DATE,
    source_database_name VARCHAR2(128),
    command_type VARCHAR2(30),
    object_owner VARCHAR2(32),
    object_name VARCHAR2(32),
    tag RAW(10),
    transaction_id VARCHAR2(10),
    scn NUMBER,
    commit_scn NUMBER,
    old_values SYS.LCR$_ROW_LIST,
    new_values SYS.LCR$_ROW_LIST)
    NESTED TABLE old_values STORE AS old_values_ntab
    NESTED TABLE new_values STORE AS new_values_ntab;
    ---procedure for inserting value/user defined DML handler...
    CREATE OR REPLACE PROCEDURE history_dml(in_any IN ANYDATA)
    IS
    lcr SYS.LCR$_ROW_RECORD;
    rc PLS_INTEGER;
    BEGIN
    -- Access the LCR
    rc := in_any.GETOBJECT(lcr);
    -- Insert information about the LCR into the history_row_lcrs table
    INSERT INTO strmadmin.history_row_lcrs VALUES
    (SYSDATE, lcr.GET_SOURCE_DATABASE_NAME(), lcr.GET_COMMAND_TYPE(),
    lcr.GET_OBJECT_OWNER(), lcr.GET_OBJECT_NAME(), lcr.GET_TAG(),
    lcr.GET_TRANSACTION_ID(), lcr.GET_SCN(), lcr.GET_COMMIT_SCN,
    lcr.GET_VALUES('old'), lcr.GET_VALUES('new', 'n'));
    -- Apply row LCR
    lcr.EXECUTE(true);
    END;
    Thanks
    Kapil

    Hi Damorgan,
    I will try this in my stream environment, but i am little doubtfull that this will work. the reason why i am saying this is if i will right this in my user_proc which is a dml handler for my stream environment, then these statement will run on the DB where i have "apply process" and i am not sure what user id or seession id these statements will give in that case..any way thankyou for your attention on a post about streams. i will post the result soon.
    Kapil

  • How to update a column value by comparing old value by using DML Handler...

    Hi Can anyone post the DML Handler code for updating a column value by comparing the old value.
    Thanks,
    Ray

    Hi,
    Here is an example of a DML handler.
    BEGIN
    DBMS_APPLY_ADM.SET_DML_HANDLER(
    object_name => 'scott.emp',
    object_type => 'TABLE',
    operation_name => 'UPDATE',
    error_handler => false,
    user_procedure => 'strmadmin.update_column',
    apply_database_link => NULL,
    apply_name => 'MY_APPLY');
    END;
    This DML handler which will send any LCR matching the specified conditions to the strmadmin.update_column for customised processing.
    You can write the strmadmin.update_column procedure so that it extracts the old values from the LCR. You can then use the old values from the LCR to identify the row in the table. Once you identify the row, you can update it as you want.
    I haven't really tried to do any customised processing using DML handlers, but this should work.
    Hope this is of help.
    Sujoy

  • Doubt in user exit for transaction MM03

    Hi Friends,
        I have a doubt in user-exits. I have to add a button in MM03 which when clicked should open a particular URL taking material no. as the parameter.I have got the function for opening the URL, I just want to know which user exit should I be calling and in what way?Can anyone please give me step by step procedure as I am new in user exits.Thanks in advance....

    VA01 is a dialog program.  The use of WRITE statements in dialog program is really not done.
    You will need output your values to existing screen fields or create new ones in SE51.
    Sounds like you might want to review dialog prog in general.
    Also - the TABLES statement is for database tables.  It has nothing to do with internal tables.

  • Calling Oracle function and Procedure using OCCI with in C++ code

    Could any body send me the sample code to create and execute Oracle function and Procedure using OCCI concept in C++?.
    Edited by: 788634 on Aug 16, 2010 4:09 AM

    Hi Vishnu,
    Yes, sure, you can create a PL/SQL procedure, function, package, package body, etc. from within an OCCI application. I would say that, generally, this is not the sort of activity a typical client application would perform unless there is some initialization/installation processes that need to happen. In any case, here is a simple demo showing how to create a stand alone procedure (in a real application I would use a package and body) that returns a ref cursor. The ref cursor is just a simple select of two columns in the hr.countries sample table. Of course, there is no error handling, object orientation, etc. in this demo - I wanted to keep the code as short and as simple as possible to illustrate the concept.
    Regards,
    Mark
    #include <occi.h>
    #include <iostream>
    using namespace std;
    using namespace oracle::occi;
    int main(void)
      // occi variables
      Environment *env;
      Connection  *con;
      Statement   *stmt;
      ResultSet   *rs;
      // database connection information
      string user = "hr";
      string passwd = "hr";
      string db = "orademo";
      // sql to create the procedure which returns a ref cursor as out parameter
      // should be run as hr sample user or in a schema that has select privilege
      // on the hr.countries table and a synonym (countries) that points to the
      // hr.countries table
      string sqlCreate =
        "create or replace procedure get_countries(p_rc out sys_refcursor) as "
        "begin"
        " open p_rc for"
        " select country_id, country_name from countries order by country_name; "
        "end;";
      // pl/sql anonymous block to call the procedure
      string sqlCall = "begin get_countries(:1); end;";
      // create a default environment for this demo
      env = Environment::createEnvironment(Environment::DEFAULT);
      cout << endl;
      // open the connection to the database
      con = env->createConnection(user, passwd, db);
      // display database version
      cout << con->getServerVersion() << endl << endl;
      // create statement object for creating procedure
      stmt = con->createStatement(sqlCreate);
      // create the procedure
      stmt->executeUpdate();
      // terminate the statement object
      con->terminateStatement(stmt);
      // now create new statement object to call procedure
      stmt = con->createStatement(sqlCall);
      // need to register the ref cursor output parameter
      stmt->registerOutParam(1, OCCICURSOR);
      // call the procedure through the anonymous block
      stmt->executeUpdate();
      // get the ref cursor as an occi resultset
      rs = stmt->getCursor(1);
      // loop through the result set
      // and write the values to the console
      while (rs->next())
        cout << rs->getString(1) << ": " << rs->getString(2) << endl;
      // close the result set after looping
      stmt->closeResultSet(rs);
      // terminate the statement object
      con->terminateStatement(stmt);
      // terminate the connection to the database
      env->terminateConnection(con);
      // terminate the environment
      Environment::terminateEnvironment(env);
      // use this as a prompt to keep the console window from
      // closing when run interactively from the IDE
      cout << endl << "ENTER to continue...";
      cin.get();
      return 0;
    }

  • DML Handler for update - need help

    Hi,
    I am trying a simple DML handler to INSERT all the column values in a target table (CHANNELS_DML)..which are sourced from an updated table (CHANNEL). Both of these tables are in the same database.
    Here is the procedure I'm using for this purpose..
    +++++++++++++++++
    CREATE OR REPLACE PROCEDURE chn_dml_handler(in_any IN ANYDATA) IS
    lcr SYS.LCR$_ROW_RECORD;
    rc PLS_INTEGER;
    command VARCHAR2(30);
    old_values SYS.LCR$_ROW_LIST;
    old_pk_val sys.anydata;
    new_values SYS.LCR$_ROW_LIST := NULL;
    BEGIN
    rc := in_any.GETOBJECT(lcr);
    command := lcr.GET_COMMAND_TYPE;
    old_values := lcr.GET_VALUES('old');
    new_values := lcr.GET_VALUES('new');
    IF command = 'UPDATE' THEN
    old_values := lcr.GET_VALUES('old','y');
    lcr.SET_VALUES('new', old_values);
    lcr.ADD_COLUMN('new', 'TIMESTAMP', ANYDATA.ConvertDate(SYSDATE));
    lcr.ADD_COLUMN('new', 'OPERATION', ANYDATA.Convertvarchar2('UPDATE'));
    lcr.SET_COMMAND_TYPE('INSERT');
    lcr.SET_OBJECT_NAME('CHANNELS_DML');
    ELSIF command = 'DELETE' THEN
    lcr.SET_COMMAND_TYPE('INSERT');
    lcr.SET_OBJECT_NAME('CHANNELS_DML');
    lcr.SET_VALUES('new', old_values);
    lcr.SET_VALUES('old', NULL);
    lcr.ADD_COLUMN('new', 'TIMESTAMP', ANYDATA.ConvertDate(SYSDATE));
    lcr.ADD_COLUMN('new', 'OPERATION', ANYDATA.Convertvarchar2('DELETE'));
    ELSE
    lcr.SET_COMMAND_TYPE('INSERT');
    lcr.SET_OBJECT_NAME('CHANNELS_DML');
    lcr.ADD_COLUMN('new', 'TIMESTAMP', ANYDATA.ConvertDate(SYSDATE));
    lcr.ADD_COLUMN('new', 'OPERATION', ANYDATA.Convertvarchar2('INSERT'));
    END IF;
    lcr.EXECUTE(true);
    END;
    ++++++++++++++++++++
    INSERT, DELETE are working fine. However, when it comes to UPDATE I encounter "ORA-23605: invalid value "" for STREAMS parameter command_type".
    Would appreciate, if you can point me to any missed steps!
    Both source, target tables have the pk and supplemental logging is enabled for all the source tbl columns. (BTW, is it mandatory to enable supplemental logging ?)
    Thanks,
    Sharas

    You need to put this statement into IF 'UPDATE'
    lcr.SET_VALUES('old', NULL);
    old values in case of INSERT should be NULL.
    You may want to use case instead of IF ELSEIF...
    You might also have problems with LOBS... LOBs are not covered by this code.

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • Is it possible for one user to use Aperture and another iPhoto?

    I have a new imac 21.5", 3.33ghz, 4gb and I was wondering if it is possible for me as admin user to handle camera downloads automatically with Aperture, and my wife as second user to use iPhoto as automatic camera destination? Any comments would be appreciated.

    If you want to use the same account there are a number of possibilities:
    1. Set both Aperture and iPhoto to Do Nothing when a camera is connected. Then each one can launch their preferred app themselves. It's just one extra click.
    2. Use [Cameras|http://www.flexibits.com> to configure what happens when different cameras are connected.
    Regards
    TD

  • Error while Executing stored procedure using ant

    Hi,
    I am trying to execute a stored procedure using ant ..
    My build.xml is like this...
    <project name="myproject" default="db.build">
    <target name="db.build">
    <sql driver="oracle.jdbc.driver.OracleDriver"
    url="jdbc:oracle:thin:@idm.orademo.com:1521:orcl"
    userid="test"
    password="oracle11g"
    print="yes"
    classpath="E:\\ojdbc14.jar"
    src="E:\\upg_9102BP07.sql" />
    <!--
    <classpath>
    <pathelement path=""\\>
    <\\classpath> -->
    </target>
    </project>
    I have my stored procedure in upg_9102BP07.sql as shown in above src..
    When im executing ant cmd I got the following exception
    E:\>ant -f test.xml
    Buildfile: test.xml
    db.build:
    *[sql] Executing resource: E:\upg_9102BP07.sql*
    *[sql] Failed to execute: declare cnt int*
    BUILD FAILED
    E:\test.xml:12: java.sql.SQLException: ORA-06550: line 1, column 15:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    *:= . ( @ % ; not null range default character*
    Total time: 44 seconds
    I have no clue.. But this sql ran successfully when did manually..
    Please help me in solving the issue...
    -- Marias

    Here is my script bit lengthy...
    Rem
    Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_ddl_AddcolumnToRCE_Oracle.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:24:19 devjain Exp $
    Rem
    Rem 9102_ddl_AddcolumnToRCE_Oracle.sql
    Rem
    Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    Rem
    Rem NAME
    Rem 9102_ddl_AddcolumnToRCE_Oracle.sql - <one-line expansion of the name>
    Rem
    Rem DESCRIPTION
    Rem Create a new column 'RCE_DELETE' in RCE table
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem blaksham 09/30/09 - Created
    Rem
    declare cnt int;
    Begin
         Select Count(1) into cnt From User_Tab_Columns Where TABLE_NAME='RCM' And COLUMN_NAME='RCM_DELETE';
         IF cnt=0 Then
         Begin
              Execute Immediate 'ALTER TABLE RCM ADD RCM_DELETE VARCHAR2(1)';
         End;
         Else
              DBMS_OUTPUT.PUT_LINE('Column already exists in the DB');
         End IF;
    End;
    Rem
    Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_dml_odf_source_name.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:44:45 devjain Exp $
    Rem
    Rem 9103_dml_odf_source_name.sql
    Rem
    Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    Rem
    Rem NAME
    Rem 9103_dml_odf_source_name.sql - <one-line expansion of the name>
    Rem
    Rem DESCRIPTION
    Rem <short description of component this file declares/defines>
    Rem
    Rem NOTES
    Rem <other useful comments, qualifications, etc.>
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem vpotukuc 09/17/09 - Bug8796435: Increase the size of odf_source-name
    Rem vpotukuc 09/17/09 - Created
    Rem
    SET ECHO ON
    SET FEEDBACK 1
    SET NUMWIDTH 10
    SET LINESIZE 80
    SET TRIMSPOOL ON
    SET TAB OFF
    SET PAGESIZE 100
    declare
    collen NUMBER := 0;
    begin
    select char_length into collen from user_tab_columns where table_name = 'ODF' and column_name = 'ODF_SOURCE_NAME';
    IF (collen < 400) then
    execute immediate 'alter table ODF modify ODF_SOURCE_NAME varchar2(400)';
    END IF;
    END;
    File name: 91_dml_update_reviewers_With_NoEmail_attestation.sql
    Purpose: Modify the email template to replace the 'Delegated By Last Name' with 'Reviewer Last Name' and 'Delegated By User Id' to 'Reviewer User Id'.
    Author: Babu Lakshamanaiah
    Description: Modify the email template 'Attestation Reviewers With No E-mail Addresses Defined'
    declare
    cnt int;
    begin
    Select Count(1) into cnt From emd Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
    IF cnt=0 Then
    Begin
    DBMS_OUTPUT.PUT_LINE('There is no record with emd_name Attestation Reviewers With No E-mail Addresses Defined ');
    End;
    Else
    update emd set emd_body='The following attestation reviewers do not have email addresses defined. Attestation requests have been generated for these reviewers and can be accessed by loging in to Oracle Identity Manager. However, notification emails were not sent.' ||chr(10) || chr(10) ||
    'Attestation process: <Attestation Definition.Process Name>' || chr(10) ||
    'Attestation Request ID: request <Attestation Request.Request Id>' || chr(10) ||
    'Request date: <Attestation Request.Request Creation Date>' || chr(10) || chr(10) ||
    'Reviewers Without E-mail Address: <reviewers> ' || chr(10) ||
    '<Attestation Task.Reviewer First Name> <Attestation Task.Reviewer Last Name> [<Attestation Task.Reviewer User Id>]' Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
    End IF;
    commit;
    end;
    Please help me out.....
    --Marias                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Improve the performance in stored procedure using sql server 2008 - esp where clause in very big table - Urgent

    Hi,
    I am looking for inputs in tuning stored procedure using sql server 2008. l am new to performance tuning in sql,plsql and oracle. currently facing issue in stored procedure - need to increase the performance by code optmization/filtering the records using where clause in larger table., the requirement is Stored procedure generate Audit Report which is accessed by approx. 10 Admin Users typically 2-3 times a day by each Admin users.
    It has got CTE ( common table expression ) which is referred 2  time within SP. This CTE is very big and fetches records from several tables without where clause. This causes several records to be fetched from DB and then needed processing. This stored procedure is running in pre prod server which has 6gb of memory and built on virtual server and the same proc ran good in prod server which has 64gb of ram with physical server (40sec). and the execution time in pre prod is 1min 9seconds which needs to be reduced upto 10secs or so will be the solution. and also the exec time differs from time to time. sometimes it is 50sec and sometimes 1min 9seconds..
    Pl provide what is the best option/practise to use where clause to filter the records and tool to be used to tune the procedure like execution plan, sql profiler?? I am using toad for sqlserver 5.7. Here I see execution plan tab available while running the SP. but when i run it throws an error. Pl help and provide inputs.
    Thanks,
    Viji

    You've asked a SQL Server question in an Oracle forum.  I'm expecting that this will get locked momentarily when a moderator drops by.
    Microsoft has its own forums for SQL Server, you'll have more luck over there.  When you do go there, however, you'll almost certainly get more help if you can pare down the problem (or at least better explain what your code is doing).  Very few people want to read hundreds of lines of code, guess what's it's supposed to do, guess what is slow, and then guess at how to improve things.  Posting query plans, the results of profiling, cutting out any code that is unnecessary to the performance problem, etc. will get you much better answers.
    Justin

  • How to check which privileges user is using

    Hello All,
    I have a user assigned DBA role in mistake many years back.
    During our security overview I is flagged and now I need to revoke the DBA role from that user.At the moment it look like as follows and I am on 10204 database
    Privilege
    Category Granted Privilege
    Role Privs CONNECT
    DBA
    OEM_MONITOR
    RESOURCE
    Sys Privs ALTER ANY MATERIALIZED VIEW
    ANALYZE ANY
    CREATE ANY MATERIALIZED VIEW
    CREATE PROCEDURE
    CREATE ROLE
         CREATE SEQUENCE
    CREATE SESSION
    CREATE TABLE
    CREATE VIEW
    DROP ANY MATERIALIZED VIEW
    GLOBAL QUERY REWRITE
    UNLIMITED TABLESPACE
    Now I need to find what all privileges out of approx 158 in the DBA role this user is using so that I can revoke the DBA role and assign that sys privielege exclusively and later on trim down a bit on those as well if possible?
    Can someone help me in finding or is there a way possible to find out which privileges are actually being used by the user assigned to him via DBA role?
    I can find something on net on those lines, any help or useful pointers would be highly appreciated.
    Many Thanks,
    Rishi

    Hello All,
    Right I think auditing the DBA role could save my day.I have enable the auditing on the DB for dba role as shown below:
    audit_file_dest string /oraadmin/tgtx/10/adump
    audit_sys_operations boolean FALSE
    audit_syslog_level string
    audit_trail string DB, EXTENDED
    Exact version of the database is:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    I have enable the audit dba role for user exeter as shown:
    SYS@TGTX> AUDIT DBA by exeter WHENEVER SUCCESSFUL;
    Audit succeeded.
    Now I expect to audit all the sys privs assigned to dba role but alas its not working as expected if anyone can shed any light ON it, what I am trying to do is as follows:
    I am trying to use the sys priv that is create any table as user exeter who is assigned dba role as follows:
    SYS@TGTX> select * from dba_role_privs where grantee='EXETER';
    GRANTEE GRANTED_ROLE ADM DEF
    EXETER DBA NO YES
    EXETER CONNECT NO YES
    EXETER RESOURCE NO YES
    EXETER OEM_MONITOR NO YES
    EXETER@TGTX> create table dbaschema.test2 (srno number(10));
    Table created.
    Now I expect to see some records in dba_audit_trail as a result of above commands but there is none, am I doing anything wrong here?
    SELECT * FROM dba_audit_trail
    WHERE USERNAME = 'EXETER'
    ORDER BY timestamp;
    No rows returned but I shall have expected atleast one row to be returned here after enabling the audit on DBA role by exeter.
    Any Ideas?
    Thanks
    Rish

  • Stored Procedure used as a data source for an Apex report

    Just wondering whether anyone has used a Stored Procedure as the data source for an Apex report. An option to select Stored Procedures(s) as the data source does not appear within the IDE (only displays Table, Views, Functions).
    Do you have to return the definition of the Stored Procedure via a function ... if so, how is this done ?
    Thank you.

    >
    Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your profile with a real handle instead of "920338".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    Just wondering whether anyone has used a Stored Procedure as the data source for an Apex report. An option to select Stored Procedures(s) as the data source does not appear within the IDE (only displays Table, Views, Functions).
    Do you have to return the definition of the Stored Procedure via a function ... if so, how is this done ? When asking a question about "reports" it's firstly essential to differentiate between standard and interactive reports. Standard reports can be based on tables, views, SQL queries, or PL/SQL function blocks that return the text of a SQL query. Interactive reports can only be based on a SQL query.
    "Stored Procedures" are therefore not an option (unless you are using the term loosely to describe any PL/SQL program unit located in the database, thus including functions). What would a procedure used as the source of a report actually do? Hypothetically, by what mechanisms would the procedure (a) capture/select/generate data; and (b) make this data available for use in an APEX report? Why do you want to base a report on a procedure?

  • Calling store procedure using class cl_sql_statement not running

    Hello together
    i want to call a stored procedure that has an input and an output parameter but when i using my coding i m getting the following error
    ORA-06550: line 1, column 7:#PLS-00201: identifier 'STORED_PROC_NAME' must be declared#ORA-06550: line 1, column 7:#PL/SQL: Statement ignored
        GET REFERENCE OF lv_input  IN lr_dref."in
        lr_cl_sql_statement->set_param( data_ref = lr_dref
                            inout    = cl_sql_statement=>C_PARAM_IN ).
       GET REFERENCE OF lv_out INTO lr_dref. "out
        lr_cl_sql_statement->set_param( data_ref = lr_dref
                            inout    = cl_sql_statement=>C_PARAM_OUT ).
        TRY.
          data lv_ROWS_PROCESSED type i.
        CALL METHOD LR_CL_SQL_STATEMENT->EXECUTE_PROCEDURE
          EXPORTING
            PROC_NAME      ='Stored_Proc_Name'
          RECEIVING
            ROWS_PROCESSED = lv_ROWS_PROCESSED
    i my oppinion there could be an error in setting the parameters. Has anyone an running solution for calling a stored procedure with in and out parameter. I already tested the ADBC Programs and even had a sight in the class documentation but there is no example with in and output parameter.
    Thank your for your help!

    Hi
    Not sure as the exact  solution , but you can try the following :
    You are executing the "stored procedure"  as which user , is it under your schema and do you have execute priveleges on it.
    Please see below links , might be helpful to you :
    http://forums.devshed.com/java-help-9/call-stored-procedure-337312.html
    http://bytes.com/topic/oracle/answers/643380-pls-00201-identifier-user-procedure-name-must-declared
    Thanks
    Rishi

Maybe you are looking for

  • Inbound delivery against PO

    All SAP Gurus, We are using inbound delivery against purchase order (VL31N). Excess inbound delivery is not allowed. In case of vendor rejection/return, PO remains open (that is goods receipt can be done for the quantity equal to rejected quantity).

  • REQUEST HELP ON  JSP ODBC EXCEPTION ERROR

    hello. 1)currently im using the tomcat server 4.1.31 and am using jsp technology along with the microsoft access database as the backend. i havd placed the jsp files and the microsoft access database in a dir under the webapps/root/ on the tomcat ser

  • How to regenerate additional rows after user clicks enter?

    Hi all,           I am outputing the data through internal table(contains two fields 'Country' and 'Test')using ALV Classes. My requirement is user can add another row.And after appending another row user will enter country(say India) against the cou

  • Timestamp with the Transcription of the speech analysis

    Hi, I am working on a project right now where I need to add a timestamp to the transcribed text of a video, is that possible in Adobe Premiere, if it is how ? Thank you

  • Hp pavillion 15-b142dx usb 3.0 driver for windows 7

    Have a hp sleekbook 15-b142dx and down graded from windows 8 to windows 7. Can't find the right driver to make the two USB 3.0 ports work. The 2.0 USB port works just fine. This question was solved. View Solution.