SQL to return the first line

Hello guys,.

I use a sql to sort a single column of a specific sort order, I need just the first returned row based on ID (doc_no) here is an example:
SQL> WITH 
  2  table_a AS (
  3  SELECT 1 doc_no, 'Description of 1' doc_desc FROM DUAL UNION ALL
  4  SELECT 2, 'Description of 2' FROM DUAL),
  5  table_b AS (
  6  SELECT 1 fk_doc_no, 'A' client_rev, TO_DATE ('10/10/2008', 'dd/mm/yyyy') due_date, 
  7   TO_DATE ('10/10/2008', 'dd/mm/yyyy') trans_date FROM DUAL UNION ALL
  8  SELECT 1, 'B', TO_DATE ('05/11/2008', 'dd/mm/yyyy'), TO_DATE ('05/11/2008', 'dd/mm/yyyy') FROM DUAL UNION ALL
  9  SELECT 1, '0', NULL, TO_DATE ('21/11/2008', 'dd/mm/yyyy') FROM DUAL UNION ALL
 10  SELECT 2, 'A', TO_DATE ('25/11/2008', 'dd/mm/yyyy'), TO_DATE ('25/11/2008', 'dd/mm/yyyy') FROM DUAL UNION ALL
 11  SELECT 2, '0', NULL, TO_DATE ('25/11/2008', 'dd/mm/yyyy') FROM DUAL)
 12  SELECT x.doc_no, x.doc_desc, y.last_client_rev, y.due_date, y.trans_date
 13  FROM (SELECT   fk_doc_no,
 14                 MAX (client_rev) KEEP
 15                   (DENSE_RANK LAST ORDER BY TRANSLATE(client_rev
 16                                                       ,'ABCD012' -- Desired sort order
 17                                                       ,'012ABCD' -- Actual sort order
 18                                                      )) AS last_client_rev,
 19                 due_date, trans_date
 20            FROM table_b
 21        GROUP BY fk_doc_no, due_date, trans_date) y,
 22       table_a x
 23  WHERE x.doc_no = y.fk_doc_no;
The result is:
    DOC_NO DOC_DESC         L DUE_DATE TRANS_DA
---------- ---------------- - -------- --------
         1 Description of 1 0          21/11/08
         1 Description of 1 A 10/10/08 10/10/08
         1 Description of 1 B 05/11/08 05/11/08
         2 Description of 2 0          25/11/08
         2 Description of 2 A 25/11/08 25/11/08
The required data will be:
    DOC_NO DOC_DESC         L DUE_DATE TRANS_DA
---------- ---------------- - -------- --------
         1 Description of 1 0          21/11/08
         2 Description of 2 0          25/11/08
Can you help me with this?

Best regards.
BTW: I use Oracle 10 g

Hello
You don't need a subquery

SELECT   fk_doc_no, doc_desc,
         MAX (client_rev)KEEP (DENSE_RANK LAST ORDER BY TRANSLATE
                                              (client_rev,
                                               'ABCD012' -- Desired sort order
                                                        ,
                                               '012ABCD'  -- Actual sort order
                                              )) AS last_client_rev,
         MAX (due_date)KEEP (DENSE_RANK LAST ORDER BY TRANSLATE
                                              (client_rev,
                                               'ABCD012' -- Desired sort order
                                                        ,
                                               '012ABCD'  -- Actual sort order
                                              ),
          trans_date) due_date,
         MAX (trans_date)KEEP (DENSE_RANK LAST ORDER BY TRANSLATE
                                              (client_rev,
                                               'ABCD012' -- Desired sort order
                                                        ,
                                               '012ABCD'  -- Actual sort order
                                              )) trans_date
    FROM table_a x, table_b y
   WHERE x.doc_no = y.fk_doc_no
