Formatting SQL Query output in HTMLDB

Guys, I would like to show the result in report of SQL Query to be formatted in such way:
I got a table USERS with columns:FIrst_name, second_name, team_name, team_leader.
So in a report in HTMLDB I would like to format the result to show all employees , 500 of them, on 1 page, and show in a header for each team, team leader and team name with the rest of team underneath,so only two columns, break on team_leader or team_name, then next team, and then, NOT all this in one long display, but in three sets of result, spread in wide of report, cause the screen dimensions are quite wide.I tried few things but they do not work. I can break on tem leader or team name, but all this is still in one long set of result, not in 3 or 4 tables sets.
help
Jozef

Hi Kamal,
I am using Oracle Applications 11.5.7 iProcurement. Database is 9i. I need to place a link in iProcurement homepage using AK Developer and when clicked it should run a query and output the result in a browser.
help appreciated
thanks

Similar Messages

  • Formatting SQL query as of iSQL*PLUS query output format through PL/SQL

    This is my procedure through which i m sending an e-mail. In my e-mail i want to show output from error log query. I can show it in simple text but i want the output for the error log to be formatted as the query result is formated in iSQLPlus.
    In simple words instead of the message i want to send the query result which is formatted as iSqlPlus query output. Thankx in advance. Please provide a simple solution that iSqlPlus engine recieves my any given query and gives the formatted output for that query in the e-mail
    DECLARE
    conn utl_smtp.connection;
    v_log number;
    BEGIN
    conn := demo_mail.begin_mail(
    sender => '<sender-email>',
    recipients => '<recipient-email>',
    subject => 'HTML E-mail Test',
    mime_type => 'text/html');
    </h1>
    -- This method will be used for oracle error reporting');
    demo_mail.write_text(
    conn => conn,
    message => '<h1>Hi! This is a <i>test msg</i>);
    demo_mail.end_mail( conn => conn );
    END;

    oe@ORA102>
        select * from
        (select rownum r1, p.promo_id, promo_name from promotions p where rownum <5)
        full outer join
        (select rownum r2, w.warehouse_id from warehouses w where rownum <4)
       on (r1 = r2)
    oe@ORA102>/
            R1   PROMO_ID PROMO_NAME                   R2 WAREHOUSE_ID
             1          1 everyday low price            1            1
             2          2 blowout sale                  2            2
                                                        3            3
    oe@ORA102>But there should be "some connection" between the result sets, otherwise the resulting result set become unpredictable / meaning less.
    I am joining on ROWNUM, Do you want every row from emp related to every row from stocks (like a cartesian join)?
    Trying to understand the requirement.
    vr,
    Sudhakar B.

  • SQL query output

    Dear friends ,
    I want to view a select query using page by page . Is it possible to do in SQL ?
    suppose here is an example of select query :
    sql > select * from v$session ;
    I want to see the output as page by page .
    waiting for ur kind reply . .. ..

    Hi, (assuming you use Db 10g v.2)
    you should read the chapter "6 Formatting SQL*Plus Reports" of e-book:
    SQL*Plus® User's Guide and Reference
    Release 10.2
    Part Number B14357-01
    and especially the 'break' command.....
    Greetings,
    Sim

  • Writing a function to find whether a value is present in a sql query output

    Hi gurus,
    I would like to write a function to which i will pass a value and a sql query as parameters.
    Now the function needs to execute that sql query and find whether the given value is present in the output list
    when the query is executed. If it is present it should return 'T' otherwise 'F'
    My function will look like
    CREATE FUNCTION CHECK_VALUE(VALUE VARCHAR2,V_SQL VARCHAR2) RETURN VARCHAR2
    SELECT CHECK_VALUE('Dallas','SELECT LOCATION_CODE FROM HR_LOCATIONS')
    It should check whether the value 'Dallas' is present in the output list returned by the sql query.
    Any help will be appreciated.
    Thank you.

    CREATE OR REPLACE
      FUNCTION CHECK_VALUE(
                           VALUE VARCHAR2,
                           V_SQL VARCHAR2
        RETURN VARCHAR2
        IS
            RETVAL VARCHAR2(4000);
            REFCUR SYS_REFCURSOR;
        BEGIN
            OPEN REFCUR FOR V_SQL;
            LOOP
              FETCH REFCUR INTO RETVAL;
              EXIT WHEN REFCUR%NOTFOUND;
              IF RETVAL = VALUE
                THEN
                  CLOSE REFCUR;
                  RETURN 'T';
              END IF;
            END LOOP;
            CLOSE REFCUR;
            RETURN 'F';
    END;
    Function created.
    SQL> SET SERVEROUTPUT ON
    SQL> EXEC DBMS_OUTPUT.PUT_LINE(CHECK_VALUE('DALLAS','select loc from dept'));
    T
    PL/SQL procedure successfully completed.
    SQL> EXEC DBMS_OUTPUT.PUT_LINE(CHECK_VALUE('PARIS','select loc from dept'));
    F
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Need help on format for query output

    I am new to SQL Developer.
    When I run a query in the worksheet, sometimes the results are in table format and sometimes they are in text format. I would like to have the output always in table format, as it is easier to save to Excel that way.
    Is there a setting for this? Or can someone explain to me what triggers the format to change for some queries?
    I am using SQL D 3.1.07 Build MAIN-07.42 and accessing an instance on 11.2.0.2.

    Hi,
    Welcome to the forum!
    If you look carefully at the worksheet's toolbar, you will notice two green arrowhead icons on the left side: one larger and one smaller imposed over a lined paper image. How they work:
    1. The larger renders the query result in a grid format (what you call table format). Hover over it with the mouse and see: Run Statement (Ctrl+Enter)
    2. The smaller renders the query result in script output format. Hover over it with the mouse and see: Run Script (F5)
    Regards,
    Gary
    SQL Developer Team
    Edited by: Gary Graham on May 17, 2013 10:38 AM
    Also, if you use Run Statement to execute code that is inherently script-like, it will treat as if you used Run Script

  • SQL query Output  exceeds 65000 rows in excel

    Hi,
    I have a SQL file attached to my concurrent program. The query in the SQL file returns tab separated output that i need to email as a csv through the same SQL file.
    The issue I am facing is that the query returns about 157000 records but only 65536 are being displayed in the excel worksheet.
    How can I get all the records by accommodating them in multiple worksheets of the same excel file?
    Please help!
    I am using EBS 11i.
    Code I am using in SQL file:
    set pages 3000
    set lines 300
    set heading off
    set term off
    set feedback off
    set verify off
    set echo off
    set serverout off
    spool /tmp/TEST.csv
    select 'Header'
    from dual
    SELECT column1||CHR(9)||column2
    FROM staging_table
    spool off
    set lines 1000 pages 40 head off echo off veri off
    select 'cd /tmp; cat $XX_TOP/install/sql/disclaimer.txt > x.dat; cat '||'/tmp/TEST.csv'||' | uuencode '||'/tmp/TEST.csv'
    ||' > '||substr('/tmp/TEST.csv',1,length('/tmp/TEST.csv')-4)||'.dat >> x.dat'
    ||' ; mail -s ''' ||'&1'||''' '||'&2'||' < x.dat'
    ||' ; rm '||substr('/tmp/TEST.csv',1,length('/tmp/TEST.csv')-4)||'.dat'||' ;'
    from dual
    list
    spool /tmp/email.txt
    spool off
    host chmod 777 /tmp/email.txt
    host /tmp/email.txt
    Thanks
    Edited by: user10648285 on May 13, 2011 5:27 AM

    open a blank Excel (2007 version), go to Data tab, then from External Data click From Text, select the CSV file (That having more than 65k records), click import, then from "start import at row" select 65001 and click next button, select delimiter as Comma, click Next button and filaly finish.
    In this way you will have the data after 65k rows in excel. Now you can simply open that cvs file in excel then you will have first 65k records (remening part will be discarded).
    So now you have two excel files and you can paste it in two diff tab.
    Note - you can repeate this activity if you have more than 130000 records...

  • SBO SQL Query outputs zero values as nulls but need the zeros

    Hi all,
    I'm having a problem with a query I'm writing in SBO where if the field contents are zero, these are output as null.
    I have a field for the stock usage on sales orders and ont too for production orders, but if I add these together they only provide a result if both columns contain a numeric value.
    I've tried adding "0" to the column value, adding and subtracting "1" and also multiplying the value by "1" but still no joy.
    I have also tried adding a "cast" statement to the column, but that doesnt seem to have an effect either (I think as this is more an output function).
    I need to be able to use these columns as separate displays in addition to being used in a further column as part of a calculation.
    If anyone has an idea how I can output a true zero value as opposed to a null value your help would be appreciated.
    Cheers,
    J

    Hello Julian,
    You could try to use a CASE Statement as I have shown below and test this will the SQL below.  If you use the T0.LineNum without any CASE or CAST the LineNum 0 will show as blank in SAP.
    SELECT
    CASE WHEN T0.LineNum != 0 THEN CAST(T0.LineNum AS VARCHAR(10)) ELSE '0' END AS 'Row Number',
    T0.ItemCode AS 'Item No.', T0.BaseQty AS 'Base Quantity', T0.PlannedQty AS 'Planned Quantity - Rows'  FROM  [dbo\].[WOR1\] T0

  • Simple SQL Query Output

    Table1:
    ID      EMPNAME COUNTRY
    101     XYZ     USA
    102     ABC     UK
    103     XYZ     USA
    104     ABC     UK
    Required output:
    ID      EMPNAME COUNTRY CALCULATED_VALUE
    101     XYZ     USA     1
    102     ABC     UK     1
    103     XYZ     USA     0
    104     ABC     UK     0
    Every 1st record of (EMPNAME, COUNTRY) combination should have CALCULATED_VALUE =1 and all succeeding records of same (EMPNAME, COUNTRY) combination should have CALCULATED_VALUE =0

    Try this ->
    scott>
    scott>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.02
    scott>
    scott>
    scott>with t
      2  as
      3    (
      4      select 101 ID, 'XYZ' EMPNAME, 'USA' COUNTRY from dual
      5      union all
      6      select 102, 'ABC', 'UK' from dual
      7      union all
      8      select 103, 'XYZ', 'USA' from dual
      9      union all
    10      select 104, 'ABC', 'UK' from dual
    11    )
    12  select ID,
    13         EMPNAME,
    14         COUNTRY,
    15         case
    16           when rn = 1 then
    17             1
    18         else
    19           0
    20         end CALCULATED_VALUE
    21  from (
    22         select ID,
    23                EMPNAME,
    24                COUNTRY,
    25                row_number() over(partition by COUNTRY order by ID) rn
    26         from t
    27       )
    28  order by ID;
            ID EMP COU CALCULATED_VALUE
           101 XYZ USA                1
           102 ABC UK                 1
           103 XYZ USA                0
           104 ABC UK                 0
    Elapsed: 00:00:00.00
    scott>Regards.
    Satyaki De.

  • Reg: sql query output

    hi All, 
    select  substr(16878575,1, (length(16878575)-length(substr(16878575, -2,2)))) ||'.' || substr(16878575, -2,2) from dual;
    output - 168785.75. getting correct output.
    Can you please let me know is there any other way to do that?
    thanks in advance.

    This way, if you need to get a number with Two Decimal places.
    with data as
      select 16878575 col from dual
    select col/100 col from data;
    COL                   
    168785.75

  • SQL Query - The number of columns specified in "SQL Query" does not match t

    I am creating new UDM for tablespace alert, below is my query,however its failing with error
    SQL Query - The number of columns specified in "SQL Query" does not match the value specified in "SQL Query Output"
    I selected Metric type is number
    SQL Query Format : Two columns
    Query:
    SELECT d.tablespace_name,round(((a.bytes - NVL(f.bytes,0))*100/a.maxbytes),2)
    used_pct FROM sys.dba_tablespaces d,(select tablespace_name, sum(bytes) bytes, sum(greatest(maxbytes,bytes)) maxbytes from sys.dba_data_files group by tablespace_name) a,(select tablespace_name, sum(bytes) bytes from sys.dba_free_space group by tablespace_name) f
    WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+)
    AND NOT (d.extent_management = 'LOCAL' AND d.contents = 'TEMPORARY');
    Any clues why i am getting error.

    SQL> SELECT d.tablespace_name,round(((a.bytes - NVL(f.bytes,0))*100/a.maxbytes),2) used_pct
    2 FROM sys.dba_tablespaces d,(select tablespace_name, sum(bytes) bytes, sum(greatest(maxbytes,bytes)) maxbytes from sys.dba_data_files group by tablespace_name) a,(select tablespace_name, sum(bytes) bytes from sys.dba_free_space group by tablespace_name) f
    3 WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+)
    4 AND NOT (d.extent_management = 'LOCAL' AND d.contents = 'TEMPORARY');
    TABLESPACE_NAME USED_PCT
    MGMT_TABLESPACE .82
    SYSAUX 1.52
    UNDOTBS1 .32
    RMAN .02
    CORRUPT_TS 10.63
    USERS 0
    SYSTEM 2.26
    MGMT_ECM_DEPOT_TS .04
    MGMT_AD4J_TS 0

  • New Line Character in SQL Query

    Dear All,
    I am wondering if some one tell me how to insert new line character in the SQL Query Output for example I need out put in the following format. Every line on new line.
    The total count is:
    Registration: 1111
    Fees paid: 2222
    Admission Done: 3333
    Total:4000
    Many thanks

    Hi
    SQL> select
      2  'The total count is:
      3  Registration: 1111
      4  Fees paid: 2222
      5  Admission Done: 3333
      6  Total:4000
      7  ' dummy_txt from dual
      8  /
    DUMMY_TXT
    The total count is:
    Registration: 1111
    Fees paid: 2222
    Admission Done: 3333
    Total:4000
    SQL>
    SQL> select 'a'||chr(10)||'b' from dual;
    'A'
    a
    b
    SQL> T

  • Using 'Function Returning SQL Query' with Flash charts

    I have created a pl/sql function that returns a SQL query as a varchar2 of this form:
    select null link
    <x value> value
    <Series1 y value> Series 1 Label
    <Series2 y value> Series 2 Label
    <Series3 y value> Series 3 Label
    from tablea a
    join tableb b
    on a.col = b.col
    order by <x value>
    If I now call the function from a Flash Chart Series SQL box with the Query Source Type set to 'Function Returning SQL Query' like this:
    return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'))
    it parses correctly and the page is saved; however, when I run the page I don't get any output - nor any error messages or other indication of a problem.
    Now, if I call the function in a SQL client, capture the SQL query output using dbms_output and paste that into the Flash Chart Series SQL box - changing the Query Source Type to SQL Query - and save the page it works fine when I run it and returns a multi-series flash chart.
    Can anyone suggest either;
    1. What have I might have missed or done wrong?
    2. Any way to usefully diagnose the problem...
    I have tried using the Apex debugger - which is very nice, by the way - but it doesn't provide any info on what my problem might be. I even tried writing my own debug messages from my function using the apex_debug_message package - got nothing...
    Thanks,
    Eric

    Hi Eric,
    Try expressing the source as this:
    begin
       return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
    end;That works fine for me, and if I take out the begin-end and the trailing semicolon from the return statement I get the same behavior as you.
    It does mention in the help for the source (only during the wizard though) that this source type has to be expressed that way, but I agree it would be helpful if the tool would validate for this format when 'Function Returning SQL Query' is used or give some sort of indication of the trouble. Anyway, this should get you going again.
    Hope this helps,
    John
    If you find this information useful, please remember to mark the post "helpful" or "correct" so that others may benefit as well.

  • Difference of sql query in SQL Workshop and SQL Report (case when sum(...

    Hi ,
    I need some help, pls.
    The follwg report runs in SQL Workshop - but gives errors in the sql-query report in HTMLDB:
    SQL-Workshop:
    select
    case
    when SUM(S.POTENTIAL_GROWTH)> 1 and SUM(S.POTENTIAL_GROWTH) < 4 then 'Ok'
    when SUM(S.POTENTIAL_GROWTH)> 4 and SUM(S.POTENTIAL_GROWTH) < 8 then 'SoSo'
    when SUM(S.POTENTIAL_GROWTH)> 8 and SUM(S.POTENTIAL_GROWTH) < 12 then 'Very Good'
    else 'too much'
    end
    from "SEGMENTATION" S
    In an HTMLDB SQL-Query Report I added Aliases (as requested for HTML) but still gives the error:
    <<Query cannot be parsed, please check the syntax of your query. (ORA-00920: invalid relational operator) >>
    the code:
    select
    case
    when SUM(S.POTENTIAL_GROWTH) pot_growth > 1 and SUM(S.POTENTIAL_GROWTH)pot_growth < 4 then 'Ok'
    when SUM(S.POTENTIAL_GROWTH)pot_growth > 4 and SUM(S.POTENTIAL_GROWTH)pot_growth < 8 then 'SoSo'
    when SUM(S.POTENTIAL_GROWTH)pot_growth > 8 and SUM(S.POTENTIAL_GROWTH)pot_growth < 12 then 'Very Good'
    else 'too much'
    end
    from "SEGMENTATION" S
    any halp from the gurus wud be very much appreciated.
    TIA
    Bernhard

    Still you did not give the alias for the case when column. For that only you should give the alias
    select
    case
    when SUM(S.POTENTIAL_GROWTH) pot_growth &gt; 1 and SUM(S.POTENTIAL_GROWTH)pot_growth &lt; 4 then 'Ok'
    when SUM(S.POTENTIAL_GROWTH)pot_growth &gt; 4 and SUM(S.POTENTIAL_GROWTH)pot_growth &lt; 8 then 'SoSo'
    when SUM(S.POTENTIAL_GROWTH)pot_growth &gt; 8 and SUM(S.POTENTIAL_GROWTH)pot_growth &lt; 12 then 'Very Good'
    else 'too much'
    end "GROWTH"
    from "SEGMENTATION" S

  • SQL Query in Japanese Language

    Hello ,
    May i please ask a query.... We have a japanese customer and he prefers to get the SQL Query output in Japanese output. Is that possible via SQLPLUS?
    Regards
    Ajay

    May i please ask a query.... We have a japanese customer and he prefers to get the SQL Query output in Japanese output. Is that possible via SQLPLUS?Yes, make sure you set NLS_LANG properly.
    The correct NLS_LANG setting in Unix Environments [ID 264157.1]
    The correct NLS_LANG in a Windows Environment [ID 179133.1]
    NLS_LANG Explained (How does Client-Server Character Conversion Work?) [ID 158577.1]
    How to Determine the NLS_LANG setting of the SQL*Plus Client? [ID 344891.1]
    The Priority of NLS Parameters Explained (Where To Define NLS Parameters) [ID 241047.1]
    AL32UTF8 / UTF8 (Unicode) Database Character Set Implications [ID 788156.1]
    Thanks,
    Hussein

  • SQL query for custom alert view

    I have created a custom alert view and scoped to show alerts related to group of servers.
    Alert view Criteria: Resolution State - New, Severity - Warning and Critical, Group - "Group 1"
    I am trying to query the Operations Manager database to show the alerts with same criteria using below query.
    select MonitoringObjectName, ResolutionState, Priority, Severity, TimeRaised, TimeAdded, TimeResolved, AlertStringName, AlertStringDescription from AlertView where ResolutionState = '0' AND (Severity = '2' or Severity = '1')
    AND
    MonitoringObjectId IN (select TargetObjectId from RelationshipGenericView
    where SourceObjectDisplayName = 'Group 1')
    in Console i see both warning and critical alerts where as in SQL query output i see only critical alerts.  Could you please correct if I am using wrong query. also please share your suggessions if i am completely wrong on this.
    Kind Regards,
    Bommi
    ~Bommi

    your query looks perfectly fine. Are you sure if the alerts you see in the console are of the 'Resolution State =0' (New). It might be the case where the alert have moved to a fidderent resolution state.
    Also, take a sample warming alert from console, query for the same in DB and check the Severity value. If it is '2'.
    Regards,
    Saravanan

Maybe you are looking for

  • How do I sync non iTunes content to my iOS devices with Mavericks

    For the last three days I have been pulling my hair out wondering why I can't sync Movies or TV Shows to my iPad using either the USB cable or WiFi in iTunes since installing Mavericks. the only way I have succeed at all is to redownload items alread

  • Photos look less sharp when not in editing view

    This is kind of confusing to explain...but I'll try! When editing a photo in iPhoto '09, I adjusted it to what I wanted, but once I leave editing mode and view the photo as a preview (by double clicking on the thumbnail) it looks much less sharp and

  • Getting BAM Error

    Hi, We are getting below error in bam. Its intermittent, after bounce it works fine .... We are on 10.1.3 and using plan to pull data to populate data object. Please suggest ? Thanks in advance, 2010-07-13 13:14:29,295 [1220] ERROR - ActiveDataCache

  • Movie dimensions, blog vs podcast?

    I want to create of video podcasts series. I create a podcast, drop a 16x9 movie on the entry page. It's 16x9. I change to the podcast (list) page and it's square. Can't fix it because you can't edit this page, only the enty page which is the right s

  • HT5868 So how do I "untrust" a trusted computer that I accidentally trusted but still want to use for charging?

    I see that "Trust" a computer on iOS7 is indefinite (learned). How do I undo that on a computer that I want to use for charging but do not want to trust?