Apex3.2.1 pipelined functions with parameters send cpu to 100 percent

I have just installed 11g and exported a schema from 10g into it.
When I run Apex3.2.1 and open a page with a flash chart that running off a table object populated by a pipelined function the CPU goes in overload 100%.
I have tracked the problem to parameters on the pipelined function if I use bind parameters( :P640_YEARS, :P640_EMPLOYER_ID) then the problem happens but if I hard code values all is fine (2010,99).
This happens with every flash chart we have, which makes our application and database unusable.
Any ideas.
Derek

Thanks very much for the posts, I took the opportunity to upgrade to Apex 4.0.2 as suggested by Patrick and the application works fine again now.
Interestingly I did re-analyse the statistics but only as a reaction to the problem, should have been done regardless.
I did consider re-writing the pipelined functions but to be honest it would have been difficult as they are extremely complex, I wasn't looking forward to the task. I have become quite a fan of pipelined functions for building flash charts, dash boards extra, its as always about tuning the sql.
Thanks very to all
Derek
Edited by: 835735 on Feb 10, 2011 1:50 PM

Similar Messages

  • Pipelined function with lagre amount of data

    We would like to use pipelined functions as source of the select statements instead of tables. Thus we can easily switch from our tables to the structures with data from external module due to the need for integration with other systems.
    We know these functions are used in situations such as data warehousing to apply multiple transformations to data but what will be the performance in real time access.
    Does anyone have any experience using pipelined function with large amounts of data in the interface systems?

    It looks like you have already determined that the datatable object will be the best way to do this. When you are creating the object, you must enter the absolute path to your spreadsheet file. Then, you have to create some type of connection (i.e. a pushbutton or timer) that will send a true to the import data member of the datatable object. After these two things have been done, you will be able to access the data using the A3 - K133 data members.
    Regards,
    Michael Shasteen
    Applications Engineering
    National Instruments
    www.ni.com/ask
    1-866-ASK-MY-NI

  • Pipelined function with huge volume

    Hi all,
    I have a table of 5 million rows with an average length of 1K for each row (dss system).
    My SGA is 2G and PGA 1G.
    I wonder if a pipelined function could support a such volume ?
    Does anyone have already experienced a pipelined function with a huge volume ?
    TIA
    Yang

    Hello
    Well, just over a month later and we're pretty much sorted. Our pipelined functions were not the cause of the excessive memory consumption and the processes are are now no longer consuming as much PGA as they were previously. Here's what I've learnt.
    1. Direct write operations on partitioned tables require two direct write buffers to be allocated per partition. By default, these buffers are 256K each so it's 512K per partition. We had a table with 241 partitions which meant we inadvertently allocating 120MB of PGA without even trying. This is not a problem with pipelined functions.
    2. In 10.2 the total size of the buffers will be kept below the pga_aggregate_target, or 64k per buffer, whichever is higher. This is next to useless though as to really constrain the size of the buffers at all, you need a ridiculously small pga_aggregate_target.
    3. The size of the buffers can be as low as 32k and can be set using an undocumented parameter "_ldr_io_size". In our environment (10.2.0.2 Win2003 using AWE) I've set it to 32k meaning there will be 64k worth of buffers allocated to each partition significantly reducing the amount of PGA required.
    4. I never want to speak to Oracle support again. We had a severity 1 SR open for over a month and it took the development team 18 days to get round to looking at the test case I supplied. Once they'd looked at it, they came back with the undocumented parameter which worked, and the ridiculous suggestion that I set the PGA aggregate target to 50MB on a production box with 4GB and 300+ dedicated connections. No only that, they told me that a pga_aggregate_target of 50MB was sensible and did so in the most patronising way. Muppets.
    So in sum, our pipelined functions are working exceptionally well. We had some scary moments as we saw huge amounts of PGA being allocated and then 4030 memory errors but now it's sorted and chugging along nicely. The throughput is blistering especially when running in parallel - 200m rows generated and inserted in around 1 hour.
    To give some background on what we're using pipelined functions for....
    We have a list of master records that have schedules associated with them. Those schedules need to be exploded out to an hourly level and customised calendars need to be applied to them along with custom time-zone-style calculations. There are various lookups that need to be applied to the exploded schedules and a number of value calculations based on various rules. I did originally implement this in straight SQL but it was monsterous and ran like a dog. The SQL was highly complex and quite quickly became unmanageable. I decided to use pipelined functions because
    a) It immensely simplified the logic
    b) It gave us a very neat way to centralise the logic so it can be easily used by other systems - PL/SQL and SQL
    c) We can easily see what it is doing and make changes to the logic without affecting execution plans etc
    d) Its been exceptionally easy to tune using DBMS_PROFILER
    So that's that. I hope it's of use to anyone who's interested.
    I'm off to get a "pipelined fuinctions rule" tattoo on my face.
    David

  • Pipelined Function with execute immediate

    Hello Experts,
    I have created a Pipe lined function with execute immediate, due to below requirement;
    1) Columns in where clause is passed dynamically.
    2) I want to know the data stored into above dynamic columns.
    3) I want to use it in report, so I don't want to insert it into a table.
    I have created a TYPE, then through execute immediate i have got the query and result of that query will be stored in TYPE.
    But when calling the function i am getting
    ORA-00932: inconsistent datatypes: expected - got -
    Below is my function and type, let me know i am going wrong, and is my logic correct.
    CREATE OR REPLACE TYPE OBJ_FPD AS OBJECT
                      (LOW_PLAN_NO VARCHAR2 (40),
                       FPD VARCHAR2 (5),
                       SERIAL_NO NUMBER,
                       CEDIA_CODE VARCHAR2 (2),
                       DT DATE);
    CREATE OR REPLACE TYPE FPD_TBL_TYPE AS TABLE OF OBJ_FPD;
    CREATE OR REPLACE FUNCTION FUNC_GET_FPD_DATE (P_LOW_PLAN_NO    VARCHAR2,
                                                  P_CEDIA_CODE     VARCHAR2,
                                                  P_SERIAL_NO      NUMBER)
       RETURN FPD_TBL_TYPE
       PIPELINED
    AS
       CURSOR C1
       IS
              SELECT 'FPD' || LEVEL TBL_COL
                FROM DUAL
          CONNECT BY LEVEL <= 31;
       V_STR        VARCHAR2 (5000);
       V_TBL_TYPE   FPD_TBL_TYPE;
    BEGIN
       FOR X IN C1
       LOOP
          V_STR :=
                'SELECT A.low_PLAN_NO,
               A.FPD,
               A.SERIAL_NO,
               A.cedia_code,
               TO_DATE (
                     SUBSTR (FPD, 4, 5)
                  || ''/''
                  || TO_CHAR (C.low_PLAN_PERIOD_FROM, ''MM'')
                  || ''/''
                  || TO_CHAR (C.low_PLAN_PERIOD_FROM, ''RRRR''),
                  ''DD/MM/RRRR'')
                  DT FROM ( SELECT low_PLAN_NO, '
             || ''''
             || X.TBL_COL
             || ''''
             || ' FPD, '
             || X.TBL_COL
             || ' SPTS, SERIAL_NO, cedia_code FROM M_low_PLAN_DETAILS WHERE NVL('
             || X.TBL_COL
             || ',0) > 0 AND SERIAL_NO = '
             || P_SERIAL_NO
             || ' AND cedia_code = '
             || ''''
             || P_CEDIA_CODE
             || ''''
             || ' AND low_PLAN_NO = '
             || ''''
             || P_LOW_PLAN_NO
             || ''''
             || ') A,
               M_low_PLAN_DETAILS B,
               M_low_PLAN_MSTR C
         WHERE     A.low_PLAN_NO = B.low_PLAN_NO
               AND A.cedia_code = B.cedia_code
               AND A.SERIAL_NO = B.SERIAL_NO
               AND B.low_PLAN_NO = C.low_PLAN_NO
               AND B.CLIENT_CODE = C.CLIENT_CODE
               AND B.VARIANT_CODE = C.VARIANT_CODE
    CONNECT BY LEVEL <= SPTS';
          EXECUTE IMMEDIATE V_STR INTO V_TBL_TYPE;
          FOR I IN 1 .. V_TBL_TYPE.COUNT
          LOOP
             PIPE ROW (OBJ_FPD (V_TBL_TYPE (I).LOW_PLAN_NO,
                                V_TBL_TYPE (I).FPD,
                                V_TBL_TYPE (I).SERIAL_NO,
                                V_TBL_TYPE (I).CEDIA_CODE,
                                V_TBL_TYPE (I).DT));
          END LOOP;
       END LOOP;
       RETURN;
    EXCEPTION
       WHEN OTHERS
       THEN
          RAISE_APPLICATION_ERROR (-20000, SQLCODE || ' ' || SQLERRM);
          RAISE;
    END;Waiting for your views.
    Regards,

    Ora Ash wrote:
    Hello Experts,
    I have created a Pipe lined function with execute immediate, due to below requirement;
    1) Columns in where clause is passed dynamically.No, that's something you've introduced, and is due to poor database design. You appear to have columns on your table called FPD1, FPD2 ... FPD31. The columns do not need to be 'passed dynamically'
    2) I want to know the data stored into above dynamic columns.And you can know the data without it being dynamic.
    3) I want to use it in report, so I don't want to insert it into a table.That's fine, though there's no reason to use a pipelined function.
    You also have an pointless exception handler, which masks any real errors.
    I'm not quite sure what the point of your "connect by" is in your query as we don't have your tables or data or know for sure what the expected output is.
    However, in terms of handling the 'dynamic' part that you've introduced, then you would be looking at doing something along the following lines, using a static query that requires no poor dynamic code, and no pipelined function...
    with x as (select level as dy from dual connect by level <= 31)
    select a.low_plan_no
          ,a.fpd
          ,a.serial_no
          ,a.cedia_code
          ,trunc(c.low_plan_period_from)+a.dy-1 as dt
    from  (select low_plan_no
                 ,dy
                 ,'FPD'||dy as fpd
                 ,spts
                 ,serial_no
                 ,cedia_code
           from (
                 select low_plan_no
                       ,x.dy
                       ,case x.dy when 1 then fpd1
                                  when 2 then fpd2
                                  when 3 then fpd3
                                  when 4 then fpd4
                                  when 5 then fpd5
                                  when 6 then fpd6
                                  when 7 then fpd7
                                  when 8 then fpd8
                                  when 9 then fpd9
                                  when 10 then fpd10
                                  when 11 then fpd11
                                  when 12 then fpd12
                                  when 13 then fpd13
                                  when 14 then fpd14
                                  when 15 then fpd15
                                  when 16 then fpd16
                                  when 17 then fpd17
                                  when 18 then fpd18
                                  when 19 then fpd19
                                  when 20 then fpd20
                                  when 21 then fpd21
                                  when 22 then fpd22
                                  when 23 then fpd23
                                  when 24 then fpd24
                                  when 25 then fpd25
                                  when 26 then fpd26
                                  when 27 then fpd27
                                  when 28 then fpd28
                                  when 29 then fpd29
                                  when 30 then fpd30
                                  when 31 then fpd31
                        else null
                        end as spts
                       ,serial_no
                       ,cedia_code
                 from   x cross join m_low_plan_details
                 where  serial_no = p_serial_no
                 and    cedia_code = p_cedia_code
                 and    low_plan_no = p_low_plan_no
           where  nvl(spts,0) > 0
          ) A
          join m_low_plan_details B on (    A.low_plan_no = B.low_plan_no
                                        and A.cedia_code = B.cedia_code
                                        and A.serial_no = B.serial_no
          join m_low_plan_mstr C on (    B.low_plan_no = C.low_plan_no
                                     and B.client_code = C.client_code
                                     and B.variant_code = C.variant_code
    connect by level <= spts;... so just remind us again why you think it needs to be dynamic?

  • Pipelined function with Union clause(Invalid Number(ORA-01722) error )

    Hi,
    I have a pipelined function.
    I am fetching the data with the use of a REF cursor.
    The query has two part: query1 and query2
    when I am opeing the cursor with query1 UNION query2,it is giving me Invalid Number(ORA-01722) error.
    but when I open the cursor separately for query1 and query2,I am getting the resultset for each of the query.
    query1 and query2 are running fine with UNION in the sql editor.
    But,when I put them into two variables (var1 :='query1' and var2:='query2' and try to open the cursor with var1 UNION var2 , it's giving me the error.
    But when I put query2 as 'Select ..... from dual' and then try to open the cursor for query1 UNION query2,
    then getting the result of query1 and one extra row for query2(dual).
    The FROM table set is same for query1 and query2..
    can anyone please help me , why this Invalid Number(ORA-01722) error is coming.

    query1 := 'SELECT to_char(st.store_no) STORE_NUMBER,pp.name PROGRAM_NAME, ''HBS'' DISPENSING_SYSTEM,
    pt.PATIENT_SRC_NO SOURCE_ID, null RX2000_PATIENT_IDENTIFIER, pt.last_name PATIENT_LAST_NAME, pt.first_name
    PATIENT_FIRST_NAME, to_char(LPAD (pppd.rx_number, 7, '' '')|| ''-''|| LPAD (pppd.refill_number, 2, 0)) RX_REFILL
    FROM
    pega_patient_program_dispense pppd,pega_patient_program_reg pppr,health_care_profs hcp1,
    health_care_profs hcp2,prescription_dispenses pd,prescriptions p, pega_program_status_reason ppsr ,master_doctors md,
    prescription_disp_orders pdo, hbs_shipment_extract hse,stores st,master_stores ms,pega_programs pp,patients pt,master_patients mpt
    WHERE
    pppr.referring_hcp_id=md.id(+) and md.dispensing_system_id=hcp1.hcp_id and
    pppr.ID=pppd.PEGA_PATIENT_PROGRAM_REG_ID and pppd.prescription_dispense_id=pd.id and pd.prescriptions_id=p.id and
    p.hcp_id=hcp2.hcp_id and ppsr.ID=pppd.PEGA_PROGRAM_STATUS_REASON_ID and pppd.prescription_dispense_id = pdo.prescriptions_dispenses_id(+) AND
    pdo.shipment_number = hse.shp_no(+) and pppd.store_id=ms.id and st.id=ms.dispensing_system_id and pppr.pega_program_id=pp.id
    and pppr.patient_id=mpt.id and pt.patient_id=mpt.dispensing_system_id and pppd.dispensing_system=''HBS'' and pp.name LIKE ''REV%''
    AND
    ((pppd.prescription_dispense_id IS NOT NULL AND pppd.quantity_dispensed &gt; 0 AND pppd.reported_date IS NULL AND
    pppd.src_delete_date IS NULL AND ((pppr.program_specific_patient_code IS NULL ) OR (hcp1.last_name IS NULL) OR
    (hcp1.first_name IS NULL) OR (hcp2.first_name IS NULL) OR (hcp2.last_name IS NULL) OR (hcp2.address_1 IS NULL) OR
    (hcp2.city IS NULL) OR (hcp2.state_cd IS NULL) OR (hcp2.zip_1 IS NULL)OR (pppr.referral_date is NULL) OR
    (hcp1.state_cd IS NULL) OR (hcp1.zip_1 IS NULL)
    OR (hcp2.zip_1 IS NULL) OR (pppr.last_status_change_date IS NULL) OR (pppr.varchar_1 IS NULL) OR
    (pppr.varchar_7 IS NULL OR pppr.varchar_7 LIKE ''NOT AVAILABLE AT REFERRAL%'') OR (pppr.varchar_5 IS NULL OR
    pppr.varchar_5 LIKE ''NOT AVAILABLE AT REFERRAL%'')) ) AND ppsr.INCLUDE_ON_EXCEPTION_RPT_IND=''Y'')
    OR
    ((pppd.authorization_number IS NULL OR NVL(TRUNC(pdo.shipped_date),TRUNC(hse.shp_act_date_dt)) NOT BETWEEN
    TRUNC(pppd.date_1) AND TRUNC(pppd.date_2)) OR (pppd.varchar_4 IS NULL OR NVL(TRUNC(pdo.shipped_date),
    TRUNC(hse.shp_act_date_dt)) NOT BETWEEN TRUNC(pppd.date_3) AND TRUNC(pppd.date_5)))
    OR
    (pppr.pega_program_competitors_id IS NULL AND (ppsr.manufacturer_status=''TRIAGE'' AND ppsr.manufacturer_reason=''COMPETITOR''))
    OR
    (ppsr.manufacturer_reason IS NULL)
    query2 := ' SELECT ''150'' STORE_NUMBER,''test'' PROGRAM_NAME , ''RX2000'' DISPENSING_SYSTEM
    ,''01'' SOURCE_ID, null RX2000_PATIENT_IDENTIFIER, ''test'' PATIENT_LAST_NAME, ''test'' PATIENT_FIRST_NAME,
    ''rx01'' RX_REFILL
    FROM
    pega_patient_program_reg pppr,health_care_profs hcp1, pega_program_status_reason ppsr ,
    master_doctors md,stores st,master_stores ms,pega_programs pp,patients pt,master_patients mpt
    WHERE
    pppr.referring_hcp_id=md.id(+) and md.dispensing_system_id=hcp1.hcp_id and
    ppsr.ID=pppr.REFERRAL_STATUS_ID and st.store_type=''M'' and pppr.store_id=ms.id and st.id=ms.dispensing_system_id
    and pppr.pega_program_id=pp.id and pppr.patient_id=mpt.id and pt.patient_id=mpt.dispensing_system_id and pp.name LIKE ''REV%''
    AND
    ((((pppr.program_specific_patient_code IS NULL ) OR (hcp1.last_name IS NULL) OR (hcp1.first_name IS NULL) OR
    (pppr.referral_date is NULL) OR (hcp1.state_cd IS NULL) OR (hcp1.zip_1 IS NULL) OR (pppr.last_status_change_date IS NULL)
    OR (pppr.varchar_1 IS NULL) OR (pppr.varchar_7 IS NULL) OR (pppr.varchar_5 IS NULL OR pppr.varchar_5 LIKE
    ''NOT AVAILABLE AT REFERRAL%'')) ) AND ppsr.INCLUDE_ON_EXCEPTION_RPT_IND=''Y'')
    OR
    (pppr.pega_program_competitors_id IS NULL AND (ppsr.manufacturer_status=''TRIAGE'' AND ppsr.manufacturer_reason=''COMPETITOR''))
    OR
    (ppsr.manufacturer_reason IS NULL)
    AND
    pppr.id NOT IN(select pppd.PEGA_PATIENT_PROGRAM_REG_ID from PEGA_PATIENT_PROGRAM_DISPENSE pppd)';
    BUT IF I put
    query2 := ' SELECT ''150'' STORE_NUMBER,''test'' PROGRAM_NAME , ''RX2000'' DISPENSING_SYSTEM
    ,''01'' SOURCE_ID, null RX2000_PATIENT_IDENTIFIER, ''test'' PATIENT_LAST_NAME, ''test'' PATIENT_FIRST_NAME,
    ''rx01'' RX_REFILL
    FROM DUAL';
    then it is giving result.

  • Passing databse functions with parameters as custom parameters from comand

    Hi,
    I have a database function get_id(ichar varchar2) which will return a number which I am trying to pass to a mapping as custom inout parameter using the following command:
    @SQLplus_exec_template.sql RTUSER RTLOC PLSQL mapname "," "INPUT_ID=sample_pkg.get_id('I')"
    and I get the following error
    ------ start----------
    Session altered.
    Role set.
    override_custom_input_params(l_audit_execution_id, 'IN_FROM_DATE=1999/01/0108:00,IN_TO_DATE=2003/12/3108:00,BL_LOAD_ID=bl_job_control.get_bl_load_id('I')');
    ERROR at line 215:
    ORA-06550: line 215, column 155:
    PLS-00103: Encountered the symbol "I" when expecting one of the following:
    . ( ) , * @ % & | = - + < / > at in is mod not range rem =>
    .. <an exponent (**)> <> or != or ~= >= <= <> and or like
    between ||
    The symbol ". was inserted before "I" to continue.
    ------ end ----------
    However, the command line with NO parameter to the function like the following command works perfect:
    @SQLplus_exec_template.sql RTUSER RTLOC PLSQL mapname "," "INPUT_ID=sample_pkg.get_id"
    Will OWB commandline not accept function call with parameters? Please treat this as urgent and advice ASAP.
    Thanks.

    Thanks, Mark. It works.However facing another issue. I try to pass to_char(sysdate\,''yyyy/mm/ddhh:mi:ss'') as one of the custom parameters to the mapping as
    @SQLplus_exec_template.sql RTUSER RTLOC PLSQL mapname "," "INPUT_STDT=2002/10/2010:10:03,INPUT_enddt=to_char(sysdate\,''yyyy/mm/ddhh:mi:ss'')"
    and it erros out as
    ------ start ------
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0 ORA-06512: at line 1
    ------ end ------
    Questions:
    1. Why does a simple to_char(sysdate\,'yyyy/mm/ddhh:mi:ss') as an input parameter fail?
    2.what is the date format that OWB expects when we pass date as an input parameter.Can the format be modified?
    OWB seems to accept the format yyyy/dd/mm only. If I pass as different format, it errors with ORA 1861 Text: literal does not match format string.
    3. Where can I change the format in OWB if it can be changed.
    NOTE: OWB complains only about INPUT_ENDDT and not INPUT_STDT because, if I hardcode INPUT_ENDDT like 2003/11/178:00 it works.
    example:
    @SQLplus_exec_template.sql RTUSER RTLOC PLSQL mapname "," INPUT_STDT=2002/10/2008:00,INPUT_ENDDT=2003/11/1706:45:59"
    works fine.
    Am I missing something here?
    Thanks again.

  • Using pipelined functions with bind variables in Apex...

    Hy all:
    I have a table which has about 10 million records and it is hanging up the system when it is trying to retrieve the data from that table... so what I have done is I created a pripelined
    function and then trying to retrieve data using an SQL statement ... when I try to use a bind variable to filter by the date and location it is binding according to the location
    but not by date ... can anyone help me in this please!!
    Help greatly appreciated !
    Thanks in advance !

    Hi Denes:
    Create or replace type ohe1 as object (
    IMLITM NCHAR(50), IMAITM NCHAR(50), IMDSC1 NCHAR(60), COUNCS NUMBER(22), LIPQOH NUMBER(22),
    LIMCU NCHAR(24), LILOCN NCHAR(40), LILOTN NCHAR(60), LILOTS NCHAR(2), IOMMEJ NUMBER(22))
    CREATE OR REPLACE TYPE OHE AS TABLE OF Ohe1
    CREATE OR REPLACE FUNCTION GET_ohe
    return OHE PIPELINED
    IS
    m_rec ohe1:= ohe1 (NULL,NULL,NULL,0,0,NULL,NULL,NULL,NULL,0);
    begin
    for c in (select f1.LITM LITM, F1.AITM AITM, F1.DSC1 DSC1, F5.UNCS UNCS,
    F21.QOH QOH, F21.MCU MCU, F21.LOCN LOCN, F21.LOTN LOTN, F21.LOTS LOTS,
    F8.MEJ MEJ FROM F1 F1, F2 F2, F21 F21, F5 F5, F8 F8
    WHERE (F5.EDG='07') AND (F21.QOH != 0) AND F2.IBITM = F1.IMITM
    AND F21.ITM = F2.ITM AND F21.ITM = F5.ITM AND F21.MCU = F5.MCU
    AND F21.MCU = F2.MCU AND F21.LOTN = F8.LOTN AND F21.MCU = F8.MCU)
    loop
    m_rec.LITM:=c.LITM;
    m_rec.AITM:=c.AITM;
    m_rec.DSC1:=c.DSC1;
    m_rec.UNCS:=c.UNCS;
    my_record.QOH:=c.QOH;
    my_record.MCU:=c.MCU;
    my_record.LOCN:=c.LOCN;
    my_record.LOTN:=c.LOTN;
    my_record.LOTS:=c.LOTS;
    my_record.MEJ:=c.MEJ;
    PIPE ROW (my_record);
    end loop;
    return;
    end;
    select LITM , AITM , DSC1 , UNCS*.0001 UNCS, QOH*.0001 QOH, (UNCS*.0001)*(QOH*.0001) AMOUNT,
    MCU MCU, LOCN LOCN, LOTN LOTN, LOTS LOTS, jdate(DECODE(MEJ,0,100001,MEJ)) MEJ FROM
    TABLE (GET_ohe)
    WHERE trim(LIMCU)= TRIM(:OHE_BRANCHID)
    AND (jdate(DECODE(MEJ,0,10001,MEJ)) >=:FROMEXPDT
    AND jdate(DECODE(MEJ,0,10001,MEJ)) <=:TOEXPDATE)
    The MEJ is a julian date and I am trying to convert it into a date ..... using the function jdate! and the pipelined function is created without any errors
    and I am able to get the data with correct branch location bind variable but only problem is it is not binding the date filters in the sql.....
    Thanks
    Edited by: user10183758 on Oct 16, 2008 8:17 AM

  • Executing a oracle function with parameters ...

    Hi All,
    I'm trying to execute this part of the code:
    <cfdirectory action="list"
    directory="#getDirectoryFromPath(sharedPath)#"
    name="currentDir">
    <cfoutput query="currentDir">
    <cfset filename = sharedPath & name>
    <cfif find(".csv",name)>
    <cfexecute name = "#Application.c_script_dropfileupload_path#main_dropfileupload.sh"
    arguments = """#name#"" ""#sharedPath#"""
    variable = "Variables.upload_progress"
    timeout = "500">
    </cfexecute>
    <tr>
    <td colspan="3" class="text">
    <cfquery name="getvalcount"
    datasource="#Application.c_dsn#"
    dbtype="ODBC"
    password="#Session.Password#"
    username="#Session.UserID#">
    SELECT pk_cpv_drop_file_upload.sf_drop_validate_and_count(replace(#name#,".csv","")) FROM dual
    </cfquery>
    <cfoutput> #getvalcount.sf_drop_validate_and_count# </cfoutput>
    </td>
    </tr>
    but I'm receiving the error from oracle telling: illegal zero-length identifier
    My question is...
    IS there a way to pass the parameter #name# to this function sf_drop_validate_and_count ? or should I work with parameters to a stored procedure?
    Thanks in advance
    Regards
    Alex

    Hi ALL,
    Just to inform you that I've found a solution when you need to apply variables as a parameter:
    preserveSingleQuotes(vFileName)
    preserveSingleQuotes function will keep the string like this 'dadsadsad' and so, you can use it inside your functions, procedures, etc..
    Thanks for all the reponses I've received.
    Best regards
    Alex

  • Pipelined functions with spatial data

    hi,
    i've been trying to use pipelined functions (using the TABLE and CAST operators to query data from them) to retrieve large amounts of spatial data.
    i've followed the examples on metalink, and they work fine. my problem arises when i apply similar functions to query data using SDO_FILTER, i've been trying to pipe a mdsys.sdo_geometry datatype (ref cursor) into the function - returns null.
    are spatial datatypes supported for use in pipelined functions, and using the table and cast operators?
    if they are, where can i find further reading/reference on the subject?
    thanks
    santosh sewlal

    Check out http://otn.oracle.com/products/spatial/pdf/mapviewerfaq_31.pdf
    or
    You can look for a third party solution that can draw maps.
    Then you call out to this component from Forms.

  • Call Plugin-Function with parameters via JavaScript

    Hi!
    I have following problem: I wrote a plugin for Illustrator CS2 in C++ and now I would like to call a function of the plugin from outside of illustrator (from a JavaScript).
    This can be done with the Actionsuite. But how could I then give some parameters to my function?
    For example:
    In the plugin, I have a function "void myFun(char * test)" and I want to call this function in JavaScript with test="Hello World" for example.
    The only possible way right now seems to write parameters into a file and open that file in the plugin to "receive" them.

    Hi,
    Could you send your plugin coding.
    Regards,
    Maria

  • AddEventListener and Function with Parameters

    Hello guys
    I got this situation
    nameTxt.addEventListener(FocusEvent.FOCUS_IN,formTextHandler);
             private function formTextHandler(text:String):void{
    where i want to send some additional information too
    so how could i do that?
    Thanks

    hi,
       it seems like you will need to extend your text Component and Event class as well. Its not clear from your code that what component you are referring to . so generally you will extend your required component .
    you will need to addEvent Listener
    FocusEvent.FOCUS_IN
    in your custom extended component and in the handler of that focusEvent you will dispatch your new custom event with the parameters from this FocusEvent you received and as well as new parameters that are also required by your new extended Event.
    Method of extending events is straight forward. e.g this a sample for extending Events you will need to modify it with the paramaters you require in your event .
    package
        import flash.events.Event;
        public class AccountEvent extends Event
            public var accountObj:Object
            public static var NewAccount:String='newAccount'
            public function AccountEvent(type:String,newAccount:Object)
                super(type)
                this.accountObj=newAccount
    and here is the code how to use this event
    package
        import flash.events.Event;
        import flash.events.FocusEvent;
        import AccountEvent
        import mx.controls.TextInput
        public class customText extends TextInput
            public function customText()
                super();
                addEventListener(FocusEvent.FOCUS_IN,onFocus)
            private function onFocus(e:FocusEvent):void{
                dispatchEvent(new AccountEvent(paramaters.....///here you will add your custom paramerters and 
               //you will catch this event in your main application rather then catching the focus in event

  • How to call a function with parameters in ScriptStart function

    i am trying to call ScriptStart function from SUD dialog. This is how iam calling Call ScriptStart(path & "test.vbs","abc") abc is function which is written test.vbs. It is working. But when i want to pass some parameters to the abc function of test.vbs. It is not working why. can anybody suggest where i went wrong. I am calling the same function as Call ScriptStart(path & "test.vbs","abc(" & text1.Text & ")"). It is not working why ? Is the ScriptStart function only point to functions. it does not take any parameters or waht ?

    Hi abc421,
    Another option in addition to UserCommands would be to use ScriptInclude(path). If you execute a ScriptInclude(path) command at the beginning of your VBScript, then all the functions and Subs in the VBscript located at "path" are now available to you-- including passing parameters and receiving return values from functions. If you are calling a VBscript that uses only VBScript variables, then this is the preferred method.
    If instead you are calling a VBScript that uses global DIAdem variables declared in a VAS file (their variable names all end with the "_" character), then those parameters are already available at the subroutine called with ScriptStart(path, routine).
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Use of IN function with parameters?

    is it possible to use a parameter with an IN function, inside an explicit cursor?
    oracle doesn't accept varchars or collections.
    it should be something like this:
    CURSOR (myParam VARCHAR2) IS
    SELECT *
    FROM myTable
    WHERE myColumn IN (myParam);
    Thank you!
    Saverio M.

    Sorry just one correction
    Do you mean Parameterized Cursors ?
    declare
    v_emp number;
    v_emp1 number;
    cursor c1(v_emp in number)
    is
    select * from empdept where empno=v_emp;
    begin
    v_emp1 :=9939; -- For Example you
    for x in c1(v_emp1)
    loop
    --- Do your processes.
    null;
    end loop;
    end;
         | Legal | Privacy

  • [8i] Help with function with parameters (for workday calculation)

    Let me start by saying, I've never written a function before, and I don't have access to create a function in my database (i.e. I can't test this function). I'm trying to come up with a function that I can ask my IT department to add for me. I'm hoping someone can take a look at what I've written and tell me if it should work or not, and if this is the right way to go about solving my problem.
    I am trying to create a function to do a very simple workday calculation (adding/subtracting a particular number of workdays from a calendar date).
    The database I'm working with has a table with the workday calendar in it. Here is a sample table and sample data, representative of what's in my workday calendar table:
    CREATE TABLE caln
    (     clndr_dt     DATE,
         shop_days     NUMBER(5)
         CONSTRAINT caln_pk PRIMARY KEY (clndr_dt)
    INSERT INTO     caln
    VALUES (To_Date('01/01/1980','mm/dd/yyyy'),0);
    INSERT INTO     caln
    VALUES (To_Date('01/02/1980','mm/dd/yyyy'),1);
    INSERT INTO     caln
    VALUES (To_Date('01/03/1980','mm/dd/yyyy'),2);
    INSERT INTO     caln
    VALUES (To_Date('01/04/1980','mm/dd/yyyy'),3);
    INSERT INTO     caln
    VALUES (To_Date('01/05/1980','mm/dd/yyyy'),3);
    INSERT INTO     caln
    VALUES (To_Date('01/06/1980','mm/dd/yyyy'),3);
    INSERT INTO     caln
    VALUES (To_Date('01/07/1980','mm/dd/yyyy'),4);
    INSERT INTO     caln
    VALUES (To_Date('01/08/1980','mm/dd/yyyy'),5);
    INSERT INTO     caln
    VALUES (To_Date('01/09/1980','mm/dd/yyyy'),6);
    INSERT INTO     caln
    VALUES (To_Date('01/10/1980','mm/dd/yyyy'),7);
    INSERT INTO     caln
    VALUES (To_Date('01/11/1980','mm/dd/yyyy'),8);
    INSERT INTO     caln
    VALUES (To_Date('01/12/1980','mm/dd/yyyy'),8);
    INSERT INTO     caln
    VALUES (To_Date('01/13/1980','mm/dd/yyyy'),8);
    INSERT INTO     caln
    VALUES (To_Date('01/14/1980','mm/dd/yyyy'),9);The actual table includes from 1/1/1980 though 12/31/2015.
    I've written (and validated) this parameter query which does my workday (mday) calculation:
    SELECT     cal.clndr_dt
    FROM     CALN cal
         SELECT     cal.shop_days+:mdays     AS new_shop_days
         FROM     CALN cal
         WHERE     cal.clndr_dt     =:start_date
         ) a
    WHERE     cal.shop_days     = a.new_shop_days
    AND     ROWNUM          =1
    ORDER BY     cal.clndr_dt;Based on this query, I've created the following function (and I have no clue if it works or if the syntax is right, etc.):
    CREATE OR REPLACE FUNCTION add_mdays
         (start_date     IN DATE,
         mdays          IN NUMBER(5))
    RETURN     DATE
    IS
         new_date DATE;
    BEGIN
         SELECT     cal.clndr_dt
         FROM     CALN cal
              SELECT     cal.shop_days+mdays     AS new_shop_days
              FROM     CALN cal
              WHERE     cal.clndr_dt     =start_date
              ) a
         WHERE     cal.shop_days     = a.new_shop_days
         AND     ROWNUM          =1
         ORDER BY     cal.clndr_dt;
         RETURN     new_date;
    END add_mdays;  //edit 9:31 AM - noticed I left off this bitI'm also not sure how to have the function handle results that would return a date outside of the date range that is in the table (Before 1/1/1980 or after 12/31/2015--or, another way to look at it is, before the MIN value of caln.clndr_dt or after the MAX value of caln.clndr_dt).
    My goal is to be able to use the function in a situation like the following:
    First, here's a sample table and data:
    CREATE TABLE orders
    (     ord_no          NUMBER(5),
         plan_start_dt     DATE,
         CONSTRAINT orders_pk PRIMARY KEY (ord_no)
    INSERT INTO orders
    VALUES (1,To_Date('01/08/1980','mm/dd/yyyy'));
    INSERT INTO orders
    VALUES (2,To_Date('01/09/1980','mm/dd/yyyy'));
    INSERT INTO orders
    VALUES (3,To_Date('01/10/1980','mm/dd/yyyy'));And here is how I would like to use my function:
    SELECT     orders.ord_no
    ,     orders.plan_start_dt
    ,     add_mdays(orders.plan_start_dt, -3) AS prep_date
    FROM     ordersThus, the function would allow me to return, for every order in my orders table, the date that is 3 workdays (mdays) prior to the plan start date of each order.
    Am I going about this the right way? Do I need to create a function to do this, or is there a way for me to incorporate my query (that does my mday calculation) into the sample query above (eliminating the need to create a function)?
    Thanks much in advance!
    Edited by: user11033437 on Feb 2, 2010 8:55 AM
    Fixed a couple typos in the last insert statements
    Edited by: user11033437 on Feb 2, 2010 9:31 AM (fixed some syntax in the function)

    Hi,
    Ah, mentioning Oracle 8 and not being able to test your own code makes me nostalgic for the good old days, when you typed your cards, and brought them to a window at the computer center, and waited an hour for the job to run, and then saw the printout to find that you had made a typo.
    If you're going to write functions, you really need to test them yourself. Like all code, functions whould be written in baby steps: write a line or two (or sometimes just part of what will later become one line), test, make sure it's running correctly, and repeat.
    Ideally, your employer should create a developement schema in a development database for you to use.
    You can legally download your own instance of Oracle Express Edition for free; just be careful not to use features that aren't available in the database where the code will be deployed.
    You don't need a function to get the results you want:
    SELECT       o.ord_no
    ,       o.plan_start_dt
    ,       MIN (e.clndr_dt)     AS prep_date
    FROM       orders     o
    ,       caln          l
    ,       caln          e
    WHERE       l.clndr_dt     = o.plan_start_dt
    AND       e.shop_days     = l.shop_days - 3
    GROUP BY  o.ord_no
    ,            o.plan_start_dt
    ;This would be more efficient (and a little simpler) if you added a column (let's call it work_day) that identified if each row represented a work_day or not.
    For each value of shop_days, exactly 1 row will be marked as a work day.
    Then the query might be something like:
    SELECT       o.ord_no
    ,       o.plan_start_dt
    ,       e.clndr_dt          AS prep_date
    FROM       orders     o
    ,       caln          l
    ,       caln          e
    WHERE       l.clndr_dt     = o.plan_start_dt
    AND       e.shop_days     = l.shop_days - 3
    AND       e.work_day     = 1
    ;You could use the analytic LAG function to populate the work_day column.
    A function would certainly be handy, though perhaps slower.
    The function you posted has a few mistakes:
    (a) An argument can't be declared as NUMBER (5); just NUMBER.
    (b) When you SELECT in PL/SQL, like you're doing, you have to SELECT INTO some variable to hold the results.
    (c) ROWNUM is arbitrary (which makes it useless in this problem) unless you are drawing from an ordered sub-query. I don't think you can use ORDER BY in sub-queries in Oracle 8. Use the analytic ROW_NUMBER function instead.
    (d) The function must end with an END statement.
    Given your current caln table, here's how I would write the function:
    CREATE OR REPLACE FUNCTION add_mdays
         ( start_date     IN           DATE          DEFAULT     SYSDATE,
           mdays          IN           NUMBER          DEFAULT     1
    RETURN     DATE
    DETERMINISTIC
    IS
         --     add_mdays returns the DATE that is mdays working days
         --     after start_date.  (If mdays < 0, the DATE returned
         --     will be before start_date).
         --     Work days do not include Saturdays, Sundays or holidays
         --     as indicated in the caln table.
         new_date     DATE;          -- to be returned
    BEGIN
         SELECT     MIN (t.clndr_dt)
         INTO     new_date
         FROM     caln     f     -- f stands for "from"
         ,     caln     t     -- t stands for "to"
         WHERE     f.clndr_dt     = TRUNC (start_date)
         AND     t.shop_days     = f.shop_days + TRUNC (mdays)
         RETURN     new_date;
    END     add_mdays;
    SHOW ERRORSProduction code whould be robust (that includes "idiot-proofing").
    Try to foresee what errors people might make in calling your function, and correct for them when possible.
    For example, if it only makes sense for start_date to be midnight, or mdays to be an integer, then use TRUNC in the function in case soembody passes a bad value.
    Allow for default arguments.
    Comment your function. Put all comments within the function (that is, after CREATE and before the final END) so that they will be kept in the data dictionary.
    If, given the same arguments, the function always returns the same value, mark it as DETERMINISTIC, for efficiency. This means the system may remember values passed back rather than call the function every time it is told to.
    I wish I could mark questions as "Correct" or "Helpful"; you'd get 10 points for sure.
    You posted CREATE TABLE and INSERT statements (without even being begged).
    You gave a clear description of the problem, including desired results.
    The code is nicely formatted and easy to read.
    All around, one of the most thoughtful, well-written questions I've seen.
    Well done! Keep up the good work!
    Edited by: Frank Kulash on Feb 2, 2010 1:10 PM
    Added my own version of the function.

  • Crystal Reports from R/3 function with parameters

    I can create reports from functions that doesn't require parameters, but for one function, the R/3 admin created the function that needs parameters (start and end date) to return records in that range. Does anyone know how to supply the parameter? I tried to select records by start and end date, but didn't work.
    thanks
    Jenny

    Hi Ingo:
       Thank you for replying. It seems I have created the report correctly, but the function is not properly configured. So I'm forwarding the issue back to our R/3 admin.
    Jenny
    Edited by: Jenny Gu on Dec 22, 2011 3:10 AM

Maybe you are looking for

  • While generating the report

    while generating report in oracle 11gr2. i am getting error Error 500--Internal Server Error **From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:** **10.5.1 500 Internal Server Error** **The server encountered an unexpected condition which preven

  • Constant errors with Premiere Elements/Photoshop 7 - will upgrade to 9 help?

    I currently have Premiere Elements 7 and Photoshop 7 on my computer. Both crash a lot, often with no error messages. I also cannot seem to backup my Photoshop files. I want to purchase and install Premiere Elements 9 (and Photoshop) but am worried ab

  • How to give free to a product

    hi, How can we give free to a product where and how it has to be done . i.e consider cycle i like to give a umberlla free then if a customer order 10 cycle then i have to give them 10 umberlla while delivery . how can do it help me ......

  • Updation of db tables through Function module

    Using the below funtion module i need to update an internal table with 3 fields (Fkkop-opbel,fkkop-xblnr,fkkop-opord) into their respective tables CALL FUNCTION 'FKK_DOCUMENT_CHANGE'   EXPORTING     I_OPBEL                           = v_OPBEL   I_UPD

  • How do i combine two photos i have in iPhoto together?

    i want to put writing from one cropped image under a logo of another...how?