Sql query in apex

Hi all,
i have table with following fields start_time, end_time
and data is 25/01/2010 12:00,25/01/2010 12:48
i am running a sql query to get info about time spent
Select end_time - start_time
from table
but it is giving .033333333
I want follwing result
time_spent
00:48 min
please help

Omy,
The solution I gave above had an error. The hours and minutes component both had the difference in them.
That would have been useful if you only needed the hours component (2) or the minutes component (150 minutes-- 2 hours and 30 minutes..).
To make sure we get only the hours component and minutes component in the respecive sections, we can make use of the mod function..
  1  select start_date,
  2         end_date,
  3         (end_date-start_date) usual_diff,
  4         trunc(end_date-start_date) || ' days ' ||
  5         mod(trunc((end_date-start_date)*24),24) || ' hours ' ||
  6         mod(trunc((end_date-start_date)*24*60),60) || ' minutes ' ||
  7         mod(trunc((end_date-start_date)*24*60*60),60) || 'Seconds ' diff
  8*    from t2
sql> /
START_DATE           END_DATE             USUAL_DIFF DIFF
25-JAN-2010 03:00:00 26-JAN-2010 05:30:00 1.10416667 1 days 2 hours 30 minutes 0Seconds
--Including the display format for time...
  1  select start_date,
  2         end_date,
  3         (end_date-start_date) usual_diff,
  4         trunc(end_date-start_date) || ' days ' ||
  5         to_char(mod(trunc((end_date-start_date)*24),24),'09')      || ':' ||
  6         to_char(mod(trunc((end_date-start_date)*24*60),60),'09')   || ':' ||
  7         to_char(mod(trunc((end_date-start_date)*24*60*60),60),'09') diff
  8*    from t2
sql> /
START_DATE           END_DATE             USUAL_DIFF DIFF
25-JAN-2010 03:00:00 26-JAN-2010 05:30:00 1.10416667 1 days  02: 30: 00Did you try using the numtods interval..? Is there a reason you prefer the manual method over the numtodsinterval function?

