Emailing results of a SQL Query....

I am new to Oracle and was wondering if there is a way to create an email task that could be used to email results of a sql query. My query returns emails addresses that meet a specified criteria. I want to use an email task that takes these addresses as variables and sends out an email to the specified email address.
Anyone provide any help with how I might do this?
Thanks.

Hi,
The odiSqlUnload has a "select" command. Is possible, at your process, work with the "LPAD()" and/or "RPAD()" function to complete the necessary whitespace at each column?
To the column heading I suggest you use the "union" like: (I put the lpad and rpad fuctions as example...)
select col1, col2, col3
from(
select 1 as internal_order, 'header_col1' as col1, 'header_col2' as col2, 'header_col3' as col3
from dual
UNION
select 2 as internal_order, RPAD(col1, 10, ' ') as col1 , LPAD(col2, 50, ' ') as col2 , col3
from your_table)
order by internal_order
Do you think this will work for you?

Similar Messages

  • End the result of an sql query by Email as an excel file attachement

    Hi,
    I would like to create a PL/SQL function that send the result of an sql query by Email as an excel file attachement.
    i'm newbie in pl/sql an d i dont know if it's possible to do such task.
    regards,

    i think a regular expression is he way to go in your case...
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Result of an SQL query as a Column name of another query

    Hi Friends,
    Can we use a result of a SQL Query as a column name of another table to retrieve data. If so please help me.
    For eg :
    I have a table where is store numbers;
    select col1 from table1 where col1='5';
    and i have another table where .. this value of col is a column name..
    select ( select col1 from table1 where col1='5') from table2;
    Thanks in advance.

    Hi,
    ORAFLEX wrote:
    Hi Friends,
    Can we use a result of a SQL Query as a column name of another table to retrieve data. If so please help me.
    For eg :
    I have a table where is store numbers;
    select col1 from table1 where col1='5';
    and i have another table where .. this value of col is a column name..
    select ( select col1 from table1 where col1='5') from table2;
    Thanks in advance.Do you really mean that?
    select col1 from table1 where col1='5';That query will always return either '5' or nothing. Whatever you're trying to accomplish with that, you can do with an EXISTS query.
    Perhaps you meant to reference two different columns in that query:
    select col1 from table1 where col2='5';In that case, sorry, no, you can't do that without resorting to dynamic SQL.
    If the same column is used throughout the query (but could change every time you run the query), then the dynamic SQL might be pretty easy. In SQL*Plus, for example, you could use substitution variables, defined in another query at run-time.
    If there are only a few possible values that the sub-query could possibly return, and you know what they all are, then you can fake a dynamic query like this:
    SELECT     CASE     ( SELECT  col1
                FROM       table1
                WHERE       col2     = '5'
              WHEN  'BONUS'     THEN  bonus
              WHEN  'COMM'     THEN  comm
              WHEN  'SAL'     THEN  sal
         END     AS col1
    FROM     table2
    ;Sorry to give such a vague answer, but it's the best I can do with the information I have.
    It would help if you posted a little sample data (CREATE TABLE and INSERT statments for both tables), and the results you want to get from that data. If you want to pass a parameter to the query, give the results you want for a couple of different parameters.

  • Pass the result of a SQL Query as table_name  for another SQL Query

    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    Thanks

    Naveen B wrote:
    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    ThanksYou should craete PL/SQL code with cursor which will accept a parameter and call that cursor inside the first one
    But if the first sql returns only one row, you can do it with simple sql code
    select * from (select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ')- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Last Result from Fulltext SQL Query Search Not Showing

    I am creating a custom search results page for MOSS 2007 (using inline .aspx code - don't ask) that uses Fulltext SQL Queries.  I get the results in a ResultTable (see code below) and then use a DataTable to write code to display it (I could have used
    a DataGrid, I know).
    The problem is that the last result is not showing. So, if it reports that there are 5 results, only 4 will show. I have verified that all 5 results do exist (using a slightly broadened query). If it reports 1 result, none exist in the DataTable that loads
    the result data from the ResultTable.
    FullTextSqlQuery query = new FullTextSqlQuery(site);
    query.ResultTypes = ResultType.RelevantResults;
    query.QueryText = qry;
    query.RowLimit = 50;
    query.StartRow = iPage;
    try
    ResultTableCollection results = query.Execute();
    ResultTable resultTable = results[ResultType.RelevantResults];
    DataTable table = new DataTable();
    table.Load(resultTable, LoadOption.OverwriteChanges);
    int n = resultTable.TotalRows;
    The variable "qry" is a valid SQL Query with the relevant clauses.
    I am using a foreach loop to go through "table" (a DataTable), and so I do not think that I have a "one-off error".
    Any suggestions would be most welcome.

    So in results you have all items but when you are loading it into table (type DataTable) you are loosing one last record.
    1) First you check what data you are getting in resultTable - as you are specifying RelevantResult
    2) Check last index of data in ResultTable collection and try to find out the last index ResultTable, or try to find last index of data in result table
    DataTable.Load method accepts parm of type IDataReader and IDatareader, there are cases it looses records if not read properly..check below links
    http://stackoverflow.com/questions/8396656/why-does-my-idatareader-lose-a-row
    http://msdn.microsoft.com/en-us/library/system.data.datatable.load(v=vs.110).aspx
    <hr> Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL <br/> <b><a href="http://insqlserver.com">Everything about SQL Server | Experience inside SQL Server </a></b>-<a href="http://insqlserver.com">Mohammad
    Nizamuddin </a>

  • Xml parsing error while selecting whole result set for sql query

    Hi All,
    I am having xml parsing error while selecting whole query result set. The data is coming fine for default result set of 50 rows.
    My exception is below.
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00234: namespace prefix "xsi" is not declared
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    *31011. 00000 - "XML parsing failed"*
    **Cause: XML parser returned an error while trying to parse the document.*
    **Action: Check if the document to be parsed is valid.*
    My sql query is below that is giving results for default result set of 50 rows.
    select extract(xmlType(clob_xml_colm_name), '//v2:node1//childnode/text()','xmlns:v2="namespace_url"').getStringVal()  from table_name
    My sql developer version is below.
    Java(TM) Platform     1.7.0_04
    Oracle IDE     3.1.07.42
    Versioning Support     3.1.07.42
    My database version is below.
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit
    Please could any one help me urgently as the sql query is supposed to be correct as it is returning query results, but the problem happening when i try to select whole result set.
    Thanks and regards,

    What does the XML look like? It appears that some of the supposed XML stored as a CLOB is not really valid XML. Find the row in the table that is causing your issue and review the "XML" in it.

  • Use the results of an SQL query to create another query

    I am working on a bidding/allocation system using C# and MySQL, and I am currently having difficulty implementing the “post-allocation” mechanics of the system. Let me explain how it works, before introducing the code:
    When the bids are made on the system, they all have the position 0, so the first thing the system does is order them according to priority.
     (bid table)
    In this case, 5 bidders are interested in what is in plot 15, but we have not assigned them a position yet.
     (bid table)
    The system then organises the bids according to the order in which they are going to processed.
    The bids are then allocated, but unfortunately there are only 3 spaces in plot 15 that can be allocated. As a result, we use the priority listing to determine which bidder gets what.
     (booking table)
    At this stage, I can say that I am stuck, there are two things that I want to do, both of which involve reusing the results of the query at step 2.
     (bid table)
    The bidders that have their job allocated should see: their bid.status updated
    from Queued to Allocated,
    the bid.position should
    be set to 0,
    and their job_id should
    be set to the booking they have been allocated (i.e. booking.id).
    The bidders that have not had their jobs allocated should see: their bid.status remain
    as Queued, and their bid.position should
    be set to 0 in
    preparation for the method to run again
    The difficulty I am having is in stage 3, how do I determine which jobs have been allocated and which ones have not, and then run the necessary SQL queries in order to make the updates?
    My code so far is as follows:
    // STEP 1a - SELECT BIDS
    string query =
    "SELECT t1.operator_id, t1.datetime, t1.plot_id, t1.position, t2.market_access FROM bid t1 " +
    "JOIN operator t2 ON t1.operator_id = t2.id WHERE t1.status='Queued' AND t1.postcode=@postcode " +
    "ORDER BY t2.market_access ASC, t1.datetime ASC";
    var bidList = new List<BidList>();
    var cmd = new MySqlCommand(query, _connection);
    cmd.Parameters.AddWithValue(("@postcode"), _plot);
    MySqlDataReader dataReader = cmd.ExecuteReader();
    while (dataReader.Read())
    var item = new BidList
    OperatorId = dataReader["operator_id"] + "",
    PlotId = dataReader["plot_id"] + "",
    Position = dataReader["position"] + "",
    Datetime = dataReader["datetime"] + "",
    MarketAccess = dataReader["market_access"] + "",
    bidList.Add(item);
    dataReader.Close();
    // STEP 1b - SET PRIORITIES
    for (var i = 0; i < bidList.Count; i++)
    var position = i + 1;
    bidList[i].Position = position.ToString();
    query = "UPDATE bid SET position=@position WHERE status='Queued' AND postcode=@postcode AND operator_id=@operator_id;";
    cmd = new MySqlCommand(query, _connection);
    cmd.Parameters.AddWithValue(("@position"), position);
    cmd.Parameters.AddWithValue(("@postcode"), _plot);
    cmd.Parameters.AddWithValue(("@operator_id"), bidList[i].OperatorId);
    cmd.ExecuteNonQuery();
    dataReader.Close();
    // STEP 2 - ALLOCATE JOBS ACCORDING TO PRIORITY
    foreach (var t in bidList)
    query = "SELECT operator_id, plot_id, status FROM booking " +
    "WHERE status='open' AND postcode=@postcode AND operator_id='0'" +
    "ORDER BY datetime ASC;" +
    "UPDATE booking SET operator_id=@operator_id, status='Allocated' " +
    "WHERE (plot_id=@plot_id AND operator_id='0' AND status='Open') LIMIT 1;";
    cmd = new MySqlCommand(query, _connection);
    cmd.Parameters.AddWithValue(("@operator_id"), t.OperatorId);
    cmd.Parameters.AddWithValue(("@postcode"), _plot);
    cmd.Parameters.AddWithValue(("@plot_id"), t.PlotId);
    cmd.ExecuteNonQuery();
    dataReader.Close();
    // STEP 3
    CloseConnection();

    I can't tell.  When modifying row(s) you have to be able to uniquely be able to identify the row(s) in the database you want to modify.  That is why I recommended the other day to use DataAdapter instead of the DataReader.  You can with the
    reader, but you need to unique identify the rows.
    I can't tell from the limited amount of data you posted if in table 2 that there is only one row with the same operator id and plot id.  It looks like in table 2 the 'id' number is unique.  When working with a database with multiple tables you
    need to be able to link tables together with primary keys (columns wit unique values).  If the database isn't designed properly then it is impossible to do some operations.  So you always have to make sure you design a database properly.
    jdweng
    When you say table 2 are you referring to the bid or booking table?
    Here is the table structure for the bid table
    Here is the table structure for the booking table
    Hope it helps makes things clearer!

  • How can I display multiple column results of a sql query?

    I'm wanting to display the results of a query selecting from multiple columns, but I can't seem to find an item type that will allow this. I've tried LOV, multiselect, display as text and others. Any ideas on how to do this. Here is my basic query:
    Select ul.meaning,
    rqa.submission_date,
    rqa.location_num
    from
    cfa_rqa_doc_submit_dates rqa,
    cfa_user_lookups ul
    where
    rqa.location_num in (Select location_num from cfa_current_locations_mv
    where operator_person_id = :P1_PERSON_ID and substr(location_num,1,1) = '8')
    and
    ul.lookup_type_id='1269'
    and
    to_char(rqa.submission_date, 'month') = to_char(sysdate, 'month')
    and
    rqa.submission_date >= (SYSDATE-365)
    and ul.lookup_ID= rqa.document_type_id
    ;

    Hi,
    Do you just wish to display the result of the query? If so, you can simply parse it out in HTML.
    You can then choose if you want to use tables or css.
    Multiple column layout in tables are based on <tr> and <td>.
    <tr> is a table row, where <td> is a column.
    All tags should be closed.
    Example:
    <table>
    <tr>
    <td>col1</td><td>col2</td>
    </tr>
    <tr>
    <td colspan="2">spans over 2 cols</td>
    </tr>
    </table>If you want to do the same in css:
    (Seems this forum removes the styles!):
    float:left; width:50; << first div and 2 div (col 1 and col 2 style)
    float:left;clear:both; width:100%; << clear both, double width (spans over 2)
    <div>
    <div style="float:left; width:50;">col1</div><div style="float:left;width:50%;">col2</div>
    <div style="float:left;clear:both; width=100%;">Spans over 2 cols</div>
    </div>The div might look more complicated, but if you refrain from styling in the tags them selves, you can define different styles in the .css file.
    You need the clear:both to start a new line with the divs that float.
    I usually run a dedicated "new line" div, without content.. (exception beeing the html-entities version of ' ' (& nbsp ; << without the spaces)).
    eg.:
    <div style="cls"> </div>Parsing out the values from the PL SQL you do like so:
    begin
    declare
       cursor c_search is 
    Select ul.meaning,
    rqa.submission_date,
    rqa.location_num
    from
    cfa_rqa_doc_submit_dates rqa,
    cfa_user_lookups ul
    where
    rqa.location_num in (Select location_num from cfa_current_locations_mv
    where operator_person_id = :P1_PERSON_ID and substr(location_num,1,1) = '8')
    and
    ul.lookup_type_id='1269'
    and
    to_char(rqa.submission_date, 'month') = to_char(sysdate, 'month')
    and
    rqa.submission_date >= (SYSDATE-365)
    and ul.lookup_ID= rqa.document_type_id
    begin  
    htp.p('<div style="width:80%;">');
    for v_search in c_search loop
    htp.p('<div style="float:left;clear:none;">'||v_search.location_num||'</div>');
    htp.p('<div style="float:left;clear:none;">'||v_search.submission_date||'</div>');
    end loop;
    htp.p('</div>');
      end;
    end;Ps. hope I understood you correctly, also this code is untested.. but I hope it can still help.
    Edited by: Olav Alexander Mjelde on May 12, 2010 9:36 AM

  • How to use the result of a sql query for a max () function

    Hi
    I wrote a query on which i wrote
    "select max(id) from users "
    how can i use the returned value.
    if i made the var name ="userid"
    can it be userid.rows[0] or what.
    thnx for any help

    Hi!
    The result of this query will be the max ID of users' IDs.
    Let say we have:
    String sql="select max(users.id) from users";
    Statement st = ctx.conn.createStatement();
    ResultSet rs = st.executeQuery(sql);
    rs.next();     
    So you can get the max Id in the following way:     
    int maxId=rs.getInt("id");
    Regards,
    Rossi

  • Input result from a SQL-query into a Variable in ProcessFlow

    I am trying to select a value from a table with file names.
    This file name should be input to an ftp function. I use a owb function to read the file name then I try to asign the result to a variable.
    The function GET_FILENAME looks like
    f_name varchar2(30);
    BEGIN
    select distinct FILENAME_SOURCE into f_name from CTL_SOURCE_FILES
    where FILEID = (select min(FILEID) from CTL_SOURCE_FILES where status is null);
    RETURN f_name;
    END;
    When running it as a SQL-script it returns only one row/name.
    When I am running it in the ProcessFlow the following message is found:
    RPE-02040: Internal error: GET_FILENAME cannot be converted to a constant value.

    Let me talk about this in context of a mapping:
    create a mapping :
    use a function within a mapping
    assign the output of the mapping to a mapping input variable"
    use this mapping within your process flow and see if it works.
    if you are directly going to use the output of a function in a process flow , the FTP should be able to accept the filename from the outparam of the function which i am not sure how it works.
    try using the first approach as it is relatively simple and straightforward.

  • How to present results from a sql-query in java

    Hi - I'm having problems finding out how to present data from a database-query in a nice looking way in a JFrame. Want to present them similar to the way they are presented in the database. Is there an easy way doing this?

    Tried to use a JTable, but it's difficult when data in the table should be able to change all the time, i.e the number of rows. What is a Html-table? Can i use it in an application?

  • Accessing select result in an SQL query

    I would like to know if anyone has a simple solution to this
    problem.
    I have a database with a table in it called events; the table
    has five fields: event_id, game_type_id, game_venue_id, game_day,
    and game_time.
    I would like to build a form that selects records in the
    table successively, based on the previous input. That is, once the
    user has selected the game_type, I'd like to show the user the
    game_venue for all the entries in the events table where
    game_type_id is equal to what the user selected and allow the user
    to select one. Then once the user has selected the game_type and
    game_venue, I'd like to show the user all the records in events
    that match the user's first two selections. Ditto for game_time. At
    the end of this, a unique record will have been determined.
    Some combinations of game_type, game_venue, game_day and
    game_time don't exist, so I can't just let the user indicate freely
    what they want.
    I suppose I could do it with multiple forms, each with it's
    own submit, but that's kind of clumsy. Is there some more elegant
    way?

    You can't refer to a pl/sql package constant in a sql statement.
    Create a function that returns the constant value and then refer to the function in a sql statement.

  • Making Buttons appear depending on the results of a SQL Query

    I need some help here I am still working on a time clock program
    I need help with the clock in and out buttons i need to know how to make
    the clock in button appear only if they are not clocked in. But I can not seem
    to make the sql statement or maybe my code is wrong, it needs to just get a
    count to see if they have any entries that have 0 in the hoursworked column
    and if so then it needs to just display the clock out if not then just the clockin button needs to be displayed this was my orignal code that was not working
    <%   
        String statement = "select count(*) as cnt from TimeSheet Where idnum = " + session.getAttribute("IDNUM");
        stmt.execute(statement);
        rs = stmt.getResultSet();
        rs.next();
        int num = rs.getInt("cnt");
        if (num == 0 || num == null)
        {%>
            <tr>
                <td><input type="submit" value="Clock In" name="button"></td>
            </tr>
        <%}
        else
        {%>
            <tr>
                <td><input type="submit" value="Clock Out" name="button"></td>
            </tr>
         <% } %>but it did not work it would only display the clock out button so i need to figure this out so that the user can not clock into the program twice to get double hours and so forth.

    Does it even compile ?Yes, it wouldnt, not even in 1.5
    it needs to just get a
    count to see if they have any entries that have 0 in the hoursworked column
    and if so then it needs to just display the clock out if not then just the clockin button needs to be displayed in which case,
    1. your sql is not correct.
    2. session.getAttribute("attrName") returns an Object - is the IDNUM column of type number
    (going by the fact that you have not enclosed the value in single quotes '')
    Assuming that you have a column called 'hoursworked' in table 'timesheet' and
    IDNUM is of type NUMBER
    <%
         Integer idNum = (Integer)session.getAttribute("IDNUM");
         //from the OP ::  get a count to see if they have any entries that have 0 in the hoursworked column
         String statement = "select count(*) as CNT from TIMESHEET where IDNUM = " + idNum + " and HOURSWORKED = 0 ";
         //remaining stuff :: Look out for the error pointed out by Pgeuens
         cheers,
    ram.

  • How can i achive this result by writing SQL Query ?

    Dear Exparts,
    Here is my banner
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    "CORE     10.2.0.3.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - ProductionI have two table with relation. Here is the scripts of create table and insert data.
    TABLE
    CREATE TABLE TAB1
      T1_ID NUMBER(5)
    , T1_NAME VARCHAR2(100)
    ALTER TABLE TAB1 
    MODIFY (T1_ID NOT NULL);
    ALTER TABLE TAB1
    ADD CONSTRAINT TAB1_PK PRIMARY KEY
      T1_ID
    ENABLE;
    CREATE TABLE TAB2
      T2_ID NUMBER(5) NOT NULL
    , T2_T1_ID NUMBER(5)
    , T2_RV_NO VARCHAR2(20)
    , T2_RV_DATE DATE
    , T2_F1 VARCHAR2(20)
    , T2_F2 VARCHAR2(20)
    , T2_F3 VARCHAR2(20)
    , CONSTRAINT TAB2_PK PRIMARY KEY
        T2_ID
      ENABLE
    ALTER TABLE TAB2
    ADD CONSTRAINT TAB2_TAB1_FK1 FOREIGN KEY
      T2_T1_ID
    REFERENCES TAB1
      T1_ID
    ENABLE;INSERT DATA
    Insert into TAB1 (T1_ID,T1_NAME) values (1,'Test 1');
    Insert into TAB1 (T1_ID,T1_NAME) values (2,'Test 2');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (1,1,'00',to_date('01-OCT-2012','DD-MON-RRRR'),'Probation','05','Yes');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (2,1,'01',to_date('06-OCT-2012','DD-MON-RRRR'),'Confirm','06','Yes');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (3,2,'00',to_date('02-OCT-2012','DD-MON-RRRR'),'Probation','07','No');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (4,2,'01',to_date('09-OCT-2012','DD-MON-RRRR'),'Probation','07','Yes');
    Insert into TAB2 (T2_ID,T2_T1_ID,T2_RV_NO,T2_RV_DATE,T2_F1,T2_F2,T2_F3) values (5,1,'02',to_date('10-OCT-2012','DD-MON-RRRR'),'Confirm','06','No');Now i want to produce the following reports..
    Period:      06-OCT-2012 to 09-OCT-2012
    T2_RV_DATE     T1_NAME          T2_RV_NO     Revised_Column     Previous_Value     Revised_value
    06-OCT-2012     Test 1          01          T2_F1          Probation     Confirm
                                  T2_F2          05          06
    09-OCT-2012     Test 2          01          T2_F3          No          YesI just achieve Revised_Column     Previous_Value     Revised_value for a particular name.
    Here is my code
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F1' Revised_Column,PREVIOUS_VALUE,REVISED_VALUE
    FROM(
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F1',
    LAG(T2_F1) OVER (ORDER BY T2_RV_DATE) PREVIOUS_VALUE ,T2_F1 REVISED_VALUE
    FROM TAB2,TAB1
    WHERE TAB1.T1_ID=TAB2.T2_T1_ID
    AND TAB1.T1_ID=:EMP_ID)
    WHERE NVL(PREVIOUS_VALUE,'null')<>NVL(REVISED_VALUE,'null')
    AND T2_RV_DATE BETWEEN :BEGIN_DATE AND :END_DATE
    AND T2_RV_NO<>'00'
    UNION ALL
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F2' Revised_Column,PREVIOUS_VALUE,REVISED_VALUE
    FROM(
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F2',
    LAG(T2_F2) OVER (ORDER BY T2_RV_DATE) PREVIOUS_VALUE ,T2_F2 REVISED_VALUE
    FROM TAB2,TAB1
    WHERE TAB1.T1_ID=TAB2.T2_T1_ID
    AND TAB1.T1_ID=:EMP_ID)
    WHERE NVL(PREVIOUS_VALUE,'null')<>NVL(REVISED_VALUE,'null')
    AND T2_RV_DATE BETWEEN :BEGIN_DATE AND :END_DATE
    AND T2_RV_NO<>'00'
    UNION ALL
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F3' Revised_Column,PREVIOUS_VALUE,REVISED_VALUE
    FROM(
    SELECT T2_RV_NO,T2_RV_DATE,T1_NAME,'T2_F3',
    LAG(T2_F3) OVER (ORDER BY T2_RV_DATE) PREVIOUS_VALUE ,T2_F3 REVISED_VALUE
    FROM TAB2,TAB1
    WHERE TAB1.T1_ID=TAB2.T2_T1_ID
    AND TAB1.T1_ID=:EMP_ID)
    WHERE NVL(PREVIOUS_VALUE,'null')<>NVL(REVISED_VALUE,'null')
    AND T2_RV_DATE BETWEEN :BEGIN_DATE AND :END_DATE
    AND T2_RV_NO<>'00'but it's not work for multiple employee id
    Thanks in advance
    Edited by: Asked to Learn on Oct 6, 2012 9:18 PM

    Asked to Learn wrote:
    thanks members. i get a solution of my own for my reporting purpos. Thanks..Well why don't you post your solution? Why not be helpful to others like yourself who might search the forum looking for answers? Don't just take, give back.
    Cheers, APC

  • Concatenate results SQL query and CASE use Report Builder Reporting Services

    I need to concatenate the results from a SQL query that is using CASE.  The query is listed below.  I do not need permitsubtype but I need to concatenate the results from the permittype. 
    I tried deleting the permitsubtype query and it would not run correctly.  Please see the query and diagram below.  Any help is appreciated.
    select  PERMIT_NO
    ,(case when
      ISNULL(PERMITTYPE,'') = ''
      then 'Unassigned'
      else (select LTRIM(RTRIM(PERMITTYPE)))
      END) AS PERMITTYPE
    ,(case when
      ISNULL(PERMITSUBTYPE,'') = ''
      then 'Unassigned'
      else (select LTRIM(RTRIM(PERMITSUBTYPE)))
      END) AS PERMITSUBTYPE
     ,ISSUED
     ,APPLIED
     ,STATUS 
     ,SITE_ADDR 
     ,SITE_APN
     ,SITE_SUBDIVISION
     ,OWNER_NAME
     ,CONTRACTOR_NAME
     ,ISNULL(JOBVALUE,0) AS JOBVALUE
     ,FEES_CHARGED
     ,FEES_PAID
    ,BLDG_SF
    from Permit_Main
    where ISSUED between @FromDate and @ToDate

    Hi KittyCat101,
    As per my understanding, you used case when statement in the query, you do not need to display permitsubtype in the report, but when you tried to delete permitsubtype from the query, it could not run correctly. In order to improve the efficiency of troubleshooting,
    I need to ask several questions:
    “I tried deleting the permitsubtype query and it would not run correctly.” As we can see, it has no effect to delete permitsubtype from the query you provided, could you please provide complete sql query for the report?
    Could you please provide detailed information about the report? I would be appreciated it if you could provide sample data and screenshot of the report.
    Please provide some more detailed information of your requirements.
    This may be a lot of information to ask for at one time. However, by collecting this information now, it will help us move more quickly toward a solution.
    Thanks,
    Wendy Fu

Maybe you are looking for

  • Problem of Creating a web dynpro application based on a car rental web serv

    Based original SAP developer studio examples shipped with the developer studio, I first create J2EE application “QuickCarRental”. It works at http://192.168.254.4:50300/QuickCarRental. A web service “QuickCarRentalWebService” is defined in J2EE appli

  • Character encoding in unix environment.

    Hi, Users try to download files from my application. These files are uploaded by others. They may contain characters from foreign languages as well. The file names are displayed properly on the screen, but when the user clicks on the link to download

  • How to make round borders on moving object

    what i'm trying to do is to make objects move randomly in a circle.... i found codes for rectangular boundary...but can't find anything with curves... hope you guys know how to deal with my problem..thanks!

  • Reinstall windows os and deactivate itunes

    before i reinstall my vista os software,  what would be the procedures to make sure i do not lose any of my apps and/or music files purchased through itunes?

  • USB seems to not work properly anymore with Mountain Lion

    I just upgraded to Mountain Lion. Tried to transfer pictures from my DSLR camera but it cannot be detected anymore. My external hard disk does not work anymore as well. Can anybody please help? Thanks.