Empty row using decode

when I use the decode function I always get extra empty rows in my results. Why is this? Is it because I don't use a default value?
I always have to use a where statement to eliminate those empty rows, like in the following statement.
select
decode(table.field1,'field1value','output')
from
table
where
table.field1='field1value'

Let me try to explain using your example:
SQL> create table mytable
  2  as
  3  select 'Weight' field1, '2' field2 from dual union all
  4  select 'Colour', 'red' from dual union all
  5  select 'Size', 'L' from dual
  6  /
Tabel is aangemaakt.So, the table has three rows.
SQL> select decode(Field1,'Weight',Field2)
  2    from mytable
  3  /
DEC
2
3 rijen zijn geselecteerd.Since you don't have a where clause, you don't restrict the number of rows returned. The row appears empty because of the decode function, which says: "if field1 is equal to 'Weight' then display field2 else display nothing".
SQL> select field1
  2       , field2
  3       , decode(Field1,'Weight',Field2)
  4       , decode(Field1,'Weight',Field2, field1)
  5    from mytable
  6  /
FIELD1 FIE DEC DECODE
Weight 2   2   2
Colour red     Colour
Size   L       Size
3 rijen zijn geselecteerd.This shows that the rows are not empty, only the third column is. The fourth column is a similar decode function but with a fourth argument that additionally says "if field1 is not equal to 'Weight' then show me field1 instead of field2"
But I guess you really want one row, the row containing 'Weight', which can be easily achieved by a where clause:
SQL> select field2
  2    from mytable
  3   where field1 = 'Weight'
  4  /
FIE
2
1 rij is geselecteerd.Hope this clarifies.
Regards,
Rob.

