Problem in calling procedure

Hi,
I am having one control table for triggers which is storing the procedure name, triggering event, when the trigger should be fired and other informations. I am having a procedure for calling the triggers and I am passing the parameters to it for when the trigger should be fired which proc should be called etc.
Now the proc code look like this:
PROCEDURE call_trg (
when_fire VARCHAR2,
for_what VARCHAR2,
triggering_event VARCHAR2,
p_table_name VARCHAR2,
p_data_type VARCHAR2,
p_field_descr VARCHAR2,
p_field_id VARCHAR2,
p_emp_id VARCHAR2,
p_tran_type VARCHAR2,
p_before_dt DATE,
p_after_dt DATE,
p_before_val VARCHAR2,
p_after_val VARCHAR2,
p_object_id VARCHAR2,
p_object_descr VARCHAR2
IS
CURSOR cur_procs_obj
IS
SELECT procedure_name
FROM control_table
WHERE table_name = p_table_name
AND fire_indicator = when_fire
AND for_what_ind = for_what
AND triggering_event_indicator = triggering_event
AND enabled_ind = 'E'
AND procedure_name like '%obj%';
CURSOR cur_procs_dt
IS
SELECT procedure_name
FROM control_table
WHERE table_name = p_table_name
AND fire_indicator = when_fire
AND for_what_ind = for_what
AND triggering_event_indicator = triggering_event
AND enabled_ind = 'E'
AND procedure_name like '%dt%';
BEGIN
FOR procs IN cur_procs_dt
LOOP
IF p_data_type = 'DATE' THEN
EXECUTE IMMEDIATE 'begin ' || procs.procedure_name(p_field_descr,p_field_id,p_emp_id,p_tran_type,p_before_dt,p_after_dt,p_object_id,p_object_descr) || '; end;';
END IF;
END LOOP;
FOR proc IN cur_procs_obj
LOOP
IF p_data_type <> 'DATE' THEN
EXECUTE IMMEDIATE 'begin ' || proc.procedure_name(p_field_descr,p_field_id,p_emp_id,p_tran_type,p_before_obj_id,p_after_obj_id,p_before_val,p_after_val,p_object_id,p_object_descr) || '; end;';
END IF;
END LOOP;
END;
Here the procedure_name is storing the name of the procedure which require input parameter. But when I compiling this code its throwing error:
Error: PLS-00224: object 'PROCS.PROC_NAME' must be of type function or array to be used this way
I dont want to make it a function as that procedure inserts the record to some table. I am using this control table for firing of trigger in a defined sequence mentioned in control table. Please let me know How I can achieve this.
cant I call the procedure in the way I did by passing the parameters?
Thanks.

Just a word of caution, It is not advisable to run code, stored in relational tables, dynamically the way it seems you are planning to do.
There are significant maintenance issues you'll face from not knowing which code and where.
Karthick, one of the gurus on this forum, was attempting something similar last year and Ask Tom pointed out all the pitfalls from such an approach.
Read about it here;
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1943344500346351703
You may think you'll be saving a few lines of code, but you'll spend hours and hours debugging!
Also, one final point, it seems as what you looking for is procedure overloading, which pl/sql does offer and this may be the way to go to satisfy your requirements;
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/subprograms.htm#i12352

Similar Messages

  • Problem with call procedure

    HI,
    i've a procedure which calls another procedure.
    This is the call:
    Export_inspection_Schema(portion);
    And the other procedure begins with
    CREATE OR REPLACE PROCEDURE Export_inspection_Schema (p_portion IN VARCHAR2)
    IS...
    But it doesn't work i always get this error messages:
    ORA-06502: PL/SQL: numeric or value error
    ORA-01722: Invalid Number
    What is wrong?
    Thanks for help.
    With best regards
    Nicole

    Somewhere you have got a string to number conversion on a variable that doesn't hold a valid number. If you're lucky it's an explicit call of TO_NUMBER() which is at least easy to search for. Otherwise you'll need to track down all the assignments where datatype conversion may occur (this includes DECODE, NVL, etc).
    If the error stack gave you a line number then that's where to start.
    Cheers, APC

  • Db Adapter: problems by calling a procedure with type as parameter

    Hi,
    We using a db adapter in a bpel process.
    In that dapter we call a procedure with types as in and out parameter
    package.procedure(p_in IN in_t, p_rsult OUT result_t).
    When we calling the procedure, we don't call the procedure directly.
    We call that procedure in a schema who have the execute rigths for the package and the types.
    When we run the process we get the error message
    unable to convert the xsd element p_in whose user defined type is in_t
    cause: java.sql.SQLException: ora-01436 connect by loop in user data
    I am not shore if I draw the right conclusions.
    Is it rigth that bpel have a problem by using types as parameter when using two schematas? Isn't it a bug.
    For every help I was thankful.
    Thanks in advanced.
    Michael

    Hi,
    thanks for the hint. I have implemented a wrapper package and it's working well.
    Only one crux. The parameter of the called procedure are data types and not simple types.
    CREATE OR REPLACE TYPE pesa_db_return_t AS OBJECT
    (SUCCESS_MSG varchar2(255)
    ,FAULT_SQLCODE varchar2(255)
    ,FAULT_SQLMSG varchar2(255)
    Wrapper package...
    IS
    PROCEDURE prc_writeReOinDB (p_AuftragRechnungOnline IN pesa_data.pesa_tivu_reo_t
    ,p_result OUT pesa_data.pesa_db_return_t)
    IS
    BEGIN
    pkg_pesa_reo.prc_writeReOinDB (p_AuftragRechnungOnline => p_AuftragRechnungOnline
    ,p_result => p_result
    END prc_writeReOinDB;
    END pkg_pesa_wrapper;
    So I have to declare the parameter with the schema user in front of.
    Now, we have deployed thes sources on a second enviroment and get following error:
    <2008-04-22 15:01:25,749> <ERROR> <eweber.collaxa.cube.engine.dispatch> <BaseScheduledWorker::process> Failed to handle dispatch message ... exception ORABPEL-05002
    Message handle error.
    An exception occurred while attempting to process the message "com.collaxa.cube.engine.dispatch.message.instance.CallbackDeliveryMessage"; the exception is: Type class not found.
    Cannot find class for type "org.apache.xerces.dom.ElementNSImpl". Please check that the class is located in the classpath.
    You have a hint for me what I have to do?
    Thanks in advanced,
    Michael

  • Problem to call stored procedure with several IN pars and single REF Cursor

    Hi,
    Oracle 9.2.0.1
    Ole DB Provider I've got with ODP 9.2.0.4
    First I try to call packaged procedure with single
    REF CURSOR - it works fine(PROCEDURE getDep(dep OUT DEPART.refcur) IS ...).
    When I try to call procedure with additional IN parameter, I get an error ORA-01008: not all variables bound.
    Packaged procedure: PROCEDURE getDep(dep OUT DEPART.refcur, i1 IN number) IS .... and so on.
    Try to call from C#:
    cmd.CommandText = "{call depart.getDep(?)}";
    OleDbParameter par0 = cmd.CreateParameter();
    par0.Value = some value;
    par0.DbType = DbType.Int16;
    par0.OleDbType = OleDbType.Integer;
    par0.Direction = ParameterDirection.Input;
    OleDbDataAdapter da = new OleDbDataAdapter(cmd.CommandText,con);
    DataSet ds = new DataSet();
    da.Fill(ds);
    Connection string:
    "Provider=OraOLEDB.Oracle;User Id=scott;Password=tiger;Data Source=ora92;OLEDB.NET=true;PLSQLRSet=true"
    Please, HELP !
    Thanks in advance,
    Vyacheslav

    Hi,
    Are you using OLEDB.NET driver (System.Data.Oledb) or ODP.NET driver (Oracle.DataAccess)?
    If you are using ODP.NET, remember that you need to bind the refcursor output variable also (besides the numbder)
    Arnold

  • Getting NLS setting issues when calling procedure

    Hi,
    Can anybody suggest me what could the problem in the below issue?.
    i am invokeing procedure using DBAdapter. My soa version is 11.1.1.5. When i am calling procedure first time it is working fine. But when i am invoke second time
    it is showing below error. I observed that i am getting error alternativly. So kinldy advice me what could be the issue.
    Error:
    Cause: java.sql.SQLException: ORA-20001: Oracle error -20001: ORA-20001: Oracle error -2074: ORA-02074: cannot SET NLS in a distributed transaction has been detected in fnd_global.set_nls.set_parameter('NLS_LANGUAGE','AMERICAN'). has been detected in fnd_global.set_nls. ORA-06512: at "APPS.APP_EXCEPTION", line 72 ORA-06512: at "APPS.FND_GLOBAL", line 240 ORA-06512: at "APPS.FND_GLOBAL", line 1410 ORA-06512: at "APPS.FND_GLOBAL", line 1655 ORA-06512: at "APPS.FND_GLOBAL", line 2171 ORA-06512: at "APPS.FND_GLOBAL", line 2313 ORA-06512: at "APPS.FND_GLOBAL", line 2251 ORA-06512: at
    Regards,
    Adhi

    Hi:
    Another way to avoid this, is to use an Non-XA Datasource.
    Hope this helps
    best

  • Calling procedure with user defined IN & OUT parameters

    I have procedure in a package which I need to call from the JDBC. My problem is, that procedure take user-defined data types as IN parameters & gives user-defined OUT paramters. How do I call a procedure like this. Do I need to write the wrapper class. If so from where do I start, I mean I don't have any idea about writing wrapper classes. Below is the package spec which might help you uderstand my question more clearly.
    CREATE OR REPLACE PACKAGE FAM_AR_SUMMARY_PKG IS
    TYPE ar_summ_rec_type IS RECORD (
    CUST_NAME hz_parties.party_name%TYPE,
    CUST_ACCT_NO hz_cust_accounts_all.ACCOUNT_NUMBER%TYPE,
    CUST_ACCT_BAL NUMBER,
    CUST_PAST_DUE_BAL NUMBER,
    CUST_UNAPP_REC_BAL NUMBER,
    CONTRACT_NO okc_k_headers_b.CONTRACT_NUMBER%TYPE,
    ANN_DATE okc_k_headers_b.END_DATE%TYPE,
    TOT_CONTRACT_VALUE okc_k_headers_b.ESTIMATED_AMOUNT%TYPE,
    PAST_DUE_AMT NUMBER,
    DAYS_PAST_DUE NUMBER,
    INV_PAST_DUE NUMBER,
    DEP_INV_BAL NUMBER,
    AMT_CREDITED NUMBER);
    TYPE ar_summ_tbl_type IS TABLE OF ar_summ_rec_type
    INDEX BY BINARY_INTEGER;
    PROCEDURE FAM_GET_AR_SUMMARY(p_cust_name IN hz_parties.party_name%TYPE,
    p_chr_id IN okc_k_headers_b.ID%TYPE,
    x_ar_summ_tbl OUT NOCOPY ar_summ_tbl_type,
    x_excp_message OUT VARCHAR2);
    END FAM_AR_SUMMARY_PKG;

    Hi,
    U cant get the type record from the DB with java. I hope u r using oracle. Instead u can create a Type object and then make it as an OUT parameter. Try reading the oracle documentation for it (JDBC Developer's Guide and Reference).
    Regards,
    Chandru.M

  • Call procedure while creating view in hana.

    Can we call procedure while creating a attribute view like
    CREATE VIEW "PAYROLLDBTEST"."@HourTransactionView"
    "DocEntry",
    "DocNum",
    "EmpID",
    "EmpCode",
    "FullName",
    "TableName",
    "TranName",
    "U_FromDate",
    "U_ToDate",
    "NoOfDays",
    "U_FromTime",
    "U_ToTime",
    "NoOfHours",
    "OvertimeHours",
    "UnpaidDays",
    "Weekends",
    "Holidays",
    "U_Remarks",
    "U_BatchNo",
    "ProjectCode"
    ) AS SELECT
      T0."DocEntry" AS DocEntry,
        T0."DocNum" AS DocNum,
       T0."U_EmpCode" AS EmpID,
    CALL PAYROLLDBTEST.GetEmpCodeFromEmployeeID('EmpID')  ,              (getting syntax error here).
        GetEmployeeFullName("@TRANSACTION_HOURS".U_EmpCode) AS FullName,
          T0."U_TransactionType" AS TranCode,
        GetHourTableName("U_TransactionType") AS TableName,
         GetHourTransactionName("U_TransactionType") AS TranName,
        T0."U_FromDate",
        T0. "U_ToDate",
          DAYS_BETWEEN("U_FromDate", "U_ToDate") + 1 AS NoOfDays,
          T0."U_FromTime" AS U_FromTime,
           T0."U_ToTime" AS U_ToTime,
        IFNULL("U_WorkHours", 0) AS NoOfHours,
         IFNULL("U_OvertimeHours", 0) AS OvertimeHours,
        IFNULL("U_PaidDays", 0) AS PaidDays,
         IFNULL("U_UnpaidDays", 0) AS UnpaidDays,
        IFNULL("U_WeekendsCount", 0) AS Weekends,
         IFNULL("U_HolidaysCount", 0) AS Holidays,
          T0."U_Remarks",
           T0."U_BatchNo",
        T0."U_ProjectCode" AS "ProjectCode"
        FROM
        "@TRANSACTION_HOURS" T0
        INNER JOIN
        "OHEM" T1
        ON
         T1."empID" = T0."U_EmpCode";

    Hello,
    The problem could be a SAPGUI related problem... Whats the current sapgui patch level ? Does it work when you try on another wokstation with the same user ?
    Could you please use SAPGUI 720 and update your patch level to 7 ? Then check the behaviour again.
    Best regards
    Rene

  • Call procedure without specifcation from shell scrip

    I am writing shell script. In that I am calling one of the procedure lets say "ABC" from package "V".
    exec V.abc ();
    problem is that procedure ABC does not have specifications in package. It has only body defined.
    I am getting error as procedure undefined.
    Is there any way to call procedure in the BODY part without specifications.
    Problem here is package is not owned by me so I can not change anything in that .
    Please suggest.
    Thanks in advance.

    No, the procedure is private in the package body. You can't access it if it is not in the package specification.
    Ask the owner of the package to declare it in the package specification, make it public...
    How do you know that this procedure exists anyway?

  • Call procedure across schema

    I have oracle 8i
    i have multiple identical schema for different country.
    i write one procedure in one schema(country_1) and granted to all others for execute.
    now i am connected to country_2 which doesn't have procedure,
    and i am calling procedure of country_1(which has a procedure).
    upto this everything is fine
    but problem is i want to
    execute the procedure on the recently connected schema(country_2),it is executing on country_1(where actual procedure is )
    Thanks,
    prathesh
    ([email protected])

    You need to add AUTHID CURRENT_USER to your create procedure command.
    From the documentation
    invoker_rights_clause
    The invoker_rights_clause lets you specify whether the procedure executes with the privileges and in the schema of the user who owns it or with the privileges and in the schema of CURRENT_USER.
    This clause also determines how Oracle resolves external names in queries, DML operations, and dynamic SQL statements in the procedure.
    TTFN
    John

  • Call procedure when button submited

    Hi all,
    I'm new to Oracle APEX... I've created a stored procedure which simply inserts records in a table. I have created a new page of type "Form on a procedure" with 2 btns Submit & Cancel and i want when the btn SUBMIT is pressed the values entered in field/parameters of the procedure/ to be inserted in my table. I just don't know where to put the logic...
    Any ideas?
    Thanks in advance,
    Bahchevanov.

    bahchevanov wrote:
    Hi ,
    I'm facing problems in call to my PL/SQL procedure. Here is what i typed in the box "Enter PL/SQL Page Process":
    declare
    v_res  varchar2(250);
    begin
    v_res := XX_EMPLOYEE_PKG.create_emp(P14_FIRST_NAME
    ,P14_LAST_NAME          
    ,P14_DEPARTMENT                          
    ,P14_SALARY                          
    ,P14_EMP_EG);
    end;but it throws me an error: ORA-06550: line 6, column 2: PLS-00201: identifier 'P14_LAST_NAME' must be declared ORA-06550: line 5, column 1: PL/SQL: Statement ignoredI guess i'm referring wrongly the fields in my page...
    P14_FIRST_NAME,,P14_LAST_NAME,P14_DEPARTMENT ,P14_SALARY ,P14_EMP_EG are the name of the fields in the page and each of them have to passed as a parameter of my procedure.
    Please help
    How items are referenced in various APEX contexts is covered in the documentation (in this case use bind variable syntax), all of which is available here.
    As you appear to be totally unfamiliar with basic APEX concepts, it would be an idea to complete the <a href="<i>2 Day + Application Express Developer's Guide</i> tutorial before going any further.

  • Calling procedures from table and apex

    Hi
    I have a stored procedures and I want to put my stored procedures in table and I want to call store procedure from table in apex. how can I do this?
    For example
    I have stored procedures like Students(year number,birimno number) 
    GPA(birimno number,studentno number ) Student Procedure and GPA proecdure retrieve name and lastname
    and I want to create a table
    table has
        Id            Package                 Procedurename                                   Arguments                              Header
          1                                                GPA                                 birimno, studentno                      name, lastname
          2                                                Students                          year, birimno                                name,lastnameSo how can I do like this ? I want to call storeprocedures on APEX with selectlist. Selectlist will has a storeprocedures .
    Edited by: esra aktas on 06.May.2011 01:48
    Edited by: esra aktas on 06.May.2011 01:48
    Edited by: esra aktas on 06.May.2011 04:08

    I am beginner pl/sql .
    I had searched execute immediate for helping my problem.
    My purpose is that I want to collect all of procedures in one table. And I must retrived which I select procedure on APEX Selectlist.
    So I started to create a table which name is procedures and I put my procedures names on it.
    Now how can I execute to procedures that name is in table?
    create or replace
    procedure "ISINIF_BASARI"(normalyariyil number,birimno number )
    IS
    ogrenci_no  VARCHAR2(12);
    ders_kodu  VARCHAR2(12);
    ders_adi   VARCHAR2(50);
    harf_kodu  VARCHAR2(4);
    CURSOR c_basari IS
    select  dk.ogrenci_no,da.ders_kodu,da.ders_adi,dk.harf_kodu
    into ogrenci_no,ders_kodu,ders_adi,harf_kodu
    from ders_aktif da,ders_tanim dt, ders_kayit dk
    where da.ders_kodu like  birimno ||'%'
    and (dt.normal_yariyili=normalyariyil
    OR dt.normal_yariyili=normalyariyil+1)
    and (da.acildigi_donem='1' or da.acildigi_donem='2')
    and dt.ders_kodu = da.ders_kodu
    and dk.acilan_ders_no = da.acilan_ders_no
    BEGIN
    FOR I IN c_basari LOOP
    dbms_output.put_line(' OGRENCI NO '||I.OGRENCI_NO||'  DERS KODU  '|| I.DERS_KODU||'  DERS ADI  '||I.DERS_ADI||' HARF KODU '||I.HARF_KODU);
    end loop;
    end;I have procedure like that.
    and I have a procedures table. And I put the procedure's name in table.
    procedure
    id procname
    1 ISINIF_BASARI
    Now I want to call procedure using this table .
    When I call yhe procedures from table I wrote like this. But it has faults.
    create or replace
    PROCEDURE CALLSPFROMTABLE  as
    v_sql_exp VARCHAR2(100);
    BEGIN
    v_sql_exp :='begin'||'select p.procname from procedure p where id=1'||'end;';
    end;Edited by: esra aktas on 07.May.2011 02:19

  • Calling Procedures form Report 6i

    I would highly appreciate it if I can get advise on how to call procedures from report 6i.
    My procedure requires two input parameters and returns about six columns in all. The problem I have is in trying to figure out how to display the values returned on the report.
    I checked the on-line help to no avail. Thanks.

    You can put placeholder columns in your data model group and populate them by using them as the OUT parameters in your stored procedure, called from a formula column. The placeholder columns can then have fields referencing them in the report layout.
    HTH
    Paul Williams

  • Call procedure with Spring and strange invalid index error.

    Hi I call a procedure, from java in this way:
    FlussiGiornalieriStoredProcedure proc = new FlussiGiornalieriStoredProcedure(dataSource);
                   String column_order="";
                   if (orderColumn!=null) {
                        column_order = orderColumn + " " + orderType;
                   } else {
                        column_order = " stato DESC "; //this is the invalid index column of the error               
    Map mappa = proc.execute(idGruppo, dataInizio, dataFine, startRow, endRow, column_order);
                   result = (List<VistaFlussiGiornalieri>) mappa.get("recordsetCursor");
                   numeroTotaleRighe = ((BigDecimal)mappa.get("countRow")).intValue();
    response.setSize(numeroTotaleRighe);
              response.setList((List<VistaFlussiGiornalieri>) result);
    private class FlussiGiornalieriStoredProcedure extends StoredProcedure {
            private static final String SQL = "mkt_flussi_giornalieri2";
            public FlussiGiornalieriStoredProcedure(DataSource ds) {             
                super(ds, SQL);
                declareParameter(new SqlParameter("idGruppo", Types.VARCHAR));
                declareParameter(new SqlParameter("dataInizio", Types.DATE));
                declareParameter(new SqlParameter("dataFine", Types.DATE));           
                declareParameter(new SqlParameter("startRow", OracleTypes.NUMBER));
                declareParameter(new SqlParameter("endRow", OracleTypes.NUMBER));
                declareParameter(new SqlParameter("column_order", OracleTypes.VARCHAR));
                //declareParameter(new SqlParameter("order_name", OracleTypes.VARCHAR));
                declareParameter(new SqlOutParameter("recordsetCursor", OracleTypes.CURSOR, VistaFlussiGiornalieriDaoImpl.this));
                declareParameter(new SqlOutParameter("countRow", OracleTypes.NUMBER, VistaFlussiGiornalieriDaoImpl.this));
                //declareParameter(new SqlOutParameter("QUERY_STM", OracleTypes.VARCHAR, VistaFlussiGiornalieriDaoImpl.this));
                compile();
            public Map execute(String idGruppo, Date dataInizio, Date dataFine, int startRow, int endRow, String column_order) {
                 Map inputs = new HashMap();
                 inputs.put("idGruppo", idGruppo);
                 inputs.put("dataInizio", dataInizio);
                 inputs.put("dataFine", dataFine);
                 inputs.put("startRow", startRow);
                 inputs.put("endRow", endRow);
                 inputs.put("column_order", column_order);
                return execute(inputs);
        }When The java class call the oracle procedure I receive this message:
    >
    Caused by: java.sql.SQLException: Invalid index column
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
         at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:385)
         at it.edison.markettracker.dao.spring.VistaFlussiGiornalieriDaoImpl.mapRow(VistaFlussiGiornalieriDaoImpl.java:155)
         at it.edison.markettracker.dao.spring.VistaFlussiGiornalieriDaoImpl.mapRow(VistaFlussiGiornalieriDaoImpl.java:1)
         at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92)
         at org.springframework.jdbc.core.JdbcTemplate.processResultSet(JdbcTemplate.java:1124)
         at org.springframework.jdbc.core.JdbcTemplate.extractOutputParameters(JdbcTemplate.java:1085)
         at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:997)
         at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:936)
         ... 26 more
    If I call the procedure, from toad, in this way:
    SET serveroutput ON
    DECLARE
    TROVATI SYS_REFCURSOR;
    NUMERO_TROVATI NUMBER;
    BEGIN
          DBMS_OUTPUT.ENABLE(30000);
          dbms_output.put_line('INIZIO');
          Mkt_Flussi_Giornalieri2(1, trunc(sysdate), trunc(sysdate), 100, 50, 'stato DESC', TROVATI, NUMERO_TROVATI);
          dbms_output.put_line('RECORD TROVATI:'||NUMERO_TROVATI);
    END; I don't receive any error message. Why?
    The procedure is:
    CREATE OR REPLACE PROCEDURE Mkt_Flussi_Giornalieri2
    ( idGruppo IN VARCHAR2
    , dataInizio IN DATE
    , dataFine IN DATE
    , startRow IN NUMBER
    , endRow IN NUMBER
    , column_order in varchar2
    --, order_name in varchar2
    , recordsetCursor OUT SYS_REFCURSOR
    , countRow OUT NUMBER
    ) IS
    order_clause varchar2(200) := ' ';
    sql_stm varchar2(32000);
    BEGIN
    IF column_order IS NOT NULL
    THEN
    order_clause := column_order;
    ELSE
    order_clause := ' stato DESC ';
    END IF;
    dbms_output.put_line('clausola:'||order_clause);
    sql_stm:='
         SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, log_info FROM
      (SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, log_info FROM
      (SELECT
    temp.flow_id AS idFlusso,
    MKT_FLOW.flow_id || '' - '' || MKT_FLOW.flow_description || ''('' || temp.exec_seq || '')'' AS descrizioneFlusso,
    TO_DATE(temp.date_id,''yyyymmddhh24miss'') AS dataRiferimento,
    TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''dd/mm/yyyy'')||'' h. ''||TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''hh24:mi'') AS strDataRiferimento,
    temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
    DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
    Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
                             mp.provider_link, mfc.log_info
    FROM (
      SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
      MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
      MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
      FROM (
        SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
        FROM mkt_flow_conf_view fc
        WHERE TRUNC(end_time) >= :1
          AND TRUNC(end_time) <= :2
      ) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
      WHERE v.exec_seq        = v.exsq
        AND e.fk_exec_seq (+) = v.exec_seq
        AND tr.fk_exec_seq (+) = v.exec_seq
        AND er.error_id (+) = e.error_code
    ) temp
    INNER JOIN MKT_FLOW
    ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
    INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
    LEFT OUTER JOIN
                             (SELECT DISTINCT flow_id, log_info
                                         FROM mkt_flow_conf) mfc
                             ON mkt_flow.flow_id = mfc.flow_id
                             , mkt_provider mp
    WHERE NVL(error_id, -1) = NVL(eid, -1)
      AND NVL(trace_id, -1) = NVL(tid, -1)
      AND MKT_FLOW_GROUP.group_id=:3
      AND NVL (mkt_flow.fk_provider_id, '' '') =
                                                         NVL (mp.provider_id, '' '') )
      WHERE ROWNUM <= :4
      MINUS
      (SELECT idflusso, descrizioneFlusso, dataRiferimento, strDataRiferimento,
            stato,  dataElaborazione, ultimoMessaggio, livello, utentiRiferimento,
            exec_seq, provider_description, log_info FROM
      (SELECT
    temp.flow_id AS idFlusso,
    MKT_FLOW.flow_id || '' - '' || MKT_FLOW.flow_description || ''('' || temp.exec_seq || '')'' AS descrizioneFlusso,
    TO_DATE(temp.date_id,''yyyymmddhh24miss'') AS dataRiferimento,
    TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''dd/mm/yyyy'')||'' h. ''||TO_CHAR(TO_DATE(temp.date_id,''yyyymmddhh24miss''),''hh24:mi'') AS strDataRiferimento,
    temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
    DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
    Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
                             mp.provider_link, mfc.log_info
    FROM (
      SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
      MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
      MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
      FROM (
        SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
        FROM mkt_flow_conf_view fc
        WHERE TRUNC(end_time) >= :5
          AND TRUNC(end_time) <= :6
      ) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
      WHERE v.exec_seq        = v.exsq
        AND e.fk_exec_seq (+) = v.exec_seq
        AND tr.fk_exec_seq (+) = v.exec_seq
        AND er.error_id (+) = e.error_code
    ) temp
    INNER JOIN MKT_FLOW
    ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
    INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
    LEFT OUTER JOIN
                             (SELECT DISTINCT flow_id, log_info
                                         FROM mkt_flow_conf) mfc
                             ON mkt_flow.flow_id = mfc.flow_id
                             , mkt_provider mp
    WHERE NVL(error_id, -1) = NVL(eid, -1)
      AND NVL(trace_id, -1) = NVL(tid, -1)
      AND MKT_FLOW_GROUP.group_id=:7
      AND NVL (mkt_flow.fk_provider_id, '' '') =
                                                         NVL (mp.provider_id, '' '') )
      WHERE ROWNUM <= :8
      )  ) ORDER BY :9' ;
    dbms_output.enable(30000);
    dbms_output.put_line(sql_stm);
    OPEN recordsetCursor FOR sql_stm USING dataInizio, dataFine, idGruppo, endRow, dataInizio, dataFine, idGruppo, startRow, order_clause;
       SELECT COUNT(*) INTO countRow FROM
      (SELECT
    temp.flow_id AS idFlusso,
    MKT_FLOW.flow_id || ' - ' || MKT_FLOW.flow_description || '(' || temp.exec_seq || ')' AS descrizioneFlusso,
    TO_DATE(temp.date_id,'yyyymmddhh24miss') AS dataRiferimento,
    TO_CHAR(TO_DATE(temp.date_id,'yyyymmddhh24miss'),'dd/mm/yyyy')||' h. '||TO_CHAR(TO_DATE(temp.date_id,'yyyymmddhh24miss'),'hh24:mi') AS strDataRiferimento,
    temp.status AS stato, temp.end_time AS dataElaborazione, DECODE(temp.status,3, ERROR_DESC, 1, TRACE_DES) AS ultimoMessaggio,
    DECODE(temp.status,3, error_level, 1, fk_trace_level) AS livello,
    Get_Group_Description(MKT_FLOW.flow_id) AS utentiRiferimento, temp.exec_seq AS exec_seq, mp.provider_description,
                             mp.provider_link, mfc.log_info
    FROM (
      SELECT v.*, tr.TRACE_ID, tr.TRACE_DES , tr.trace_date, tr.fk_trace_level, e.ERROR_ID, e.ERROR_CODE, NVL(e.ERROR_DESC, er.ERROR_DESC) AS ERROR_DESC, e.error_date, e.error_level,
      MIN(e.error_id) OVER (PARTITION BY e.fk_exec_seq) eid,
      MAX(tr.trace_id) OVER (PARTITION BY tr.fk_exec_seq) tid
      FROM (
        SELECT fc.*, MAX(exec_seq) OVER (PARTITION BY flow_id, flow_frequency, n_run, date_id) exsq
        FROM mkt_flow_conf_view fc
        WHERE TRUNC(end_time) >= dataInizio
          AND TRUNC(end_time) <= dataFine
      ) v, MKT_ERROR er, MKT_FLOW_ERROR e, MKT_FLOW_TRC tr
      WHERE v.exec_seq        = v.exsq
        AND e.fk_exec_seq (+) = v.exec_seq
        AND tr.fk_exec_seq (+) = v.exec_seq
        AND er.error_id (+) = e.error_code
    ) temp
    INNER JOIN MKT_FLOW
    ON MKT_FLOW.flow_id = temp.flow_id AND MKT_FLOW.n_run = temp.n_run AND MKT_FLOW.flow_frequency = temp.flow_frequency
    INNER JOIN MKT_FLOW_GROUP ON MKT_FLOW_GROUP.flow_id = MKT_FLOW.flow_id
    LEFT OUTER JOIN
                             (SELECT DISTINCT flow_id, log_info
                                         FROM mkt_flow_conf) mfc
                             ON mkt_flow.flow_id = mfc.flow_id
                             , mkt_provider mp
    WHERE NVL(error_id, -1) = NVL(eid, -1)
      AND NVL(trace_id, -1) = NVL(tid, -1)
      AND MKT_FLOW_GROUP.group_id=idGruppo
      AND NVL (mkt_flow.fk_provider_id, ' ') =
                                                         NVL (mp.provider_id, ' '));
    END Mkt_Flussi_Giornalieri2;
    /Please, could someone help me?
    Thanks. Bye Bye.

    Hi,
    I have solved the problem, I forgot a parameter in the select, so java tells the an error. But now I have another problem. The procedure doesn't execute the order by. I pass the couple column_name order_type in a string as ("provider_description desc") dinamically but the procedure doesn't execute the ordering. Why?
    Thanks, bye bye.

  • Problem sending calls from iPhone 4

    My iPhone 4 does not receive calls from my fixed home line - but sending calls anywhere is apparently no problem - have been through complete Apple procedure for resolving problem (reinitialisation etc) but without success - any ideas out there ?

    Thanks for responding so quickly !
    In response to your queries:
    - I have not yet consulted the carrier as yet (guess that is my next action tomorrow !)
    - The fixed phone only seems to have a problem in calling my cellphone and no other !
    -  I have not tried to call my cellphone yet from other fixed phones
    - My cellphone receives calls from other cellphones
    Hope this gives you a lead !

  • Use wcf-sql to call procedure

    when i use wcf-sql to call store procedure, i got problem:
    the store procedure like this:
    @variable_1 varchar(300);
    @variable_2 varchar(300);
    @variable_3 int;
    if LEN(@variable_1)<=1
    begin
         set @variable_2=0;
    end
    else
        set @variable_2=substring(@variable_1,1,LEN(@variable_1)-1); 
        set @variable_3= checksum(@variable_2);
    when the input parameter @variable_1 is empty value, it will raise two error: 1: invalid length parameter passed to the SUBSTRING function. 2: function "checksum" request at least 1 argument(s).
     it's so strange! how can i avoid this issue?

    Hi Jacky,
    Substring function can have length as positive integer only.
    SUBSTRING ( expression ,start , length )
    Length is a positive integer or bigint expression that specifies how many characters of the
    expression will be returned. If
    length is negative, an error is generated and the statement is terminated. If the sum of
    start and
    length is greater than the number of characters in
    expression, the whole value expression beginning at
    start is returned.
    Error (invalid length parameter passed to the SUBSTRING function) is result of this.
    i.e. when variable_1 = 0, length will return a negative integer.
    Error (function "checksum" request at least 1 argument(s)) is because the variable_2 is not assigned any value due to Error 1.
    Rachit
           thanks Rachit, but if @variable_1 is empty value,it should not execute
    "else" part. this is my question. how can it happen?

Maybe you are looking for