Similar Messages

  • Changing font color in a report using SQL query for APEX 5.0

    Hello,
    I am testing APEX 5.0 in my testing environment to see if I can migrate my internal apps from 4.2 to 5.0.
    How can I change the font color in a field based in the SQL query? I know how to do it in 4.2 but I can't find the same in 5.0.
    Thanks,

    Well, I used to put the html tags in the select as text getting the color value depending a CASE , then I had to change the Display attribute for the column in the report as "Display as text (espace special characters...)".
    I found an old post here: https://tylermuth.wordpress.com/2007/12/01/conditional-column-formatting-in-apex/ and  this method still worked for me in APEX 5.0
    Thanks anyways

  • Change column order updateable sql query report APEX 4

    Hi all,
    I have a master detail page. Detail is SQL Query (updateable report)
    I want to change the column order but seems not possiible anymore in A4.
    In A3... on the right side of the report attributes it was possible to move columns up or down.
    path is Home>>Application Builder>>Application nnn >>Page xx >>Report Attributes
    It seems that A4 the move up or down functionality is hidden or the region is to small with no horizontal scrollbar.
    Is there a work_aorund?
    This is also the case when the pages are displayed in icon view when showing all pages using.
    Home >> Application Builder >>Application
    Most right icons are hidden after the about and task regions.
    The work-around here is to display the pages in report or detail view
    Maybe a fix needed for APEX4?
    have nice weekend!
    Hugo Perfors
    Enthousiastic APEX developer

    Hi,
    It could be your browser settings. Try zooiming out in the browser View - Zoom - Zoom Out.
    Regards

  • How do I query off a pl/sql funtion that returns an sql query in apex.

    I built a function that a returns a good sql query. I verified the out put of my function works when I manually entered into the SQL Commands.
    Is it possible to build a report off of this query. My attempt failed with the following error.
    failed to parse SQL query:
    ORA-00933: SQL command not properly ended
    I am sure the query generated is correct. Like I mentioned, I was able to use in the sql command succesfully.
    Thanks,
    Edited by: greich on Nov 21, 2008 10:55 AM

    This is the code for my function:
    create or replace function f_act_proj_sched (i_facility varchar2, i_date varchar2, i_shift varchar2)
    Return varchar2 is
    o_query Varchar2 (32000);
    BEGIN
    -- function that will return the query used in main application
    o_query := o_query || 'SELECT act_proj.DESTINATION,';
    o_query := o_query || ' act_proj.SHIPPING_DATE,';
    o_query := o_query || ' act_proj.SHIFT,';
    o_query := o_query || ' act_proj.JOB_CLASS_GROUPING,';
    o_query := o_query || ' act_proj."Actual Units",';
    o_query := o_query || ' act_proj."Projected Units",';
    o_query := o_query || ' act_proj."Actual Hours",';
    o_query := o_query || ' act_proj."Projected Hours",';
    o_query := o_query || ' NVL (sched."Sched_Hours", 0)';
    o_query := o_query || ' "Scheduled Hours"';
    o_query := o_query || ' From (SELECT P.DESTINATION,';
    o_query := o_query || ' P.SHIPPING_DATE,';
    o_query := o_query || ' P.JOB_CLASS_GROUPING,';
    o_query := o_query || ' P.SHIFT,';
    o_query := o_query || ' NVL (FACILITY_STATS.WORK_UNITS, 0) "Actual Units",';
    o_query := o_query || ' NVL (P.WORK_UNITS, 0) "Projected Units",';
    o_query := o_query || ' NVL (CASE FACILITY_STATS.JOB_CLASS_GROUPING';
    o_query := o_query || ' WHEN ''Backhaul''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Selector''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.selector_goal';
    o_query := o_query || ' WHEN ''Common''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Lift''';
    o_query := o_query || ' THEN Facility_stats.work_units';
    o_query := o_query || ' / Goal_destination_shift.forklift_goal';
    o_query := o_query || ' ELSE Facility_stats.work_units';
    o_query := o_query || ' END, 0) "Actual Hours",';
    o_query := o_query || ' CASE P.JOB_CLASS_GROUPING';
    o_query := o_query || ' WHEN ''Backhaul''';
    o_query := o_query || ' THEN P.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Selector''';
    o_query := o_query || ' THEN P.work_units';
    o_query := o_query || ' / Goal_destination_shift.selector_goal';
    o_query := o_query || ' WHEN ''Common''';
    o_query := o_query || ' THEN P.work_units';
    o_query := o_query || ' / Goal_destination_shift.backhauler_goal';
    o_query := o_query || ' WHEN ''Lift''';
    o_query := o_query || ' THEN P.work_units' ;
    o_query := o_query || ' / Goal_destination_shift.forklift_goal';
    o_query := o_query || ' ELSE P.work_units';
    o_query := o_query || ' END "Projected Hours"';
    o_query := o_query || ' FROM STAFFING.FACILITY_STATS,';
    o_query := o_query || ' STAFFING.FACILITY_STATS P,';
    o_query := o_query || ' STAFFING.GOAL_DESTINATION_SHIFT';
    o_query := o_query || ' WHERE (GOAL_DESTINATION_SHIFT.DESTINATION = P.DESTINATION)';
    o_query := o_query || ' AND (GOAL_DESTINATION_SHIFT.SHIFT_FLAG = P.SHIFT)';
    o_query := o_query || ' AND (FACILITY_STATS.DESTINATION(+) = P.DESTINATION)';
    o_query := o_query || ' AND (FACILITY_STATS.SHIPPING_DATE(+) = P.SHIPPING_DATE)';
    o_query := o_query || ' AND (FACILITY_STATS.JOB_CLASS_GROUPING(+) = P.JOB_CLASS_GROUPING)';
    o_query := o_query || ' AND (FACILITY_STATS.SHIFT(+) = P.SHIFT)';
    o_query := o_query || ' AND (P.PROJ_ACTUAL_FLAG = ''P'')';
    o_query := o_query || ' AND (FACILITY_STATS.PROJ_ACTUAL_FLAG(+) = ''A'')';
    o_query := o_query || ' AND P.DESTINATION = ' || i_facility;
    o_query := o_query || ' AND P.SHIPPING_DATE = ' || i_date;
    o_query := o_query || ' AND (case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then P.SHIFT';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end =';
    o_query := o_query || ' case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then to_number(' || i_shift || ')';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end)) act_proj,';
    o_query := o_query || ' (SELECT Destination,';
    o_query := o_query || ' schedule_date,';
    o_query := o_query || ' shift,';
    o_query := o_query || ' job_class_grouping,';
    o_query := o_query || ' SUM ("Sched_Hours") "Sched_Hours"';
    o_query := o_query || ' FROM (';
    -- Loop to create bucket query
    for idx in 1..20 Loop
    o_query := o_query || '(SELECT EMP_SCHEDULE.EMPLOYEE_ID,';
    o_query := o_query || ' EMP_SCHEDULE.SCHEDULE_DATE,';
    o_query := o_query || ' EMP_SCHEDULE.DESTINATION,';
    o_query := o_query || ' EMP_SCHEDULE.SHIFT, ';
    o_query := o_query || idx || ' "Bucket_number",';
    o_query := o_query || ' Bucket' || idx || '_class "bucket class",';
    o_query := o_query || ' JOB_CLASS_GROUPING,';
    o_query := o_query || ' NVL (EMP_SCHEDULE.BUCKET' || idx || '_SCHED_HRS, 0) "Sched_Hours"';
    o_query := o_query || ' FROM STAFFING.EMP_SCHEDULE,';
    o_query := o_query || '(SELECT DISTINCT FACILITY_CLASS_BUCKET.JOB_CLASS_GROUPING,';
    o_query := o_query || ' FACILITY_CLASS_BUCKET.DESTINATION';
    o_query := o_query || ' FROM STAFFING.FACILITY_CLASS_BUCKET';
    o_query := o_query || ' WHERE (FACILITY_CLASS_BUCKET.BUCKET_ID = ' || idx || ')) A';
    o_query := o_query || ' Where A.Destination = EMP_SCHEDULE.DESTINATION';
    o_query := o_query || ' and EMP_SCHEDULE.DESTINATION = ' || i_facility;
    o_query := o_query || ' and EMP_SCHEDULE.SCHEDULE_DATE = ' || i_date;
    o_query := o_query || ' AND (case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then EMP_SCHEDULE.SHIFT';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end =';
    o_query := o_query || ' case';
    o_query := o_query || ' when to_number(' || i_shift || ') != -1';
    o_query := o_query || ' Then to_number(' || i_shift || ')';
    o_query := o_query || ' Else 1';
    o_query := o_query || ' end))';
    if idx < 20
    THEN
    o_query := o_query || ' UNION ';
    Else
    o_query := o_query || ')';
    End if;
    END Loop;
    o_query := o_query || ' GROUP BY Destination,';
    o_query := o_query || ' schedule_date,';
    o_query := o_query || ' shift,';
    o_query := o_query || ' job_class_grouping) Sched';
    o_query := o_query || ' WHERE (act_proj.DESTINATION = sched.DESTINATION(+))';
    o_query := o_query || ' AND (act_proj.SHIPPING_DATE = sched.SCHEDULE_DATE(+))';
    o_query := o_query || ' AND (act_proj.SHIFT = sched.SHIFT(+))';
    o_query := o_query || ' AND (act_proj.JOB_CLASS_GROUPING = sched.JOB_CLASS_GROUPING(+))';
    o_query := o_query || ' ORDER BY SHIFT,';
    o_query := o_query || ' job_class_grouping';
    Return (o_query);
    END;

  • Using :APP_ID in the sql query in apex

    Hi All,
    I am facing problem while using :APP_ID in the query for populating the Select list in apex.
    can any one suggest me how to use :APP_ID in the query. It is working fine in URL making.... in the javascript codes.
    And one more thing please put up the list of Global variable, Environment Variables in apex. like :APP_USER, :APP_ID
    Thanks in Advance,
    Santhosh Tirunahari

    Hello Santhosh,
    An example using APP_ID:
    select WORKSPACE, APPLICATION_ID, APPLICATION_NAME, LIST_NAME
    from APEX_APPLICATION_LIST_ENTRIES
    where APPLICATION_ID =:APP_IDGreetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • PL/SQL function body returning SQL query - ORA-06502: PL/SQL: numeric or value error

    I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option.  The SQL query generated will possibly be over 32K.  When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated.  I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL.  I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL.  Our environment is on 11gR2 and using ApEx 4.2.1.  I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using.  Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
    As a test, I created a page on apex.oracle.com with a report region with the following source:
    declare
      l_stub varchar2(25) := 'select * from sys.dual ';
      l_sql  clob := l_stub || 'union all ';
      br     number(3) := 33;
    begin
      while length ( l_sql ) < 34000 loop
        l_sql := l_sql || l_stub || 'union all ';
      end loop;
      l_sql := l_sql || l_stub;
      for i in 1 .. ceil ( length ( l_sql ) / br ) loop
        dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
      end loop;
      return l_sql;
    end;
    The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K.  When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed.  When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
    I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g.  Thoughts?
    Shane.

    What setting do you use in your report properties - especially in Type and in Region Source?
    If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
    According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
    declare
    mycond varchar2(4000);
    begin
    if :P1_REPORT_SEARCH is not null THEN
    mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
    end if;
    return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
    end;
    And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
    For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
    (You would than need to change the code of your function accordingly).
    If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query.

  • Validate and Edit SQL Query Errors

    I am trying to "Validate or Edit SQL Query" in APEX 3.0. When I open up the SQL Query its highlighted in red and when I click on the Validate or Edit button it gives me an error.
    I modified my marvel.conf file to include:
    AddType text/xml xbl
    AddType text/x-component htc
    and this still didnt take care of it. Any ideas and thank you in advance.
    PS: OPS - Windows Server 2003
    Upgraded from 1.6 to 3.0

    I've gotten so used to command line editing, that I rarely us "ed". back in the days of DOS, the default editor was EDLIN - one of those goofy editors that only showed one line at a time, so it wasn't much of an improvement. you could switch to the old dos editor, but that wasn't much better (just checked, it's still there)
    some nice things with command line editing
    to change everthing between the first two single quotes
    c/'...'/'new criteria'to remove everything after a specific string
    c/from.../fromto change a string that contains (or will contain) slashes
    c.1/2.1/4.

  • How to run a sql query from a button in apex 3.0

    Hi,
    I am brand new and went through/installed the obe project tracker. I have need to create a simple application that displays a result (2 fields, name and license number) based on two parameters (dob and login id) which all are stored in 1 table in the database. I could this very simply in VB or VB.net but have no idea how to do it in apex.
    Please provide guidance,
    Thank you,
    Tom

    Hi Tom,
    Sounds like a report region will satisfy your requirements.
    Create a new report region on one of your pages.
    Choose SQL Report and give the region a title.
    When you get to the "Enter SQL Query or PL/SQL function returning a SQL Query:" step, type:
    SELECT name, license_number
    FROM   <insert_your_table_name_here>
    WHERE  dob = :P<n>_dob
    AND    login_id = :P<n>loginid(replace <n> with the page number that the region is on and use your own table name).
    Don't try to run the page yet - it will give 'No data found'
    Now, go back to the Page Definition screen and add two items in the region you just created - call them P<n>dob and P<n>login_id
    Then, create a button in the same region (to be displayed amongst the region's items) - call it P<n>_GO and click 'Create' (take all the other defaults).
    Now you can run the page, put some values into the fields and click go.
    If you want to get fancier, you can change the text items to select lists etc. - let us know if you need help with that.
    Hope this helps,
    Bryan.

  • Apex 4.2 Report region sql query with "apex_item.text" renders wrongly

    In APEX 4.2 page i have created region "Report data".
    Type="SQl Query".
    "User Interface"-->"Template"="Reports Region".
    "Region Source"="select apex_item.text(1, '111') as c1 from dual".
    Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
    If i run in Sql Developer query
    select apex_item.text(1, '111') as c1 from dual;Then result is:
    <input type="text" name="f01" size="20" maxlength="2000" value="111"  />But in APEX 4.2 the report is rendered so:
    <td  headers="c1">&lt ;input type=&quot ;text&quot ; name=&quot;f01&quot; size=&quot;20&quot; maxlength=&quot;2000&quot; value=&quot;111&quot;  /&gt ;</td>(for this forum to display correctly i had to put extra spaces between" &gt" and ";" and so on)
    And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " &gt ;" .
    In APEX 3 i have similar query working well, without such anomaly.
    What attribute should i change in APEX 4.2 region to display my query result as needed?
    I need that function "apex_item.text", i cannot remove it.
    Edited by: CharlesRoos on 13.02.2013 15:28
    Edited by: CharlesRoos on 13.02.2013 15:29
    Edited by: CharlesRoos on 13.02.2013 15:29

    CharlesRoos wrote:
    In APEX 4.2 page i have created region "Report data".
    Type="SQl Query".
    "User Interface"-->"Template"="Reports Region".
    "Region Source"="select apex_item.text(1, '111') as c1 from dual".
    Actually the select query is little bit more complex, but generally simplified it is such, that it uses function "select apex_item.text" to construct HTML textfield.
    If i run in Sql Developer query
    select apex_item.text(1, '111') as c1 from dual;Then result is:
    <input type="text" name="f01" size="20" maxlength="2000" value="111"  />But in APEX 4.2 the report is rendered so:
    <td  headers="c1">&lt ;input type=&quot ;text&quot ; name="f01" size="20" maxlength="2000" value="111"  /&gt ;</td>(for this forum to display correctly i had to put extra spaces between" &gt" and ";" and so on)
    And APEX 4.2 shows ugly html inside report cell/slot for me, displaying characters/symbols ">". The reason is that APEX HTML page source does not have symbol ">" but has " &gt ;" .
    In APEX 3 i have similar query working well, without such anomaly.
    What attribute should i change in APEX 4.2 region to display my query result as needed?Ensure that the Display As Column Attribute for the C1 column is Standard Report Column.

  • APEX,PDF's, BI Publisher and SQL Query returning SQL code..

    I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
    I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
    Here is my dilemma:
    I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
    The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
    I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
    An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
    Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
    Thank you,
    Tony Miller
    UTMB/EHN
    Title adjusted to allow people to know what I am talking about...
    Message was edited by:
    Tony Miller

    Tony,
    You can find the log as follows:
    - go to http://[yourserver]:[yourport]/em
    - logon to OC4J EM: oc4jadmin/[yourpassword]
    - click on "logs" at the bottom of the page
    - in the hgrid/tree, expand OC4J->home->Application
    xmlpserver
    - click on view log icon
    You can also observe what's going on in BI Publisher
    by going to the command prompt from where you started
    it.
    Or, as a third option, you can locate the file on
    your file system, depending on your setup, the path
    would be something similar to this:
    \oracle\product\10.2.0\bip\j2ee\home\application-deplo
    yments\xmlpserver\application.log
    With that said though, I don't expect you'll find
    much in there that would help with your particular
    problem. I suspect you either get no rows in your XML
    at runtime, due to some session state issues, or your
    XML structure does in fact not match your RTF
    template.
    I'm not quite following your problem description,
    i.e. when did you do what and are you associating
    your report layout with a report query or report
    region. So just some general notes, your query needs
    to be parseable at design-time, when exporting the
    XML, so that you get the XML file with the proper
    column names derived from your query. If you want to
    use your RTF template with a standard report region,
    you must export the XML file first using the advanced
    XML structure option. And of course the column names
    in your report query need to match the column names
    in your report region.
    Perhaps this helps you further diagnose what's going
    on, if you have additional information that could
    help, let me know. And if you could stage this on
    apex.oracle.com, I'd be happy to take a look.
    Regards,
    MarcMarc,
    Thanks for looking at this issue. Below find my remarks to your questions..
    Re: your query needs
    to be parseable at design-time, when exporting the
    XML, so that you get the XML file with the proper
    column names derived from your query.At the start of this process, the query code was a function in a package. The function was returning an SQL select statement, for a report region on a page. I took the select statement, built an application query to build a sample of the xml for BI Publisher desktop (Add-on for Word). The code was producing the usual Col01, Col02.. since at design time that is were the column names.
    When I then took the xml from this and built the rtf for loading into my APEX application.
    When testing the Application Query with this RTF report layout, I am getting PDF's. When using it with the report region sending an xml feed to BI Publisher I am getting nothing back.
    I have since taken the sql code and moved it back into the report region, and set the region to have a type of straight SQL Query. I have even tried to hard-code the parameters I was getting from the page to limit data returned.
    Is it possible to see the xml being produced by the APEX page?
    Re: Stage this on apex.oracle.com.. I would love to, but we would have HIPPA issues if I posted the data on a public website.
    Can I send you the RTF file and the xml file that the application query is creating to see if there something weird about them?
    Thank you,
    Tony Miller
    UTMB/EHN

  • APEX, BI Publisher and SQL Query (PL/SQL Function returning SQL Query)..

    I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
    I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
    Here is my dilemma:
    I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
    The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
    I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
    An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
    Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
    Thank you,
    Tony Miller
    UTMB/EHN
    Title changed, maybe SOMEONE has an idea on this??
    Message was edited by:
    Tony Miller

    Hi,
    1/ first check you are passing the bind variables and
    appropriate values in the call to your report - if
    the query returns no data then you get an empty page
    So if your query takes :P10_USERNAME variable then
    pass it to the report in the URL
    f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=YOUR_REP_QUERY_N
    AME:::P10_USERNAME:MYUSER
    2/ try to use the Default layout first to check your
    report query really returns the data when called
    3/ if you defined a header in your rtf template check
    there is no & (ampersand) - if using & in the header
    and preview the template from word it displays data
    OK, but if you use this template in the report query
    it fails to render the data (bug in Apex-> Bi
    Publisher integration maybe?)
    4/ If using the table in the rtf template check its
    width does not overflow the page margins - there is a
    problem with pdf export
    5/ check
    /oc4j/j2ee/home/application-deployments/xmlpserver/app
    lication.log forthe information on BI Publisher runs
    RadoIssue was in the APEX page having issues.. I recoded a new page and am able to generate BI Publisher based PDF files..
    Thank you,
    Tony Miller
    UTMB/EHN

  • Oracle sql query execute in the apex

    hi:
    my requirement is, in region i have one text area item and query button.
    in this text area i am typing the any sql query and when i am pressing the query button it should display the query output report..
    pls give solution fast as soon as possible....
    Message was edited by:
    anbarasan

    Hi anbarasan,
    Maybe you can create a report of type "SQL query (PL/SQL Function returning query". Then in the region source, something like:
    DECLARE
    v_sql VARCHAR2 (4000);
    BEGIN
    v_sql := :PX_YOUR_ITEM;
    RETURN v_sql;
    END;
    Paulo Vale
    http://apex-notes.blogspot.com

  • Newbie - help with a SQL query for a bar chart  - Originally posted in APEX

    I originally posted this in the APEX forum but someone there suggested this is more of a SQL question.  Anyone out there who can provide some assistance?
    Hi,
    I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORY
    Order by COUNT(PROJECT_ID) DESC
    The code from the other app was:
    select null link
    , FUNCTIONAL_AREA label
    , count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
    , count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
    , count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
    from PM_V2
    where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
    group by FUNCTIONAL_AREA
    Order by COUNT(PROJECT_ID) DESC
    I'm getting a "Failed to parse SQL query!" error when I try to run validation.
    Is this enough info for some assistance? Any help would really be appreciated.
    Thanks,
    Rachel

    Hi, Rachel,
    user10774102 wrote:
    I originally posted this in the APEX forum but someone there suggested this is more of a SQL question.  Anyone out there who can provide some assistance?
    Hi,
    I'm a new user on APEX with no real SQL knowledge and I'm trying to build a dashboard with charts into an existing APEX application. Based on another application, I have come up with the following SQL code:
    select null link
    , CATEGORY label
    , count (decode(PROJECT_STATUS,'1',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'2',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'3',PROJECT_ID))"On Hold"
    , count (decode(PROJECT_STATUS,'4',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'5',PROJECT_ID))"Pending Review"
    from GRAPO_PROHEADTRK
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')
    group by CATEGORY
    Order by COUNT(PROJECT_ID) DESCIs there a problem with the code above?
    It's curious that the WHERE clause includes "PROJECT_STATUS='6'", but there is no pivoted column for project_status='6', like there is for '1' through '5'. That's not necessarily a mistake, and it wouldn't raise an error in any case.
    Instead of
    where (PROJECT_STATUS='1' or PROJECT_STATUS='2' or PROJECT_STATUS='3' or PROJECT_STATUS='4' or PROJECT_STATUS='5' or PROJECT_STATUS='6')you could say
    where PROJECT_STATUS  IN ('1', '2', '3', '4', '5', '6')but that probably has nothing to do with your current problem.
    The code from the other app was:
    select null link
    , FUNCTIONAL_AREA label
    , count (decode(PROJECT_STATUS,'Active',PROJECT_ID))"Active"
    , count (decode(PROJECT_STATUS,'Complete',PROJECT_ID))"Complete"
    , count (decode(PROJECT_STATUS,'On Hold',PROJECT_ID)) "On Hold"
    , count (decode(PROJECT_STATUS,'Recurring',PROJECT_ID))"Recurring"
    , count (decode(PROJECT_STATUS,'Pipeline',PROJECT_ID))"Pipeline"
    , count (decode(PROJECT_STATUS,'Not Approved',PROJECT_ID))"Not Approved"
    from PM_V2
    where LOB='S2S' and (FUNCTIONAL_AREA='Accounts Payable' or FUNCTIONAL_AREA='Expense' or FUNCTIONAL_AREA='Procurement' or FUNCTIONAL_AREA='Fixed Assets')
    group by FUNCTIONAL_AREA
    Order by COUNT(PROJECT_ID) DESC
    I'm getting a "Failed to parse SQL query!" error when I try to run validation.Is that an Apex error message? Sorry, I don't know anything about Apex.
    If you can't get a more specific error message from Apex, then try debugging this statement in SQL*Plus. When you get it fixed, then you can copy it back into Apex.
    If this is a SQL problem, then you should be able to re-create the problem in pure SQL.
    If you can't re-create the problem in pure SQL, then it's probably an Apex problem, and belongs in the Apex forum, not here.
    I don't see anything obviously wrong with your code, but I can't tell if, for example, you spelled a column name wrong, or if something has the wrong data type
    Is this enough info for some assistance? Any help would really be appreciated.It wiould be better if you posted a completE script that people could run to re-create the problem, and to test their ideas.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle (and any other software, such as Apex) you're using.

  • APEX 4.1, SQL Query(Updateable report), Validation issue.

    Hi,
    I am using APEX 4.1.
    I have SQL Query(Updateable report), we have created validation for the columns in this report.
    The validations are working properly only for the first row of the report on submitting, the remaining rows are not getting validated.
    If we check mark the rows it will get validated, but we want the validation to happen without checkmarking, on all the rows on clicking submit button.
    Can someone help me to fix this issue?
    Thanks in advance.
    Thanks & regards,
    Ravi.

    Hi Ravi,
    Welcome to Oracle Forums!
    Please acquaint yourself with the FAQ and forum etiquette if you haven't already done so.
    Always state
    <ul>
    <li>Apex Version</li>
    <li>DB Version and edition</li>
    <li>Web server used.I.e. EPG, OHS, ApexListner Standalone or with J2EE container</li>
    <li>When asking about forms always state tabular form if it is a tabular form</li>
    <li>When asking about reports always state Classic / IR</li>
    <li>Always post code snippets enclosed in a pair of &#123;code&#125; tags as explained in FAQ</li>
    </ul>
    I am using APEX 4.1.I have SQL Query(Updateable report), we have created validation for the columns in this report.
    The validations are working properly only for the first row of the report on submitting, the remaining rows are not getting validated.
    If we check mark the rows it will get validated, but we want the validation to happen without checkmarking, on all the rows on clicking submit button.
    Can someone help me to fix this issue?
    >
    Post your validation code with some explanations of what the g_fnn are.
    Cheers,

  • APEX validations in updateable reports built on a PL/SQL query

    Sorry if the question is not clear (english is not my mother language) or if the answer already exists on the forum (I have not been able to find it).
    I build a report on a PL/SQL function query.
    In this PL/SQL query i use apex_item.checkboxes or texts to let the end user change/enter some new data.
    As i need to do some validations on the user entries, i have already used some events (e.g. onChange) that trigger
    simple javascript validations checking if data is numeric or length of data entered....
    But i would like to use also the standard validations of APEX to make some more complex validations (e.g. checking coherency) on
    many data entered by the end user.
    I am trying to build a PL/SQL to loop through the report lines through a checkbox item i have added
    but the process of debugging is awfull for me.
    - Is there a pointer to a code example of validations within a query report that would help me in achieving this validation
    - or could someone give me some clue on how to acess these report data in the interface.
    Thanks in advance,
    Daniel

    Daniel:
    You can check out Denes Kubicek's APEX demo site for ideas on how to create validations for a tabular form.
    http://htmldb.oracle.com/pls/otn/f?p=31517:41:3322496527336906:::RP,::
    Varad

Maybe you are looking for

  • Storage location missing in purchase order

    Hi all, I'm struggling to find why the storage location is not copied from purchase requisition to purchase order using ME21n. Further this happens only for one buyer, the same PR's if converted in PO by other buyers, move correctly storage locations

  • If I delete an app on my old iPhone will it delete the same app on my new phone?

    My old iPhone 4s does not have data capability now that I have the new iPhone 6 plus. However, I still use the old phone for games and other apps. I also have some important information on the old and new phone since I downloaded all the information

  • WM report for slow moving items

    Hello, Is there any report in  WM for slow moving items (or Dead stock)? Regards,

  • Gtt taking very long - same thing in table runs fast why?

    Hi All, I have a report which is based off GTT. The reason we went for GTT is that process for each region can happen in parallel and users can run multiple reports. But it seems like when there is GTT report takes time (just this, other reports with

  • Invoking CFCs that extend mapped CFCs through the flex2gateway

    Hello all, I’ve run into an issue with my CFCs and I’m hoping someone can tell me why this is happening. Here is my setup in this scenario: I have a mapping for my CFCs on my local CF Server where Logical Path /CFC maps to C:\ColdFusion8\common\CFC T