Setting a bind variable in a Shared Component Report Query

I have defined a Shared Component Report Query in APEX using a bind variable similar to below
Select name, id , ....
from asset
where id = :id
I have also created a Report Region that displays a table where one of the columns contains a value I would like to be a link column that can launch the Report Query and pass its value to the bind parameter :id in the report query. This in turn would generate a pdf report for the details associated with that column. I am having problems setting the :id bind parameter. How do I do this?
Can anyone help?
Thanks

The bind values are set from session state. So if try something like this:
Select name, id , ....
from asset
where id = :P1_ID
With P1_ID being a page item, for which you set the session state / value before generating the PDF file. So assuming you already have a page with a report and a page item, and that page item is already used in your report, then you could just create a button to download the PDF, make sure the button is a submit button, and create a branch pointing to the report query URL (or in 3.1 use the create button wizard, to do this declaratively.)
Regards,
Marc

Similar Messages

  • Bind Variables and Shared Component Report Query

    I have a query in a region report which I have replicated to a shared component report query.
    Both queries reference page items as bind variables in the where clause.
    The report region on screen shows the correct results but the report query shows "no data". This is the case when running "Test Query" and "Download XML data" from the shared component report query definition. If I hardcode the variable names I get rows returned, If I use bind variables - and specify the values for these variables I get no data. THe XML file contains the tags for each bind variable I have specified but has no data between the tags. I have Ticked the box to include application and session state but it appears that the bind variables are not being used.
    When I use my report query in the application (URL tied to a button) I get the same problem, the binds are not being passed to the report query.
    Can someone please clarify if this is a bug or not? And if not, how can I get it to work.
    I am using Apex 4.0.2
    Thanks
    Kathryn

    Hi
    To confirm, yes I selected the bind variables. I used these in the report layout, but the xml file has them as empty i.e.
    <P0_START_DATE><P0_START_DATE/> with nothing in between.
    IN the Test Query section, if I put real values in the boxes for the bind variables, I get no data found. If I hardcode the values into the query, I get the data.
    I've repeated the create report query many times and have created a report layout in RTF. I can use the layout with my region - in the print attributes and the layout works with the query but I need to create a PDF using 2 queries - ROWSET1 and ROWSET2. I can generate the XML but the values in the rows are all empty. When I use the layout with a report query instead of the region, I get no data even though I have used the same sql and have selected the bind variables. I was using variables from page items on page zero but have also tried using page items on the current page, the result is the same.
    I need to use a report query and a report layout as I need data from 2 queries in the PDF.
    I looked at your demo - what happens if you add a second sql query to the report query - is there any chance I can look at the back end (developer access?)
    Thanks for your input
    Kathryn

  • How to set the bind variable on page load and execute query ?

    Hi All,
    I am using Jdeveloper 11.1.1.5
    I have a table called "Employee"
    Columns :- id , name , location
    Data :- 1, ,james , chicago
    2 ,Raj ,capetown
    Now i have another webservice(created as a webservice dataControl) which sends me the "id" on each time my page loads.Now the id which has been returned by webservice should be incorporated in my VO Query as in where clause to fetch the data for the respective "id" in that "Employee" table and should be rendered on form.
    Eg :- Id "2" has been sent by the webservice then the record should be fetched from database should be "2","raj","capetown".
    I know that there would be necessity of bind variable , but how do i set the bind variable on page load ?
    How can i use the bind variable appropriately ??
    Please suggest !!!!
    Thanks.

    Hi,
    Check
    http://www.orastudy.com/oradoc/selfstu/fusion/web.1111/b31974/web_services.htm#CJADCDBG
    http://thepeninsulasedge.com/frank_nimphius/2011/02/18/adf-code-corner-sample-73-released-hands-on-creating-a-search-form-using-a-pojo-ws-and-the-web-service-data-control/
    -Suresh

  • Using bind variables in Shared Component Reports not working

    I've created a report query as a shared component in my APEX application. I'm calling the report on a page via a button. The query behind the report has bind variables for period and entity fields which are both defined on Page 0. I can run the query and return values just fine, but when you run the report from the page via the button, I get no values back. Does anyone know a trick to getting this to work? I've been working in APEX for about a month and I don't have much developer experience so any help is appreciated.
    Regards,
    -Steve

    Rohit,
    Thanks for your response. We are using APEX version 4.2.1.00.08. I do have Session State enabled and have put the required page items in the list. Here is my report query (highlighted lines contain the bind variables):
    SELECT TAX_DIVISION.DIVISION_CODE Division,
    TAX_ENTITY.ENTITY_CODE Entity_Code,
    DECODE(TAX_ADJUSTMENT.CATEGORY_DESC,'Net Income/(Loss)',1,'Permanent Adjustment',2,'Temporary Adjustment',3,4) Category_Desc,
    TAX_ADJUSTMENT.CLASSIFICATION Classification,
    TAX_ADJUSTMENT.ADJUSTMENT_CODE Adjustment_Code,
    SUM(NVL(NVL(TAX_ENTITY_ADJUSTMENT.OVERRIDE_AMT,TAX_ENTITY_ADJUSTMENT.ADJUSTMENT_AMT),0)) Tax_Amount
    FROM TAX_DIVISION,
    TAX_ENTITY,
    TAX_ENTITY_ADJUSTMENT,
    TAX_ADJUSTMENT,
    TAX_PERIOD
    WHERE TAX_DIVISION.DIVISION_ID = TAX_ENTITY.DIVISION_ID
    AND TAX_ENTITY.ENTITY_ID = TAX_ENTITY_ADJUSTMENT.ENTITY_ID
    AND TAX_ENTITY_ADJUSTMENT.ADJUSTMENT_ID = TAX_ADJUSTMENT.ADJUSTMENT_ID
    AND  TAX_ENTITY_ADJUSTMENT.PERIOD_ID = :P0_PERIOD_ID
    AND  TAX_ENTITY_ADJUSTMENT.YEAR_ID = :P0_YEAR_ID
    AND  TAX_ENTITY.DIVISION_ID = :P0_DIVISION_ID
    AND TAX_ADJUSTMENT.ADJUSTMENT_CODE = 'IBIT'
    GROUP BY TAX_DIVISION.DIVISION_CODE ,
    TAX_ENTITY.ENTITY_CODE ,
    DECODE(TAX_ADJUSTMENT.CATEGORY_DESC,'Net Income/(Loss)',1,'Permanent Adjustment',2,'Temporary Adjustment',3,4),
    TAX_ADJUSTMENT.CLASSIFICATION ,
    TAX_ADJUSTMENT.ADJUSTMENT_CODE
    HAVING SUM(NVL(NVL(TAX_ENTITY_ADJUSTMENT.OVERRIDE_AMT,TAX_ENTITY_ADJUSTMENT.ADJUSTMENT_AMT),0)) !=0
    ORDER BY DIVISION_CODE, DECODE(TAX_ADJUSTMENT.CATEGORY_DESC,'Net Income/(Loss)',1,'Permanent Adjustment',2,'Temporary Adjustment',3,4), CLASSIFICATION, ENTITY_CODE, ADJUSTMENT_CODE
    The query returns data when I set the bind variables and test in the report queries screen. When I assign the report query URL to the button in the application and run from there, I get no results.

  • How to set a bind variable across the pages in a report

    I want to create a portal report where data will come from a table for a date range for a week.
    For e.g select event_date,last_name, event_name
    from RESOURCES
    where event_date between trunc(to_date(:curr_date,'DD-MON-RRRR'))
    and trunc(to_date(:curr_date,'DD-MON-RRRR')+ 7)
    The :curr_date is defined as a bind variable whose default value is sysdate.
    Now, when we run the report for the first time, it takes the :curr_date as
    sysdate and prints the report.
    I have two buttons in the report output like "previous week" and "next week".
    If someone presses previous week, the same report should run with curr_date
    as sysdate-7 and if someone presses next week, the report should run with
    curr_date as sysdate +7 and also the :curr_date sets to sysdate - 7 or sysdate + 7
    depending on the button pressed.
    Problem:
    How do I set the value of curr_date if someone presses any of
    previous week/next week.
    null

    Best to state your JDev version, and technology stack (eg. ADF BC) when posting.
    I can think of 2 approaches.
    1) Create a parent VO based on SELECT :bindVar FROM dual, then create links between your other VOs and the parent
    2) Create a AM client interface method that programatically sets the bind variable in each VO.
    Can you specify your use case? This one tends to come up when discussing effective from/to dated queries.
    CM.

  • Setting VO bind variable using session variable

    Hi,
    I need to get/set VO bind variable using ApplicationModuleImple or ViewObjectImple class. Does Any one know how to do it?
    I have one VO based on query like "select name from users where password = :password ". I had a bind variable to it too. now i want to set it from a session scoped variable. can i do it using ADFContext.getCurrent().getSession().get('username'); ? but somehow I am not able to get the knowledge i.e where to set bind variable. please help.

    Timo thanks for the reply, actually I don't want to do it using data control i.e drag and drop method to a page. Instead i just want to set bind variable to a session varable already got from login page.
    I got the following sollotion but don't know where to put them,
    1.
    FacesContext context = FacesContext.getCurrentInstance();
    ValueBinding vb = context.getApplication().createValueBinding("#{data}");
    BindingContext bci = (BindingContext)vb.getValue(context);
    DCDataControl dc = bci.findDataControl("AppModuleDataControl");
    ApplicationModule am = (ApplicationModule)dc.getDataProvider();
    AppModuleImpl service = (AppModuleImpl)am;
    ViewObject vo = service.findViewObject("YourViewObject").setNamedWhereClauseParam("nameBindVariable", objectValue);
    vo.executeQuery();
    what is the #{data} in second line ? if you know please let me know.
    Second Solution :
    2- In backing bean code:
    FacesContext context = FacesContext.getCurrentInstance();
    Application fapp = context.getApplication();
    JUFormBinding adfbc = (JUFormBinding)fapp.createValueBinding("#{bindings}").getValue(context);
    DCIteratorBinding iter = adfbc.findIteratorBinding("YourIterator");
    iter.getViewObject().setNamedWhereClauseParam("nameBindVariable", objectValue);
    iter.executeQuery();
    where would I get "YourIterator" ... ? I am still a new at jdev ... ;)

  • Set VO bind variable on page loading programmatically

    Greetings everyone!
    I use JDeveloper version 11.1.2.3.0
    I am currently trying to get some filtered data from a VO, based on a WHERE clause with a bind variable. This process should be done on page load. I have to set this bind variable with the id of the logged user (the part of getting this id is already achieved and used somewhere else). My current approach is defining a managed bean with pageFlow scope. Inside this i have a method in which i retrieve the id and i set it as the parameter value. The code snippet:
          BindingContainer bindings = getBindings();
            OperationBinding operationBinding = bindings.getOperationBinding("getUserIdFromUsername"); //getUserIdFromUsername is a method defined in the AppModule and exposed in the client interface
           operationBinding.getParamsMap().put("username", getUserName());
          Object userID = operationBinding.execute();
            setUserId(Integer.parseInt(userID.toString()));
           System.out.println("THE USER ID IS: "+getUserId());
           BindingContainer bindings2 = getBindings();
           OperationBinding operationBinding2 = bindings.getOperationBinding("ExecuteWithParams");  // i've dragged and dropped the ExecuteWithParams operation into the page
           operationBinding2.getParamsMap().put("userId", getUserId());  // userId is the bind variable which i'm talking about
            Object result = operationBinding2.execute();
    Then, i call this method on BeforePhase in the page view. It works, i get the filtered data and the println shows me the correct ID. The problem is that each time i select a row in the table showing the data, the page seems to reload and it always get the selection back at the very first row.
    What am i doing wrong? May be this is not the right approach, as i've seen some other posts about this topic but they are not very clear to me.
    Please advice

    Approach1:
    Drag and Drop an Application  method as Default Method Call Activity, then draw a control flow case from the method to your page.
    In the application module method, implement appropriate logic.
    Approach2:
    Using a combination of client listener and server listener will also help.
    <af:clientListener method="onLoadAction" type="load"/>
    <af:serverListener type="MyCustomServerEvent"
    method="#{backingBeanScope.editBean.onLoadListener}"/>
    function onLoadAction(event){
               /*alert(':::: onSave ::');*/
               AdfCustomEvent.queue(actionEvent.getSource(),
                             "MyCustomServerEvent",
                             true);
           actionEvent.cancel() ;
           actionEvent.stopPropagation();

  • ADF BC / Why bind variables are mandatory in the sql query

    I got this error during view object excecution in the component browser :
    (oracle.jbo.SQLStmtException) JBO-27122: Erreur SQL lors de la préparation d'une instruction. Instruction : SELECT * FROM (Select distinct(socialgroup.socialgroup_i) from socialgroup, socialgroupmember, lodgingallocation, lodge
    where socialgroup.socialgroup_i = socialgroupmember.socialgroup_i and socialgroupmember.t_socialgrouprole_i = t_rolegroup_ipar.fgetflextypologyclassitem_i(t_rolegroup_ipar.fisbeneficiary) and socialgroupmember.datefrom <= :DateTo and nvl(socialgroupmember.dateto, :DateFrom) >= :DateFrom and socialgroupmember.requester_i = lodgingallocation.requester_i and lodgingallocation.datefrom <= :DateTo and nvl(lodgingAllocation.DateTo, :DateFrom) >= :DateFrom and lodgingallocation.lodge_i = lodge.lodge_i) QRSLT ORDER BY "SOCIALGROUP_I"
    ----- LEVEL 1: DETAIL 0-----
    (java.sql.SQLException) Tentative de définition d'un nom de paramètre qui ne se trouve pas dans le SQL: T_SICategory_I
    The bind variables T_SICategory_I is not yet use in the sql query but will be used later so i defined it for the view object.
    Is it a reason that the run time check this ? It would be more convenient to set the bind variables early when defining the view object and add them later during the development iteration.

    Design-time defined named bind variables can be marked as required, or not.
    This is decided by the use in the where clause or in view criteria. In my case the bind variable was not used in where clause neither in view criteria and that causes the error.
    May be i would be nice to add a check box (a flag) that enable or disable the bind variables for this checking so we will be able to let it defined even we removed some part of the query corresponding to the corresponding restriction or we defined it earlier for a part of the query that is not yet defined.
    In my current case i fully defined the bind variables but would refine my query later ... in that cause i would have to remove this bind variable and loose all the definitions to run this view object.
    sorry for my english ...

  • How to set a bind variable into a vo query from the current vo ?

    I would like to exclude from my list of values defined in a view object the already referenced items in the current view object content.
    Let's say i have dept and emp with a many to many relationships, I would like that the already existing dept for emp not listed (excluded) in the list of values for emp.
    Do i need to define a bind parameters and set it during search or is it possible to use an expression that will refer the current row attribute representing the dept ?
    I didn't find an example or explanation how to set bind parameters defined in a view object query from seach pages or list of values ui components. May be somebody know how to find the info.
    Thank you

    I think that bind variable accessors in the VO class is what you need. You can override the getter method of the bind variable "LocaleCode2" in order to return the first 2 chars from the bind variable "LocaleCode". Have a look at this blog post for details:
    http://jdeveloperandadf.blogspot.com/2011/03/custom-java-bind-variable-in-where.html
    Dimitar

  • Setting VO bind variable programatically

    Hi,
    We have a panel accordion, which has several panels. Depending on panel's name (text attribute) we need to set the underlining VO bind variable to the name value.
    Could someone point to an example of how to do it?

    use [url http://docs.oracle.com/cd/E14571_01/apirefs.1111/e10653/oracle/jbo/server/ViewObjectImpl.html#setNamedWhereClauseParam%28java.lang.String,%20java.lang.Object%29]setNamedWhereClauseParam  method
    also check {message:id=9904521}
    Edited by: M.Jabr on Nov 28, 2011 8:55 AM

  • How to set default bind variable value to task parameter value

    Hi,
    I 'm implementing a BPEL process with a human task, and I autogenerate the task form. I have a custom sql table that stores opinions, different processes should show different opinios, so my ADF table can only show records related to that process. A custom process number is sent to the task form as a task parameter. How do I use that value as the bind variable default and only value?
    Thanks,
    I.D.

    Hi Shay and thanks for your reply,
    What I want is what you have but without the login page. I tried to start my flow with an action and for some reason it didn't work.
    Is there anything else you can tell me?
    Thanks,
    I.D.
    P.S. I was able to get it to work using the aproach Frank Nimphius described in another post.
    Re: How do I prepopulate a bind variable from a session variable?
    Anyway just out of curiosity could you please tell me if I could have done it your way?
    Thanks a lot,
    I.D.
    Edited by: user8696770 on 5/Ago/2009 7:12

  • ORA-01006:bind variable does not exist for the QUERY

    Dear All,
    Please help on below query :
    DECLARE
    P_ROTATION_NO GCH_VSL_REGN.ROTATION_NO%TYPE :=21;
    P_VESL_NO GCH_VSL_MASTER.VESL_NO%TYPE := NULL;
    P_VESL_NAME GCH_VSL_MASTER.VESL_NAME%TYPE:= NULL;
    P_FROM_REG_DATE GCH_VSL_MASTER.CREATED_DATE%TYPE:= NULL;
    P_TO_REG_DATE GCH_VSL_MASTER.CREATED_DATE%TYPE:= NULL;
    P_FROM_ARRIVAL_DATE GCH_VSL_REGN.ARRIVAL_DATE%TYPE:= NULL;
    P_TO_ARRIVAL_DATE GCH_VSL_REGN.ARRIVAL_DATE%TYPE:= NULL;
    P_CLOSE_TYPE GCH_VSL_CLOSE_DTLS.CLOSE_TYPE%TYPE:= NULL;
    P_RESULT_LIST SYS_REFCURSOR;
    P_TOTAL_LENGTH NUMBER;
    P_ERROR_MESSAGE VARCHAR2(1000);
    lv_sql1 VARCHAR2(5000);
    lv_sql2 VARCHAR2(5000);
    lv_whereClause VARCHAR2(5000);
    pv_text VARCHAR2(1000);
    BEGIN
    pv_text := NULL;
    lv_whereClause := ' WHERE GVM.VESL_MASTER_NUM = GVR.VESL_MASTER_NUM
    AND GVR.ROTATION_NO = GVCH.ROTATION_NO
    AND GVCH.CLOSE_HDR_ID = GVCD.CLOSE_HDR_ID(+)
    AND (:P_ROTATION_NO IS NULL OR
    (:P_ROTATION_NO IS NOT NULL AND
    GVR.ROTATION_NO LIKE % :P_ROTATION_NO %))
    AND GVM.IS_VALID = 1';
    lv_sql1 := 'SELECT COUNT(gvr.rotation_no)
    FROM gch_vsl_close_hdr gvch,
    gch_vsl_master gvm,
    gch_vsl_regn gvr,
    gch_vsl_close_dtls gvcd'||lv_whereClause;
    dbms_output.put_line (lv_sql1);
    EXECUTE IMMEDIATE lv_sql1 INTO :P_TOTAL_LENGTH
    USING P_ROTATION_NO;
    END;
    I am getting below error when running the above query
    ORA-01006:     bind variable does not exist

    why (date datatype assumed for variables with names containing DATE)
    PROCEDURE XVY(P_ROTATION_NO IN GCH_VSL_REGN.ROTATION_NO%TYPE,
                  P_VESL_NO IN GCH_VSL_MASTER.VESL_NO%TYPE,
                  P_VESL_NAME IN GCH_VSL_MASTER.VESL_NAME%TYPE,
                  P_CM_REGN_NO IN GCH_VSL_REGN.CM_REGN_NO%TYPE,
                  P_FINAL_CLOSE_STA IN GCH_VSL_CLOSE_HDR.FINAL_CLOSE_STA%TYPE,
                  P_FROM_REG_DATE IN GCH_VSL_MASTER.Created_Date%TYPE,
                  P_TO_REG_DATE IN GCH_VSL_MASTER.CREATED_DATE%TYPE,
                  P_FROM_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_TO_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_RESULT_LIST OUT SYS_REFCURSOR,
                  P_TOTAL_LENGTH OUT NUMBER,
                  P_ERROR_MESSAGE OUT VARCHAR2
                 ) AS
      lv_sql1        VARCHAR2(4000);
      lv_sql2        VARCHAR2(4000);
      lv_whereClause VARCHAR2(4000);
    BEGIN
    --  pv_text := NULL;
      lv_whereClause := ' WHERE gvm.vesl_master_num = gvr.vesl_master_num '||
                          ' AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO '||
                          ' AND (:P_ROTATION_NO IS NULL '||
                          '  OR  (:P_ROTATION_NO IS NOT NULL '||
                          ' AND   gvch.rotation_no LIKE ''%'' || :P_ROTATION_NO || ''%'' ' ||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_CM_REGN_NO IS NULL '||
                          '  OR  (:P_CM_REGN_NO IS NOT NULL '||
                          ' AND   gvr.cm_regn_no LIKE ''%'' || :P_CM_REGN_NO || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_VESL_NAME IS NULL '||
                          '  OR  (:P_VESL_NAME IS NOT NULL '||
                          ' AND   gvm.vesl_name LIKE ''%'' || :P_VESL_NAME || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_VESL_NO IS NULL '||
                          '  OR  (:P_VESL_NO IS NOT NULL '||
                          ' AND   GVM.vesl_no LIKE ''%'' || :P_VESL_NO || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_FINAL_CLOSE_STA IS NULL '||
                          '  OR  (:P_FINAL_CLOSE_STA IS NOT NULL '||
                          ' AND   gvch.imp_close_sta LIKE ''%'' || :P_FINAL_CLOSE_STA || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_FROM_REG_DATE IS NULL '||
                          '  OR  (:P_FROM_REG_DATE IS NOT NULL '||
                          ' AND   gvch.created_date >= :P_FROM_REG_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_TO_REG_DATE IS NULL '||
                          '  OR  (:P_TO_REG_DATE IS NOT NULL '||
                          ' AND   gvch.created_date <= :P_TO_REG_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_FROM_ARRIVAL_DATE IS NULL '||
                          '  OR  (:P_FROM_ARRIVAL_DATE IS NOT NULL '||
                          ' AND   gvch.arrival_date >= :P_P_FROM_ARRIVAL_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_TO_ARRIVAL_DATE IS NULL '||
                          '  OR  (:P_TO_ARRIVAL_DATE IS NOT NULL '||
                          ' AND   gvch.arrival_date <= :P_TO_ARRIVAL_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND gvm.is_valid = 10 ';
      lv_sql1 := 'SELECT COUNT(gvr.rotation_no) '||
                 '  FROM xvz gvch, '||
                 '       zxsc gvm, '||
                 '       dsae gvr, '||
                 '       vvsd gvcd '|| lv_whereClause;
      lv_sql2 := ' SELECT gvch.close_hdr_id, '||
                 '        gvch.rotation_no, '||
                 '        gvr.cm_regn_no, '||
                 '        gvm.vesl_no, '||
                 '        gvm.vesl_name, '||
                 '        gvch.final_close_sta, '||
                 '        gvr.arrival_date, '||
                 '        gvch.close_date, '||
                 '        gvr.created_date '||
                 '   FROM xvz gvch, '||
                 '        zxsc gvm, '||
                 '        dsze gvr '|| lv_whereClause || 'ORDER BY gvch.rotation_no';
      EXECUTE IMMEDIATE lv_sql1 INTO P_TOTAL_LENGTH
                  USING P_ROTATION_NO,P_ROTATION_NO,P_ROTATION_NO,
                        P_CM_REGN_NO,P_CM_REGN_NO,P_CM_REGN_NO,
                        P_VESL_NAME,P_VESL_NAME,P_VESL_NAME,
                        P_VESL_NO,P_VESL_NO,P_VESL_NO,
                        P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,
                        P_FROM_REG_DATE,P_FROM_REG_DATE,P_FROM_REG_DATE,
                        P_TO_REG_DATE,P_TO_REG_DATE,P_TO_REG_DATE,
                        P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,
                        P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE;
      OPEN P_RESULT_LIST
       FOR lv_sql2 USING P_ROTATION_NO,P_ROTATION_NO,P_ROTATION_NO,
                         P_CM_REGN_NO,P_CM_REGN_NO,P_CM_REGN_NO,
                         P_VESL_NAME,P_VESL_NAME,P_VESL_NAME,
                         P_VESL_NO,P_VESL_NO,P_VESL_NO,
                         P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,
                         P_FROM_REG_DATE,P_FROM_REG_DATE,P_FROM_REG_DATE,
                         P_TO_REG_DATE,P_TO_REG_DATE,P_TO_REG_DATE,
                         P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,
                         P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE;
    END;instead of (the where clauses should be equivalent)
    PROCEDURE XVY(P_ROTATION_NO IN GCH_VSL_REGN.ROTATION_NO%TYPE,
                  P_VESL_NO IN GCH_VSL_MASTER.VESL_NO%TYPE,
                  P_VESL_NAME IN GCH_VSL_MASTER.VESL_NAME%TYPE,
                  P_CM_REGN_NO IN GCH_VSL_REGN.CM_REGN_NO%TYPE,
                  P_FINAL_CLOSE_STA IN GCH_VSL_CLOSE_HDR.FINAL_CLOSE_STA%TYPE,
                  P_FROM_REG_DATE IN GCH_VSL_MASTER.Created_Date%TYPE,
                  P_TO_REG_DATE IN GCH_VSL_MASTER.CREATED_DATE%TYPE,
                  P_FROM_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_TO_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_RESULT_LIST OUT SYS_REFCURSOR,
                  P_TOTAL_LENGTH OUT NUMBER,
                  P_ERROR_MESSAGE OUT VARCHAR2
                 ) AS
      lv_sql1        VARCHAR2(4000);
      lv_sql2        VARCHAR2(4000);
      lv_whereClause VARCHAR2(4000);
    BEGIN
      SELECT COUNT(gvr.rotation_no)
        INTO P_TOTAL_LENGTH
        FROM xvz gvch,
             zxsc gvm,
             dsae gvr,
             vvsd gvcd
       WHERE gvm.vesl_master_num = gvr.vesl_master_num
         AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO
         AND (P_ROTATION_NO IS NULL
          OR  (P_ROTATION_NO IS NOT NULL
         AND   gvch.rotation_no LIKE '%' || P_ROTATION_NO || '%'
         AND (P_CM_REGN_NO IS NULL
          OR  (P_CM_REGN_NO IS NOT NULL
         AND   gvr.cm_regn_no LIKE '%' || P_CM_REGN_NO || '%'
         AND (P_VESL_NAME IS NULL
          OR  (P_VESL_NAME IS NOT NULL
         AND   gvm.vesl_name LIKE '%' || P_VESL_NAME || '%'
         AND (P_VESL_NO IS NULL
          OR  (P_VESL_NO IS NOT NULL
         AND   GVM.vesl_no LIKE '%' || P_VESL_NO || '%'
         AND (P_FINAL_CLOSE_STA IS NULL
          OR  (P_FINAL_CLOSE_STA IS NOT NULL
         AND   gvch.imp_close_sta LIKE '%' || P_FINAL_CLOSE_STA || '%'
         AND (P_FROM_REG_DATE IS NULL
          OR  (P_FROM_REG_DATE IS NOT NULL
         AND   gvch.created_date >= P_FROM_REG_DATE
         AND (P_TO_REG_DATE IS NULL
          OR  (P_TO_REG_DATE IS NOT NULL
         AND   gvch.created_date <= P_TO_REG_DATE
         AND (P_FROM_ARRIVAL_DATE IS NULL
          OR  (P_FROM_ARRIVAL_DATE IS NOT NULL
         AND   gvch.arrival_date >= P_P_FROM_ARRIVAL_DATE
         AND (P_TO_ARRIVAL_DATE IS NULL
          OR  (P_TO_ARRIVAL_DATE IS NOT NULL
         AND   gvch.arrival_date <= P_TO_ARRIVAL_DATE
         AND gvm.is_valid = 10;
      OPEN P_RESULT_LIST
       FOR SELECT gvch.close_hdr_id, 
                  gvch.rotation_no, 
                  gvr.cm_regn_no, 
                  gvm.vesl_no, 
                  gvm.vesl_name, 
                  gvch.final_close_sta, 
                  gvr.arrival_date, 
                  gvch.close_date, 
                  gvr.created_date 
             FROM xvz gvch, 
                  zxsc gvm, 
                  dsze gvr
            WHERE gvm.vesl_master_num = gvr.vesl_master_num
              AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO
              AND gvch.rotation_no LIKE '%' || nvl(P_ROTATION_NO,gvch.rotation_no) || '%'
              AND gvr.cm_regn_no LIKE '%' || nvl(P_CM_REGN_NO,gvr.cm_regn_no) || '%'
              AND gvm.vesl_name LIKE '%' || nvl(P_VESL_NAME,gvm.vesl_name) || '%'
              AND gvm.vesl_no LIKE '%' || nvl(P_VESL_NO,gvm.vesl_no) || '%'
              AND gvch.imp_close_sta LIKE '%' || nvl(P_FINAL_CLOSE_STA,gvch.imp_close_sta) || '%'
              AND gvch.created_date BETWEEN nvl(P_FROM_REG_DATE,gvch.created_date) AND nvl(P_TO_REG_DATE,gvch.created_date)
              AND gvch.arrival_date BETWEEN nvl(P_FROM_ARRIVAL_DATE,gvch.arrival_date) AND nvl(P_TO_ARRIVAL_DATE,gvch.arrival_date)
              AND gvm.is_valid = 10;
            ORDER BY gvch.rotation_no;
    END;Regards
    Etbin
    Edited by: Etbin on 8.4.2012 14:37
    In order not to waste your time in the future:
    Don't execute dynamic SQL until it works !!!
    Write out what you managed to put together using dbms_output.
    Paste that into the SQL window of your client tool (SQL Developer ...)
    Convert parameters to bind variables (replace p_ with :p_)
    Try to run it.
    If errors are thrown correct them, adjust the procedure/function set up to write your dynamic SQL accordingly
    Repeat the cycle until no errors are thrown
    Comment out the dbms_output. ... line
    Uncomment the execute immediate ... line

  • 3.0 Shared Component - Report Format - all PDF

    Greetings,
    Details
    I have been working with the REPORTS - REPORT QUERIES section of APEX 3.0
    The testing I have been doing is very simple, but I am running into a bit of a stumper.
    I have created 4 report queries on the EMP table (SELECT * FROM EMP) that all use the same REPORT LAYOUT. The RTF file which is the template is a very simple - show all columns and rows for the EMP table (14 rows).
    I have set each of the 4 report layouts to a different format.
    1 - PDF
    1 - EXCEL
    1 - WORD
    1 - HTML
    I am NOT using the ITEM to dynamically set the format.
    I can TEST each of the reports in the shared component area, and they test OK with a success rate of 75%.
    The EXCEL format does not export correctly. (using Excel 2002 on the client) It is a bit of a mess. (Works in the XML publisher template builder on the client.. so the format is not the issue.)
    More curious is the behavior when I put this application. I have created a LIST of the 4 report formats. All 4 return the PDF format when used.
    To see the Application:
    http://apex.oracle.com/pls/otn/f?p=34096
    Question Summary:
    1 - Has anyone run with and tested the RTF style report layouts out to Excel?
    2 - The approach described usees 4 report queries against 1 layout. Is this a VALID use of the report functionality?
    3 - Why would all the reports try to use PDF when they test in the correct formats?
    Best Regards and Thank You.
    -- Tim

    Tim,
    The Excel output is not strictly XLS, it's actually HTML formatted in a way that Excel understands and through setting the MIME-types we make it open in Excel. I have to try reproducing your specific problem with Excel 2002. If you could send me your RTF layout and the end-result ([email protected]), I can take a look.
    Your approach using 4 different queries with the same layout is perfectly fine. Ideally of course, you would not have to replicate them same query four times, so we are considering a shared query concept for future version of Application Express.
    You specific problem with the output format being PDF at runtime appears to be a bug, I'll investigate further. Meanwhile one work-around would be to use a report region instead. If you're using the same SQL query as the source, you can associate the same report layout (on the report print attributes page). You could also create a "container" page for that report region, that's never actually called by the end user, and then have a button pointing to the URL below for printing. It would then work just like your report queries, only that you now would get the requested format:
    f?p=&APP_ID.:[REPORT PAGE ID]:&SESSION.:FLOW_XMLP_OUTPUT_R[REPORT REGION ID]
    so if your app ID is 34096 and your "container" page e.g. 99, and on page 99 your report region ID would be 1234567890, then use this URL as the button target:
    f?p=&APP_ID.:99:&SESSION.:FLOW_XMLP_OUTPUT_R1234567890
    Hope this helps,
    Marc

  • Maximum Size of bind variables/model names in a SPARQL query

    I was wondering what the maximum field size is for a bind variable (?'' being used in the subject or object within a triple) in a SPARQL query using the Jena Adapter for Oracle? The reason for this is that I keep getting Oracle exception (ORA-00972: identifier is too long) when executing queries.
    The other question dealt with the max size of the model names? Is there anyway to increase this length by extending certain classes within the Jena Adapter for Oracle?
    Thanks,
    Rahul

    Hi,
    For model names, because we use model names together with some suffixes to create namespace tables, application tables, and indexes, the length
    has to be shorter than 30 bytes - 11 bytes = 19 bytes.
    Note that 30 bytes limit is imposed by Oracle database. You cannot create a table with a name longer than 30 bytes.
    11 bytes is the maximum suffix length imposed by Jena Adapter. We are considering to reduce it to 4 for the next Jena Adapter release.
    For variable names, because we translate SPARQL to SQL queries (and variable name to column alias), there is the same 30 bytes limit.
    Note that there are suffixes for variable names as well. For example, $RDFVID, $RDFLTYP, ... These suffixes are used internally.
    Some simple tests for illustration purpose.
    SQL> create table a23456789012345678901234567890(i int);
    Table created.
    SQL> create table a234567890123456789012345678901(i int);
    create table a234567890123456789012345678901(i int)
    ERROR at line 1:
    ORA-00972: identifier is too long
    -- Assume table X has a column I
    SQL> select i as "v23456789012345678901234567890" from x;
    no rows selected
    SQL> select i as "v234567890123456789012345678901" from x;
    select i as "v234567890123456789012345678901" from x
    ERROR at line 1:
    ORA-00972: identifier is too long
    Hope it helps,
    Zhe Wu

  • ORA-01006 Using Bind Variables In A Dynamic SQL Contains Query

    I have the following dynamic SQL query :-
    declare
    TYPE typ_sql IS REF CURSOR;
    ltyp_sql typ_sql;
    lv_sql VARCHAR2(100);
    begin
    lv_sql := 'SELECT arx_id FROM arx WHERE CONTAINS ';
    lv_sql := lv_sql || (arx_full,''(:b1) WITHIN ui'') > 0';
    open ltyp_sql FOR v_sql USING ln_id;
    fetch ......
    close ......
    end;
    When the code tries to open the cursor it gives the above error. I presume it is the way Oracle is expanding the bind variable but I cannot find anything in the docs to say why this is happening or whether you can do this or not using bind variables ( CONTAINS query ). Any help would be appreciated, thanks,
    Stuart.

    lv_sql || '(arx_full, :b1 || '' within ui'') > 0';

Maybe you are looking for