GROUP BY y.fk_doc_no, doc_desc
SQL> WITH table_a AS
  2       (SELECT 1 doc_no, 'Description of 1' doc_desc
  3          FROM DUAL
  4        UNION ALL
  5        SELECT 2, 'Description of 2'
  6          FROM DUAL),
  7       table_b AS
  8       (SELECT 1 fk_doc_no, 'A' client_rev,
  9               TO_DATE ('10/10/2008', 'dd/mm/yyyy') due_date,
 10               TO_DATE ('10/10/2008', 'dd/mm/yyyy') trans_date
 11          FROM DUAL
 12        UNION ALL
 13        SELECT 1, 'B', TO_DATE ('05/11/2008', 'dd/mm/yyyy'),
 14               TO_DATE ('05/11/2008', 'dd/mm/yyyy')
 15          FROM DUAL
 16        UNION ALL
 17        SELECT 1, '0', NULL, TO_DATE ('21/11/2008', 'dd/mm/yyyy')
 18          FROM DUAL
 19        UNION ALL
 20        SELECT 2, 'A', TO_DATE ('25/11/2008', 'dd/mm/yyyy'),
 21               TO_DATE ('25/11/2008', 'dd/mm/yyyy')
 22          FROM DUAL
 23        UNION ALL
 24        SELECT 2, '0', NULL, TO_DATE ('25/11/2008', 'dd/mm/yyyy')
 25          FROM DUAL)
 26  SELECT   fk_doc_no, doc_desc,
 27           MAX (client_rev)KEEP (DENSE_RANK LAST ORDER BY TRANSLATE
 28                                                (client_rev,
 29                                                 'ABCD012' -- Desired sort order
 30                                                          ,
 31                                                 '012ABCD'  -- Actual sort order
 32                                                )) AS last_client_rev,
 33           MAX (due_date)KEEP (DENSE_RANK LAST ORDER BY TRANSLATE
 34                                                (client_rev,
 35                                                 'ABCD012' -- Desired sort order
 36                                                          ,
 37                                                 '012ABCD'  -- Actual sort order
 38                                                ),
 39            trans_date) due_date,
 40           MAX (trans_date)KEEP (DENSE_RANK LAST ORDER BY TRANSLATE
 41                                                (client_rev,
 42                                                 'ABCD012' -- Desired sort order
 43                                                          ,
 44                                                 '012ABCD'  -- Actual sort order
 45                                                )) trans_date
 46      FROM table_a x, table_b y
 47     WHERE x.doc_no = y.fk_doc_no
 48  GROUP BY y.fk_doc_no, doc_desc
 49  /

 FK_DOC_NO DOC_DESC         L DUE_DATE   TRANS_DATE
---------- ---------------- - ---------- ----------
         1 Description of 1 0            2008-11-21
         2 Description of 2 0            2008-11-25

SQL> 

Published by: Salim champion 2009-01-26 06:47

Tags: Database