Similar Messages

  • Change paragraph style of empty row using GREP

    Hello again ... another GREP query if anyone can assist!
    How can I change a completely empty paragraph line (like those found between verses in a poem, for example) to a different paragraph style so I can control the space better using GREP?

    Fair point ... but if I demonstrate:
    Text line here
    Text line here
    Text line here
    Text line here
    Text line here
    Text line here
    The empty row (4) between the two blocks is in the same paragraph style as the rest of the text. Indeed if lines 3 or 5 were in different styles I could remove the empty row and create a space using before/after spacing. But it is all in the same style. I was wondering if there was a way using GREP to change the para style of an empty row ie 4.

  • How to create editable table with one empty row ?

    I'm looking for solution how to create editable table with one empty row using ADF BC. I have seen this solution in application that was created in JHeadstart and it's very well idea to use it insead of creation form.

    hammm, i do it this:
    drop the VO on the page, select Table->ADF Table....
    so, drop the botton create, from de VO->operations->create (the firts), and right botton (mouse) Edit binding....
    in Data collection select the VO, in Select an action select CreateInsert
    luck

  • Identify empty rows in Excell  using POI

    Hi,
    Could U please tell me how to identify empty rows in Excell sheet using Apachi POI (poi-3.6-20091214.jar).
    Thanks.
    DNA

    Hi,
    I used the following algorithm to identify empty rows (contains value deleted cells). within the main program it is used to by pass the empty rows in an excel sheet.
    If some one has a better solution please do share it with us.
    Program to identify empty rows
    {color:#3366ff}BEGIN
    row -> Instance of the row iterator. Goes through each row.
    cell -> Instance of the cell iterator. Goes through each cell.
    isCellEmpty -> boolean value to assign status.
    rowsToOmit -> An ArrayList which stores the omitted rows.
    WHILE(Has another row){
    get Cell Iterator of row
    WHILE(Cell Iterator Has another cell){
    IF(cell value == "")
    then isCellEmpty is TRUE
    ELSE{
    then isCellEmpty is FALSE
    BREAK
    IF(isCellEmpty value is true)
    Add row to rowsToOmit
    END{color}
    Edited by: nalagiri on Sep 19, 2010 11:37 PM

  • How to delete empty row without validation error in ADF Table(EMP)

    Hi Everyone,
    I am using EMP Table in ADF jspx page to insert the data into database.when i insert a row into table by createInsert operation,it inserting the row.But I need to delete that row immediately with out entering any value.
    But it showing some validation error at empno.Is there any ways to delete the empty row?if not,what are the reasons that we can't delete the row.
    could any one tell me the reasons!!
    Thanks in advance!!
    With Best Regards,
    Amar
    Edited by: 973755 on Dec 11, 2012 6:42 AM

    Amar,
    I am little confused with your logic here.....
    but if you are trying to remove the row by clicking Remove button, you can set the immediate property to true and that remove function will run without executing any entity validation.......
    -R

  • How to insert an empty row on a matrix with multiple loaded lines?

    Hi.
    I want to insert an empty row on my form's matrix. Currently I am using the <b>AddRow </b>method, as it is:
    // C# - it's mandatory to give parameters to the method (=
    oMatrix.AddRow(1,1)
    But, when the matrix already has some rows (at least 1), the method <b>AddRow </b>inserts the new line as a copy of above line, then, I have to manually clear all cells.
    Any idea on this?
    Thanks in advance.

    If you matrix is bound to a dbDatasource you can insert a record in the dbdataspurce instead of using matrix.AddRow... If not only way to do it is by clearing the row after add

  • How can I leave an empty row?

    Hi,
    If I want to use GridBagLayout, how can I leave an empty row? Or empty column? When I create the buttons on a frame, are they created sequentially? so Is that mean I can't put something back to the first row later in the program? Thx.
    Adrian

    I'm just guessing, since I havent done Java for a long time... but if you want an empty row... what pops up in my mind first is like putting in an empty JLabel/Label... for that row... but then if you wanna fill it in... i dunno...

  • SSRS- Hide Empty Rows

    Hi,
    I am having a difficult time deleting empty rows in a table. I used HideDuplicates under properties to hide any of the duplicated data but now it is leaving me an empty row in the table. I tried to use the following codes but none of them seemed to work:
    =Iif(Previous(Fields!Apps.Value) = Fields!Apps.Value, True, False)
    =IIF(fields!Apps.value IS NOTHING, True, False)
    =isnothing(fields!Apps.value)
    =if(Fields!Apps.Value = "",
    true, false). 
    =IIF(IsNothing(Fields!Apps.Value),True,False)
    =iif(Fields!Apps.IsMissing,True,False) 
    Might anyone know another code I might use to delete the empty rows?
    Thank you in advance!

    What you are looking for is probably the Visibility option not the HideDuplicates. You can right click on the row and choose
    Row Visibility. Select "Show or hide based on an expression" and put in the expression that resolves to true to hide the row, and false to show it.
    The HideDuplicates field that you are using is there to hide duplicating text and not entire rows. For example if you have:
    Value1
    5
    Value1
    15
    Value1
    20
    Value2
    10
    You would then get:
    Value1
    5
    15
    20
    Value2
    10
    I hope that helped.
    Regards,
    Andrew.

  • Appending empty rows in internal table

    Hi,
      i am using table control, where there is a condition, some row may left empty. end if i press enter button the empty row is filled by the next available record. My need is to pick the records in the table control to the internal table including the empty rows as it is.

    Hi Karthikeyan,
    By default with user pressinng enter, empty rows will get deleted.
    How are you populating your table control? Is it from standard transaction or your internal table?
    If it is from your internal table, you can add anothe flag field for empty row.
    Whenever row is empty in your internal table, mark flag field as 'X', so in the table control you these entries will not get vanished with pressing of enter.
    This is one idea and you can build on this. You can make this flag column as non editable so that no one can change these.
    hope this helps,
    ags.

  • How to add empty rows in table in smart form

    how to add empty rows in table in smart form?
    plz help me regarding this
    send me ur queries to [email protected]

    You will need to add some extra rows to the internal table that your table is displaying.  Use a program node to append additional rows with a key but no argument.
    Alternaively a template may me more suitable for your requirement than a table.
    Finally, please do not include you e-mail address in your question.  Your question and the answers provided to it are for the benefit of everyone in the Community.
    Regards,
    Nick

  • How to avoid displaying empty rows in a table?

    The situation is as follows:
    I have got a set of questions under a particular category say marketing category.
    The user will be displayed with a table consisting of a set of questions from a particular category with four radio buttons for each question.
    Now once he is done with all the set of questions under a particular category, he will be navigated to the next set of questions under some other category say 'xyz'
    Now instead of creating seperate view objects for each category, we have created a view object which will hold all the set of questions from all the category but will display only the set of questions under a particular category by declaring a variable in the backing bean and setting the question rendering to the value in the variable. the value to the variable will be changed once the user is done with answering all the set of questions under a particular category.
    Now the problem that i am facing is:
    Because of the rendering condition that i have used, it displays only those rows that have the rendering condition set to the variable in the backing and displays all other empty rows overlapped.
    How do i avoid this situation ??

    Seems odd, but you could use COALESCE to achieve this.
    ME_XE?create table all_nullz (col1 number, col2 number, col3 number);
    Table created.
    Elapsed: 00:00:00.20
    ME_XE?
    ME_XE?insert into all_nullz values (1,2,3);
    1 row created.
    Elapsed: 00:00:00.12
    ME_XE?insert into all_nullz values (null, null, null);
    1 row created.
    Elapsed: 00:00:00.06
    ME_XE?
    ME_XE?delete from all_nullz where coalesce(col1,col2,col3) is null;
    1 row deleted.
    Elapsed: 00:00:00.26
    ME_XE?

  • Preventing empty rows in address formats

    Hallo everyone!
    I'd like to know if there is a method to prevent SBO2005A from printing empty rows in the address fields when for instance there is missing county in BP addresses like this:
    I have defined an address format that goes
    Block
    County
    Street
    ZipCode | Freetext(" ") | City
    We use Block as "Name2" and County as "Name3" in master data just in case the customer wants to use additional names for his BPs.
    If I use the "Block" - field and I leave the "County" - field blank it prints an empty row between "Block" and "Street". This is not the behaviour I would like to see. In case "county" is missing I would rather see something like this in a printout:
    Block
    Street
    ZipCode | Freetext(" ") | City
    So, is there a method to force this? or any workaround?

    Hello Patryk,
    PLD does not offer the functionality to control the blank lines in an address field.  I would suggest you use a formatted search in your address field on the marketing document and have it formatted in the document itself before you print.
    Please see sample code for your requirment for the Ship to address.  If you want this to applied to the Bill to address field then you have to slight alter the query by cha
    For Shipto address formatting
    SELECT CASE WHEN T0.Block IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.Block + CHAR(13) + CHAR(10) ELSE '' END +
    CASE WHEN T0.County IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.County + CHAR(13) + CHAR(10) ELSE '' END +
    ISNULL(T0.Street, '') + CHAR(13) + CHAR(10) + ISNULL(T0.ZipCode, '') + '  ' + ISNULL(T0.City, '')
    FROM  [dbo].[CRD1] T0 WHERE T0.AdresType = 'S' AND T0.Address = $[$40.0.0] AND T0.CardCode = $[$4.0.0]
    For Billto address formatting
    SELECT CASE WHEN T0.Block IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.Block + CHAR(13) + CHAR(10) ELSE '' END +
    CASE WHEN T0.County IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.County + CHAR(13) + CHAR(10) ELSE '' END +
    ISNULL(T0.Street, '') + CHAR(13) + CHAR(10) + ISNULL(T0.ZipCode, '') + '  ' + ISNULL(T0.City, '')
    FROM  [dbo].[CRD1] T0 WHERE T0.AdresType = 'B' AND T0.Address = $[$226.0.0] AND T0.CardCode = $[$4.0.0]
    Suda

  • Delete empty rows while having empty xml tag

    I've seen something like same but it doesn't work for me. I have a table which is created using xml rules, some time it contains empty xml tag also converted into row but I don't want these empty rows. After table creation empty rows need to be deleted.
    I've got this script from this forum which delete empty rows
    for(var i=myDocument.textFrames.length-1; i>=0; i--){
      for(var j=myDocument.textFrames[i].tables.length-1; j>=0; j--){
       for(var k=myDocument.textFrames[i].tables[j].rows.length-1; k>=0; k--){
        myContents = 0;
        for(var l=myDocument.textFrames[i].tables[j].rows[k].cells.length-1; l>=0; l--){
         if (myDocument.textFrames[i].tables[j].rows[k].cells[l].contents != "") myContents++;
         if (myContents == 0) myDocument.textFrames[i].tables[j].rows[k].remove();
    but incase of any cell contains empty xml element it goes blank. Could any one help on this.
    Thanks
    Mac

    Gyan,
    Thanks for your help. I have modified the code as below:
    public void removeblankline()
    OAViewObject rvo = (OAViewObject)findViewObject("NCRPaymentExtLineVO1");
    Row row[] = rvo.getAllRowsInRange();
    System.out.println("Remove all blank rows");
    System.out.println("Total Rows"+rvo.getRowCount());
    int jcount = rvo.getRowCount();
    for (int j=0;j< jcount;j++)
    NCRPaymentExtLineVORowImpl rowj = (NCRPaymentExtLineVORowImpl)row[j];
    System.out.println("Check Line Number: "+j);
    System.out.println("Line Type Lookup Code: "+rowj.getLineTypeLookupCode());
    if((rowj.getLineTypeLookupCode()==null)||("".equals(rowj.getLineTypeLookupCode().trim())))
    System.out.println("Removed Line Number: "+j);
    rowj.remove();
    System.out.println("Processed with Line Number: "+j);
    } // end removeblankline
    This is the change I have done:
    int jcount = rvo.getRowCount();

  • Count of non-empty rows of a table

    How to I get the number of non-empty rows of a table ?
    Thanks

    You can loops through the rows and check whether any cell is empty or not? Use a counter variable to increment the same.
    Thanks,
    Bibhu

  • Advanced Table delete empty rows

    Hi
    I added logic to add 10 empty rows and to delete the empty rows when the form is submitted. But somehow it only deletes the rows in current screen of the Advanced Table. if there are 15 rows and I click next to go the last 5 and submit the form it deletes only the 5 empty rows but not the other 10 rows in the previous section.
    where am I doing wrong?
    Thanks
        Row [] row = null;
        ExpAttendeesVORowImpl rowi = null;
        if( expattendeesvoimpl1 != null )
            row = expattendeesvoimpl1.getAllRowsInRange();
            System.out.println("No of items "+row.length);
        for (int i=0;i<row.length;i++)
             pageContext.writeDiagnostics(this, "in loop ", 2);
             rowi = (ExpAttendeesVORowImpl)row;
    pageContext.writeDiagnostics(this, " in loop row "+ rowi.getName(), 2);
    if((rowi.getName() == null))
    pageContext.writeDiagnostics(this, "deleting row"+ rowi.getName(), 2) ;
    rowi.remove();
    Thanks

    you could instead try using:
    expattendeesvoimpl1.getFilteredRows("Name", null);

Maybe you are looking for