Similar Questions

  • Return the first line with a non-null value in a column

    Hey there, gurus. Can someone give me a hand with this?

    I have a table with six columns: Class_ID, Course_ID, start_date, Last_Name, First_Name, company. When our students take a class and will fill in an evaluation form, they fill in the Class_ID Last_Name First_Name, and Company. The Course_ID and Start_Date are filled automatically based on the Class_ID.

    I am trying to generate a report that contains Class_ID, Course_ID and Start_Date, PLUS the value of the first not null in the column of company for a combination given to the three first columns. Here is my SQL that does not quite do the trick:

    Select distinct c.class_id, c.course_id, c.start_date, p.company
    class c, person p, student s
    where substr (c.course_id, 1, 3) = "OBI".
    and c.start_date > = SYSDATE-30
    and c.class_id = s.class_id
    and s.pid = p.pid
    order start_date, company, class_id, course_id

    At present, if in a given class, a student entered "CCCC" under the name of the company and another entry "Collin Co Comm Coll" and another between "Collin College", I would get three rows of this class when you use the SQL above. I want just one line. I don't really like which company names gets selected - one of them will be great for our needs. I just need to see a line for each class_id and single value that some students entered the area of the company. And I guess I have to say that if no student fills in the name of the company I need to see the value null, because I need to see the line no matter what.

    Looks like some sort of funky outer join or a coalesce, but it is beyond my ability to understand.

    Now I get this:
    During class 1234 SQL271 Date 22/07/2013 company XYZ Inc.
    Made up of class 1234 SQL271 Date 22/07/2013 company XYZ
    1234 SQL271 Date 22/07/2013 company XYZ, class

    What I want:
    Class 1234 SQL271 22/07/2013 Date course XYZ Inc. or one of the other 2

    Thanks in advance!
    select c.class_id, c.course_id, c.start_date, max(p.company) company
    from class c, person p, student s
    where substr(c.course_id,1,3) = 'OBI'
    and c.start_date >= SYSDATE-30
    and c.class_id = s.class_id
    and s.pid = p.pid
    group by c.class_id, c.course_id, c.start_date
    order by class_id, start_date, course_id
    

    Or if you want to list all businesses, you can use LISTAGG if you're on the latest version of ORACLE

  • Discover with function as datasource returns only the first line.

    Hello

    I created the following function to get the status of all the rules for the instances of SQL Server.

    The data type of the function output has been configured as 'List of SQLInstanceRuleStatuss', where SQLInstanceRuleStatuss is the custom type, I created in the same module.

    When I tested the function, it returns all instances of SQL Server with two other columns.

    But when I try to create a view with the Rows property that is configured to use the feature, it returns only the first line:

    sqlRules = new ArrayList();

    queryStatement = server. QueryService.createStatement ("(DBSS_Instance)");

    queryResult = server. QueryService.executeStatement (queryStatement);

    for (it in queryResult.topologyObjects)

    {

    sqlRule is functionHelper.createDataObject ("westjet_mark_dev:SQLInstanceRuleStatus", "none", "test");.

    sqlRule.instance = it;

    sqlRule.ruleName = 'test rule name';

    sqlRule.status = false;

    sqlRules.add (sqlRule);

    }

    Return sqlRules;

    Did I miss something?

    Thank you

    Mark

    Mark,

    I think I forgot something

    sqlRule=functionHelper.createDataObject("westjet_mark_dev:SQLInstanceRuleStatus","none","test");

    you create the test id

    change your line of

    sqlRule=functionHelper.createDataObject("westjet_mark_dev:SQLInstanceRuleStatus","none",null);

    This should allow the creation of a single object in your loop for

  • Foreach returns only the first line of a dataset object

    Hello, guys.

    I am having trouble with a procedure in Oracle 9.2.0.1.0.

    I have a query that returns the number of lines, but whenever I try to browse by using a foreach loop, I only get the first line and then the loop is completed.

    For example, here's the query:

    select 
          (
            CASE
              WHEN
                TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'),'DD/MM/YYYY') < DATE '2009-01-01'
              THEN DATE '2009-01-01'
              ELSE
                TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'), 'DD/MM/YYYY')
              END
          ) startdate,
    
    
          (
            CASE
              WHEN
              TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level) -1,'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'),'DD/MM/YYYY') > DATE '2009-06-08'
              THEN DATE '2009-06-08'
              ELSE 
              TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level) -1,'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'), 'DD/MM/YYYY')
              END
          ) enddate
         
        FROM dual
        CONNECT by trunc(DATE '2009-06-08','dd') >= add_months(trunc(DATE '2009-01-01','dd'),level - 1)
    

    Who shows me this output:

    STARTDATEENDDATE
    01/01/20092009-01-31
    02/01/200928/02/2009
    03/01/200931/03/2009
    04/01/200930/04/2009
    05/01/200931/05/2009
    06/01/200906/08/2009

    But whenever I run this code:

      for rec in
      (
        select 
          (
            CASE
              WHEN
                TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'),'DD/MM/YYYY') < DATE '2009-01-01'
              THEN DATE '2009-01-01'
              ELSE
                TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'), 'DD/MM/YYYY')
              END
          ) startdate,
          (
            CASE
              WHEN
              TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level) -1,'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'),'DD/MM/YYYY') > DATE '2009-06-08'
              THEN DATE '2009-06-08'
              ELSE 
              TO_DATE(
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level) -1,'dd') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'mm') || '/' ||
                to_char(add_months(trunc(DATE '2009-01-01','mm'),level - 1),'yyyy'), 'DD/MM/YYYY')
              END
          ) enddate
         
        FROM dual
        CONNECT by trunc(DATE '2009-06-08','dd') >= add_months(trunc(DATE '2009-01-01','dd'),level - 1)    
      )
      loop
        DBMS_OUTPUT.put_line(TO_CHAR(rec.startdate, 'YYYYMMDD') || '-' || TO_CHAR(rec.enddate, 'YYYYMMDD'));
      end loop;
    

    I get this result:

    20090131 20090101

    I tried debugging and I checked that the loop runs that once, and then passes the end of loop. I'm doing something wrong?

    Thank you!

    Best regards

    Vinicius

    Try:

    for rec in

    (

    Select * from (select

    (

    CASE

    WHEN

    TO_DATE)

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), "jj"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), "mm"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), 'yyyy'), "DD/MM/YYYY")< date="">

    THEN DAY ' 2009-01-01'

    ON THE OTHER

    TO_DATE)

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), "jj"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), "mm"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), 'yyyy'), "DD/MM/YYYY")

    END

    ) startdate.

    (

    CASE

    WHEN

    TO_DATE)

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm') and level)-1, "dd"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), "mm"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), 'yyyy'), ' DD/MM/YYYY') > DATE '' 2009-06-08

    THEN DAY '' 2009-06-08

    ON THE OTHER

    TO_DATE)

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm') and level)-1, "dd"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), "mm"). '/' ||

    TO_CHAR (add_months (trunc (DATE ' 2009-01-01', 'mm'), level - 1), 'yyyy'), "DD/MM/YYYY")

    END

    ) enddate

    OF the double

    CONNECT by trunc (DATE 2009-06 - 08 ',' dd') > = add_months (trunc (DATE 2009-01 - 01 ',' dd'), level - 1)

    )   )

    loop

    Dbms_output.put_line (TO_CHAR (rec.startdate, 'YYYYMMDD') |) '-' || To_char (rec.enddate, 'YYYYMMDD'));

    end loop;

    SY.

  • Problem with white - style commentary on the first line of the select statement.

    SQL * more error? :
    It seems that the parser does not like "-" at the end of the first line of the request.
    I see this error "ORA-00936: lack of expression" or "ORA-00933: not correctly completed SQL command.
    SQL * Plus costs number not the 2nd line when I do that.
    If a space follows-, '-', I still get the error.
    a single "-" at the end of the line is ignored and the query works
    But, "-." will not get the error.
    I think that I had this problem before on the inside in the middle of a procedure from PL/SQL package.
    --
    It is of course easy to avoid. Is this just a quirk or am I missing something?
    -----
    SQL * more: 9.0.1.4.0 output
    Oracle Database 10 g Enterprise Edition release 10.2.0.3.0

    ----------------------------------------------
    -- These provoke an error
    ----------------------------------------------
    SQL select 'a' --
     from dual;
    select 'a' - from dual
                 *
    ERROR at line 1:
    ORA-00936: missing expression
    
    /* the -- is "-- " */
    SQL select 'a','b','c' --
     from dual;
    select 'a','b','c' - from dual
                         *
    ERROR at line 1:
    ORA-00936: missing expression
    
    SQL select --
     select 'a' from dual --
     ;
    select - select 'a' from dual -
             *
    ERROR at line 1:
    ORA-00936: missing expression
    
    
    SQL select 'a' from dual --
     ;
    select 'a' from dual -
                         *
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    ----------------------------------------------
    -- These are OK 
    ----------------------------------------------
    SQL select 'a' --.
      2  from dual;
    
    '
    -
    a
    Elapsed: 00:00:00.00
    SQL select
      2  'a' --
      3  from dual;
    
    '
    -
    a
    
    ------- a single "-" at the end of the line is ignored, query works
    SQL select 'a' from dual -
     ;
    
    '
    -
    a
    
    
    SQL

    Actually, it's in the docs, but we rarely know.

    >
    Continuing a long SQL More control on additional lines *.
    You can continue a long SQL * more command by typing a hyphen at the end of the line and press return. If you want, you can type a space before you type the hyphen. SQL * Plus displays a right angle (>) support as a prompt for each additional line (not in iSQL * more).

    For example:

    SALARY $99 999 COLUMN FORMAT-
    SECTION "WAGES."
    Since SQL * Plus identifies the hyphen as a continuation character, entering a hyphen in a statement SQL is ignored by SQL * more. SQL * more does not identify the declaration as a SQL statement until after the treatment of entry has joined lines together and removed the hyphen. For example, enter the following:

    SELECT - 200
    100 DOUBLE;
    Returns the error:

    >

    It only happens for the first line of a sql statement, because at that time there you are not in the edit buffer. And the order could still be a sql * more order and not a sql command.

    Published by: Sven w. on August 7, 2009 16:51

  • Pleazzz... help me put my record of the opening on the first line

    I use this query inside my builder6 (oracle10g) report, but it is untimely return of output.
    only when I give the start date of the report (: m_frm_date) as the opening date (op_date), the balance
    the report that is stored in the table op_bal, happens correctly, with the first line, the opening balance.
    later, when I try to run the same report giving other start dates, opening balance
    line was traded to the second row. Please refer to the screenshot of my reports, for the best idea.
    select op_date, TNO,OP_CODE,EI,withdrawal,deposit,
    sum(NVL(DEPOSIT,0)-NVL(WITHDRAWAL,0)) over (order by op_date,TNO) bal
    from
    (
    select op_date, NULL TNO,null OP_CODE,NULL EI,withdrawal,deposit
    from
    (
    select  :M_FRM_DATE op_date, sum(withdrawal) withdrawal, sum(deposit) deposit
    from
    (
    select :M_FRM_DATE op_date,sum(DECODE(EXPN_EI,'E',EXN_AMOUNT)) WITHDRAWAL,
    sum(DECODE(EXPN_EI,'I',EXN_AMOUNT)) DEPOSIT
    from EXPENSES_TXN, expense_master
    where exn_acnt_code = expn_code
    and exn_date < to_CHAR(:M_FRM_DATE,'dd/mm/yyyy')
    union all
    select op_date, null withdrawal, op_amount deposit
    from op_bal))
    union all
    SELECT
    EXN_DATE,
    EXN_NO,
    EXN_ACNT_CODE,
    EXPN_EI,
    DECODE(EXPN_EI,'E',EXN_AMOUNT) WITHDRAWAL,
    DECODE(EXPN_EI,'I',EXN_AMOUNT) DEPOSIT
    FROM EXPENSES_TXN, EXPENSE_MASTER
    WHERE EXN_ACNT_CODE = EXPN_CODE
    and EXN_DATE between to_CHAR(:M_FRM_DATE,'dd/mm/yyyy') and to_CHAR(:M_UPTO_DATE,'dd/mm/yyyy'))
    order by op_DATE,tno
    /
    this is the actual for which report has to come;
    SQL> select * from op_bal;
     
    OP_COD OP_NAME            OP_DATE       OP_AMOUNT
    ------ ------------------ --------- -------------
    OP0000 NATIONAL BANK      01-JAN-09      5000.000
     
    *Date No.2*
    SQL> SELECT
      2  EXN_DATE,
      3  EXN_NO,
      4  EXN_ACNT_CODE,
      5  EXPN_EI,
      6  DECODE(EXPN_EI,'E',EXN_AMOUNT) WITHDRAWAL,
      7  DECODE(EXPN_EI,'I',EXN_AMOUNT) DEPOSIT
      8  FROM EXPENSES_TXN, EXPENSE_MASTER
      9  WHERE EXN_ACNT_CODE = EXPN_CODE
     10  order by 1;
     
    EXN_DATE         EXN_NO EXN_AC E    WITHDRAWAL       DEPOSIT
    --------- ------------- ------ - ------------- -------------
    01-MAR-09         2.000 AC0002 E      2000.000
    10-MAR-09         7.000 AC0012 I                     500.000
    15-MAR-09         5.000 AC0007 E        15.000
    20-MAR-09         8.000 AC0012 I                     700.000
    31-MAR-09         6.000 AC0008 E        30.000
    01-APR-09         9.000 AC0013 I                     250.000
    07-APR-09         1.000 AC0001 E       200.000
    09-APR-09         4.000 AC0011 E        35.000
    09-APR-09         3.000 AC0003 E        50.000
     
    9 rows selected.
    http://S640.Photobucket.com/albums/uu123/fairoozxp/?action=view & Current = EXPRPT.jpg
    http://S640.Photobucket.com/albums/uu123/fairoozxp/?action=view & Current = EXPRPT1.jpg
    http://S640.Photobucket.com/albums/uu123/fairoozxp/?action=view & Current = EXPRPT2.jpg

    much appreciated, tyvm.

    Hello

    Is the problem that, when it is be a rank with exn_date =: m_frm_date, the line which represents the total front: m_frm_date sometimes appears after him?
    If Yes, then you must add something to the ORDEER TO ensure that the total line comes first.
    If NWT is NULL rfor only the total row, and then, as said to put, simply add 'NULLS FIRST' to "ORDER BY tno". Don't forget to do this as well in the analytical AGENDA BY:

    OVER (ORDER BY op_date, tno NULLS FIRST)     AS bal
    

    towards the beginning of your query and the result ORDER BY value at the end:

    ORDER BY  op_date,
                 tno          NULLS FIRST;
    

    If reallly NWT can be null, you can create a new column (I'll call her sort_key) ust to distinguish the total line on the lines later. SELECT a literal 1 sort_key of ACE in the part of the UNION that created the total line, and then '2 AS sort_key' in the part of the UNION, who gets lines and after: m_frm_date:

    SELECT     op_date, tno, op_code, ei, withdrawal, deposit,
         SUM ( NVL (deposit, 0)
             - NVL (withdrawal, 0)
             ) OVER (ORDER BY op_date, sort_key, tno)     AS bal
    FROM
         (
         SELECT  TO_DATE (:m_frm_date, 'dd/mm/yyyy')        AS op_date,
              NULL                                  AS tno,
              NULL                            AS op_code,
              NULL                            AS ei,
              withdrawal,
              deposit,
              1                                        AS sort_key
         FROM
              (     -- Begin sub-query for expenses before :m_frm_date          SELECT  TO_DATE (:m_frm_date, 'dd/mm/yyyy')        AS op_date,
              SELECT     SUM (withdrawal)                        AS withdrawal,
                   SUM (deposit)                          AS deposit
              FROM
                   (
                   SELECT     SUM (DECODE (expn_ei, 'E', exn_amount))     AS withdrawal,
                        SUM (DECODE (expn_ei, 'I', exn_amount)) AS deposit
                   FROM     expenses_txn,
                        expense_master
                   WHERE     exn_acnt_code     = expn_code
                   AND     exn_date     < TO_DATE (:m_frm_date, 'dd/mm/yyyy')
                   UNION ALL
                   SELECT     NULL          AS withdrawal,
                        op_amount     AS deposit
                   FROM     op_bal
                   )
              )     -- End sub-query for expenses before :m_frm_date
         UNION ALL
         SELECT     exn_date,
              exn_no,
              exn_acnt_code,
              expn_ei,
              DECODE (expn_ei, 'E', exn_amount)     AS withdrawal,
              DECODE (expn_ei, 'I', exn_amount)     AS deposit,
              2                               AS sort_key
         FROM     expenses_txn,
              expense_master
         WHERE     exn_acnt_code     = expn_code
         AND     exn_date      BETWEEN  TO_DATE (:m_frm_date, 'dd/mm/yyyy')
                         AND       TO_DATE (:m_upto_date,'dd/mm/yyyy')
         )
    ORDER BY  op_date,
                 sort_key,
                 tno;
    

    Be sure to use strings to represent DATEs. If: m_frm_date is a string, it must always be used with TO_DATE and TO_CHAR ever.

    Never, send or even write, unformatted code.
    During the validation of code on this site, type the 6 characters
    {code}
    (small letters only, inside curly braces) before and after the code for formatting, to keep the spacing.

  • Scan of a file only works on the first line

    Hello

    I'm new to Labview (see 8.6) and I'm running on this problem.

    I use the Scan of a file to get a certain amount of information for the installation of test.txt.  The data of the file looks like this:

    AAA 1

    BBB 2

    REC 3

    I noticed that the Scan of the file works for only the first line.  Trying to get data that are not in the first line results in an error 85.

    Any ideas? Thank you

    It's all in what the scan of the file reads, and what is the next cgaracter in the file.

    Your first analysis of the file reads up to but NOT including the first newline in the file.

    The second read readings where the first reading was arrested and is expected to see 'B' as the next character, but sees the new line instead, and if the analysis fails. You must specify second reading formatted to await the return line.

    You can do this by making the FIRST character of the format string space, that will tell it to expect a number any of charaters 'white space '.

    Yo can indeed put a space at the beginning of the format string in your first analysis of the file and it will match with zero white space characters before you see the AAA. By doing this he also tolerate to see the spaces and tabs before your AAA or BBB identifiers.

    Rod.

  • Mr President, how can I enter two rows at the same time with different default values that only the first line to use see?

    Mr President.

    My worm jdev is 12.2.1

    How to enter two rows at the same time with different default values that only the first line to use see?

    Suppose I have a table with four fields as below

    "DEBIT" VARCHAR2(7) , 
      "DRNAME" VARCHAR2(50),
      "CREDIT" VARCHAR2(7) , 
      "CRNAME" VARCHAR2(50),
    

    Now I want that when I click on a button (create an insert) to create the first line with the default values below

    firstrow.png

    So if I click on the button and then validate the second row with different values is also inserted on commit.

    The value of the second row are like the picture below

    tworows.png

    But the second row should be invisible. It could be achieved by adding vc in the vo.

    The difficult part in my question is therefore, to add the second row with the new default values.

    Because I already added default values in the first row.

    Now how to add second time default values.

    Concerning

    Mr President

    I change the code given by expensive Sameh Nassar and get my results.

    Thanks once again dear Sameh Nassar .

    My code to get my goal is

    First line of code is

        protected void doDML(int operation, TransactionEvent e) {    
    
            if(operation != DML_DELETE)
                 {
                     setAmount(getPurqty().multiply(getUnitpurprice()));
                 } 
    
            if (operation == DML_INSERT )
                       {
                               System.out.println("I am in Insert with vid= " + getVid());
                           insertSecondRowInDatabase(getVid(),getLineitem(),"6010010","SALES TAX PAYABLE",
                            (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));      
    
                           }
    
            if(operation == DML_UPDATE)
                              {                                                    
    
                                 System.out.println("I am in Update with vid= " + getVid());
                             updateSecondRowInDatabase(getVid(),
                                 (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));      
    
                              }                      
    
            super.doDML(operation, e);
        }
        private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4, Object value5)
                  {
                    PreparedStatement stat = null;
                    try
                    {
                      String sql = "Insert into vdet (VID,LINEITEM,DEBIT,DRNAME,AMOUNT) values " +
                 "('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "','" + value5 + "')";  
    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);
                      stat.executeUpdate();
                    }
                    catch (Exception e)
                    {
                      e.printStackTrace();
                    }
                    finally
                    {
                      try
                      {
                        stat.close();
                      }
                      catch (Exception e)
                      {
                        e.printStackTrace();
                      }
                    }
                  }  
    
                  private void updateSecondRowInDatabase(Object value1, Object value5)
                  {
                    PreparedStatement stat = null;
                    try
                    {
                      String sql = "update vdet set  AMOUNT='"+ value5+"' where VID='" + value1 + "'";                     
    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
    
                      stat.executeUpdate();
                    }
                    catch (Exception e)
                    {
                      e.printStackTrace();
                    }
                    finally
                    {
                      try
                      {
                        stat.close();
                      }
                      catch (Exception e)
                      {
                        e.printStackTrace();
                      }
                    }                  
    
                  }
    

    Second line code is inside a bean method

        public void addNewPurchaseVoucher(ActionEvent actionEvent) {
            // Add event code here...
    
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
                   DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");
                   RowSetIterator rsi = dciter.getRowSetIterator();
                   Row lastRow = rsi.last();
                   int lastRowIndex = rsi.getRangeIndexOf(lastRow);
                   Row newRow = rsi.createRow();
                   newRow.setNewRowState(Row.STATUS_NEW);
                   rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);
                   rsi.setCurrentRow(newRow);
    
                   BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();
                   DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");
                   RowSetIterator rsi1 = dciter1.getRowSetIterator();
                   Row lastRow1 = rsi1.last();
                   int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);
                   Row newRow1 = rsi1.createRow();
                   newRow1.setNewRowState(Row.STATUS_NEW);
                   rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);
                   rsi1.setCurrentRow(newRow1);
        }
    

    And final saveUpdate method is

        public void saveUpdateButton(ActionEvent actionEvent) {
            // Add event code here...
    
            BindingContainer bindingsBC = BindingContext.getCurrent().getCurrentBindingsEntry();      
    
                   OperationBinding commit = bindingsBC.getOperationBinding("Commit");
                   commit.execute(); 
    
            OperationBinding operationBinding = BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Commit");
            operationBinding.execute();
            DCIteratorBinding iter = (DCIteratorBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("VdetView1Iterator");// write iterator name from pageDef.
            iter.getViewObject().executeQuery();  
    
        }
    

    Thanks for all the cooperation to obtain the desired results.

    Concerning

  • How to select and default hightlight the first line in a programmatic Table(ADF Table created based on a SortableModel) ADF.

    Hi all


    We use JDeveloper Studio Edition Version 12.1.3.0.0 and deployed on GlassFish Server Open Source Edition 3.1.2.2 (build 5) and connect to the SQLServer database.


    We created a table ADF programming related to a SortableModel created programmatically to a bean.


    We need to select and highlight the first row in the table just after making it to retrieve data based on the first line.


    We tried the based on the following thread: How to call the bean support just after JSFF / page fragment loads? and a few other posts online, but it does not work very well.


    W has created a hidden text in the bottom of the JSF model as follows:


    < af:table varStatus = "rowStat" Summary = "table" value = "#{pageFlowScope.crudBean.dynamicTable.collectionModel} '"

    Rows = "#{pageFlowScope.crudBean.dynamicTable.collectionModel.RowCount} '"

    contentDelivery = 'immediate' var = 'row' rendered = 'true '.

    Binding = "#{backingBeanScope.crudBackingBean.tasksTable} '"

    selectionListener = "#{backingBeanScope.crudBackingBean.customListener} '"

    "rowSelection ="single"id ="t1"partialTriggers =": pt_gr2 "columnStretching =" column: clmn0 ">

    < af:forEach items = "#{pageFlowScope.crudBean.dynamicTable.columnNames}" var = 'name' varStatus 'vs' = > "

    < af:column sortable = "true" sortProperty rowHeader = "#{name}" = "no style" headerText = "#{pageFlowScope.crudBean.dynamicTable.columnLabel [name]}" "

    inlineStyle = "width: 100px;"  ID = "clmn$ {vs.index}" >

    < af:activeOutputText value = "#{row [name]}" id = "aot1" / >

    < / af:column >

    < / af:forEach >

    < / af:table >

    ....


    < af:outputText id = "hiddenOutputTextId" visible = "false" value = "#{backingBeanScope.crudBackingBean.afterPageLoad} '"

    Binding="#{backingBeanScope.crudBackingBean.hiddenOutputText}"/ >

    And we have added the code to the bean to support below:

    public String getAfterPageLoad() {}

    If (!.) {AdfFacesContext.getCurrentInstance () .isPostback ()}

    selectFirstRowInTasksTable();

    }

    Return afterPageLoad;

    }

    public void selectFirstRowInTasksTable() {}

    try {}

    RKS RowKeySet = new RowKeySetImpl();

    RowKeySet rksEmpty = new RowKeySetImpl();

    Model CollectionModel = tasksTable.getValue ((CollectionModel));

    ROWCOUNT int = model.getRowCount ();

    If (rowcount > 0) {}

    model.setRowIndex (0);

    Key of the object = model.getRowKey ();

    RKS. Add (Key);

    tasksTable.setSelectedRowKeys (rks);

    SelectionEvent selectEvent =

    new SelectionEvent (tasksTable.getSelectedRowKeys (), rks, tasksTable);

    selectEvent.queue ();

    customListener (selectEvent); / / to retrieve data

    AdfFacesContext.getCurrentInstance () .addPartialTarget (tasksTable);

    }

    } catch (Exception e) {}

    }

    }

    I think that () selectEvent.queue; should work even without calling the customerListener, but it is not working in all cases.

    What is the problem in my code?



    Have you tried to bind property of 'selectedRowKeys' to selection configuration / bean there?

    Something like:

    public RowKeySet getSelectedRKS() {
        if (rks == null) {
            // make first record as selected
            // create RowKeySet and assign it to rks variable(where rks is variable defined in bean with some scope higher than request scope)
        }
        return rks;
    }
    

    Dario

  • How do to "BOLD" in the first line of text on a number of sections of text at a time

    CS5 using (but we have CS5

    .5 available) we will create a business directory. Each page has columns of type

    business listings with the company name on top, under this address under this phone, etc.  Each ad is separated

    by a single line. There are thousands of ads, and we need to "BOLD" in the top line of each. How can do us

    without making them individually?

    Each line a paragraph, or each list a paragraph with soft returns (forced line breaks)?

    It's very simple and basic in both cases an operation. It is especially easy if each ad has the same number of lines, so we will focus first with this case.

    Each line should be a separate paragraph. If you have 4 lines, as your example, you might want to mention their name, street, city, and phone. You can and should, all the styles that will be similar in appearance on the same basic model and change only the atrributes that are different, so, for example, if all lines use the same font, many use the same size and weight and only the top line is different and only by being "BOLD" and or larger size start by defining the street, then city and phone based Street and you don't need to define something more than the next Style, I'll get to in a second.

    For topics, set name based as well on the street, but change the font characters. Now all the features of the basic fonts can be changed in one place, the definition of the style Stree.

    Since you have the same number of lines in each list, you can set up a loop "next style". For name, style next street is, the street is the city, for the city it is the phone and is name for the phone. You will also need to toe after the add space in the name, or space on the phone to book spaces registration and you probably also consider to assign everything except phone keep with the next line to prevent a list from breaking across a page or column break. If currently you have blank lines as separators (empty paragraphs), get rid of them. There are change queries find already registered in ID that will do that.

    Once the text is in place and the styles are defined, you can select all, then right click on the style name in the paragraph Styles Panel and choose apply following Style and name. Reformatted your entire list. IT IS CRITICAL in this method that the structure of each list is identical, and if there are no empty lines between the lists.

    If each line is a paragraph, but there is line different counts, you will probably reach with just two styles, one for the headings oand one for everything else, but the beat of following style will not work. If there is something unique that appears in all the headings you can use find/replace to make search and reformat in shape, but I suspect that this will not be the case on in the real world, there will be a manual work involved.

    Where a lisitn is a single paragraph, line break forced (which is better suited to the case of an uneven lines by registration number) you can define a character style nested to be applied by means of a line break forced to make the first line "BOLD", red or any other thing you want.

    At this point, you are probbly, noting that a bit before planningn is a good idea when you do a directory so that your ads have some sort of coherent structure that allows for automation. I have no idea whre that your text is coming from or how it is done in the code. If it can be established as a .csv or a tab-delimited text file, you can use data merge to fill a file based on a model of merge (i.e., how to build directories for my clients who need). You can set styles in the model to each field or paragraph that contains several fields, and merge data will remove empty lines if all row fields are null and there is no punctuation or whitespace on the line.

    A multiple records per page fusion will give you individual blocks of text for each record, and you can, if you wish, thread them using the script text point of Rorohiko.com.

  • How can I get the first line of a paragraph style indent, but others not in withdrawal

    I created a style of paragraph indented on the first line of each paragraph. In most of the books, at the start of the first line of a chapter, this line is not indented while the rest are. Is there a way to set up in InDesign CS3? Is the only way to make this work is to manually go out the tab at the start of each chapter?

    2 paragraph styles.

    1 paragraph style has no dash

    2nd paragraph style has dash

    set "next style" in 1st paragraph for paragraph 2e style style

    the "next style" value in the style of paragraph 2 to "even".

    Existing text.

    Select all of the text

    Right-click on the 1 paragraph style and select apply style then next style.

    New text (typeing)

    Start typing with the selected 1 paragraph style. When you press ENTER to start a new paragraph, the style will switch automatically to the 2nd paragraph style to what manually enable you return.

    HTH

    -mt

  • I can only access buttons of menu on the first line when I use mode full-screen, why?

    Many Web sites I visit have on the first line of the web page in a series of menu options that do not respond when I move the mouse to select options. If I use the mode full screen these buttons work correctly. These buttons work correctly when I use IE or Chrome. I am running Windows 7 and this has happened in the last two weeks.

    Recently, the extension of the Yahoo! toolbar and the extension of Babylon have been reported to cause a problem like that. Disable or uninstall the modules.

       * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    
  • Extract the first line containing "critical" or "E-Stop" of the last avalanche of line

    Hi all

    I'm watching some test systems by analyzing their audit files.

    In this case, the platform generates several line 100 files in a specific folder. The code below is to find the last file and extract the contents of the last line of the last file.

    Unfortunately, when an error occurs, the main software generates not only one entry, but an avalanche of lines [not a specific quantity of them, depending on how much the alarms are resolved] and I'm now ideas of how I could identify and the contents of the first line containing "Criticism" or "E-Stop" to exit from this avalanche [line avalanche started 22.27].

    As an example, the above program is extract the yellow line, while I need information from the blue line.

    Any idea on how I can do this?

    See you soon,.

    You can add this snippet to the top of your existing code.  I changed the indicator table to a table so I could highlight the line.

  • First character left in file by reading the first line in text file

    When you use the function of reading text from a file file, I noticed that the 1st character is left in the file. I read the line correctly.

    When adding a 2nd line this character is in the file.

    Part vi code is attached.

    Any ideas?

    Thank you.

    Elik

    Can you attach a file of real data and tell us what you mean by "first character". The number of characters per line do you have?

    Can you tell us what you see in the modified file and what you expect to see.

    Everything seems good.

    1. Read you the first line and so the file pointer is just after the first line
    2. You set the size of the file at the end (seems unnecessary, because it does nothing). The file pointer is always right after the first line.
    3. You write the first line you read concatenated with a second line. It will be written on the current file pointer, i.e. after the existing line
    4. The first line is in the file twice, as planned.

    Setting the file size to the 'end' on an existing file does not have something useful. If you want to set the position of the file instead?

    Try to set the file position from and new data will be written at the beginning of the file.

  • my printer has stopped printing. The issuance of documents in Quebec and he says the first line is printing, but it is not.

    my printer has stopped printing.  The issuance of documents in Quebec and he says the first line is printing, but it is not.

    Hello

    1. what version of Windows is installed on the computer?

    2. What is the brand and model of the printer?

    I suggest you to follow these steps and check if that helps:

    Method 1:
    Try to run the printer Troubleshooter and check that if it helps, here is the link:
    http://Windows.Microsoft.com/en-us/Windows7/open-the-printer-Troubleshooter

    Method 2:
    Try to run the below fixit and check if this may help:
    http://Windows.Microsoft.com/en-us/Windows7/why-cant-I-print

    It will be useful.

Maybe you are looking for