Adding decimal to an integer

I'm reading 3 digit integers back from a controller in the form of XXX. I need to format them to the form XX.X
Example
245 should read 24.5, or 345 should read 34.5.
Besides the easiest method of just dividing bt 10 is there a labview function that will place the decimal in my integer number where I need it to be?

No, division is just fine.Well, you could multiply with 0.1 instead
If it is just a string: insert a dot char after the 2nd char (as most "controllers" managed by VISA functions deliver strings...).
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome

Similar Messages

  • Visual Composer 7.0 - Change the Y-axis from decimal scale to integer

    Hi Experts,
    I'm new in Visual Composer 7.0, my report is work fine, but when I want to show the data in bar-chart, the values on y-axis are 0.0, 0.4.0.8,1.2,1.6.2.0 but i want like 1,2,3,4.
    Normally, this happen when values on y-axis less than 5, if more than 5, it will turn to 1,2,3,4. (which i expected)
    Inside my function module, I set all the data as integer already..
    I read through some suggestions in the forum, they suggest using 'Fixed range' and set the interval size, but need to include min & max value. But, inside my program, min value & max value has to be automatically adjusted, ie i can not set the values for those.
    Please suggest solution for me, need it urgently..
    Thanks a lot!
    Best regards,
    Derrick

    Hi All,
    I'm sorry but this seems to me impossible to do.
    In general - not necessarily for this case - there is the option to create your own Flash Components and integrate them into VC, so you could overcome such limitations.
    Using Flash Components in Visual Composer Models - SAP Documentation
    Flash Components for Visual Composer 7.0 - Flexibility is the name of the game
    Thanks,
    Udi

  • Adding Decimal Precision

    I need to compare values from two seperate databases, one stores values in pence the other in pounds, so I need to times the pence by 100 to get the same value in pounds. However I also need decimal two precision, ie. xxx.00
    Can someone tell me how to do this in a simple select query? I had a brief look at numeric functions but nothing stood out

    No need to do anything special. Just:
    select ....
    from t1,t2
    where t1.pence/100=t2.pound;
    Oracle doesn't round nor trunc by default:
    SQL> select 30033/100 from dual;
    >>>
    30033/100
    300.33
    SQL>

  • Adding Decimal Place

    Dear Guru
    I want to add 5 digits after decimal in my pricing condition types.Pls suggest how to make this settings
    Thanx
    MK

    Dear MK,
    The transaction OY04 is the correct to define decimal places based on currency. However, before you
    made the changes, please kindly make sure you don't have existing or not completing purchasing document
    in your system as this will affect the document that may create inconsistency later.
    BR,
    Ian

  • New question....adding decimal places...

    Ok my assignment is thus:The Lone Oak High School Marching Band is raising funds by selling fruit. In order to simplify processing of orders, only three types of packages of fruit are being sold. They are
    Box of Apples at a cost of $14.00
    Box of Peaches at a cost of $16.00
    Box of Oranges at a cost of $18.00
    There is a 10.00% tax on the total order amount. Write a Java program that reads the number of each type package on an order and computes the cost for the packages of each type ordered. Total the order, calculate the tax on the order, and the total including the tax. Print all items read and all items calculated with appropriate labels.
    Example:
    Boxes of Apples: 2
    Boxes of Peaches: 3
    Boxes of Oranges: 4
    Total cost of the fruit: 148.00
    Tax: 14.80
    Total Amount Due: 162.80
    Now ive got the program to work exactly as it should but for neatness i want it to have 2 decimal places. When it runs, ill use the above as an example, it cuts off the second decimal. Is there a nice way to add the the second decimal place?
    Edited by: chaoticglee on Jan 30, 2008 3:40 PM

    Try this as an example:
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class ex
        final static double HOTDOG_COST = 10.00;
        final static double TAX = 0.05;
        public static void main(String[] args)
            DecimalFormat money = new DecimalFormat("$0.00");
            Scanner in = new Scanner(System.in);
            System.out.print("How many hotdogs do you want? ");
            double subTotal = in.nextInt() * HOTDOG_COST;
            double taxCost = subTotal * TAX;
            double total = subTotal + taxCost;
            System.out.println("Cost of food: " + money.format(subTotal));
            System.out.println("Tax: " + money.format(taxCost));
            System.out.println("Total: " + money.format(total));
    }

  • Adding Digits of an integer

    If i had an integer called total, and it was 12
    How would I add the two digits together, to receive an output of 3.

    I'm working on the same sort of programming exercise. I already figured out the caculations part but was having some trouble with some extra stuff and was wondering if anyone was around to help me out a bit.
    for my exercise I have to make it so the program would terminate if the number entered was 0... (I need help with this one)
    and
    if the user enters a number less than 0, they should be told this is not allowed and asked to re-enter.
    all that syntax screws me up.
    thank you in advance

  • Logic to make decimal to integer in sap program?

    Hi,
    I have a question on make the decimal number to integer .
    For example:
    I need to make the number 4.0 to become 4 .
    How can I make that?
    Please help.

    Just do the MOVE.
    DATA: d_out TYPE i.
    PARAMETERS: p_in TYPE p DECIMALS 2.
    MOVE: p_in TO d_out.
    WRITE:/ d_out.
    It will automatically rounded the result.  40.5 ->41
    Jeffrey

  • Converting Decimal to Interger value in a Column

    Hi Folks,
    We have a requirement with column name as Customers having two calculated column values with total and % of Customers in pivot table view.
                         Total Number of Customers         % of Customers
    Customers:             500.00                                   34.44
    So my question is, how to remove decimal and impose integer value on Total Number of Customers at the same time retaining decimal for % of Customers.
    Regards,
    Vj

    The final result of our report is based on the union of two reports and the resultant report has a coulmn which two values one of total no. of cust and other a calculated column value with Cust %.
    Total Number of Customers         % of Customers
    Customers:             500.00                                   34.44
    So my question is, how to remove decimal and impose integer value on Total Number of Customers at the same time retaining decimal for % of Customers.
    Regards,
    Vj

  • How to downsample (with averaging) by a non-integer factor?

    I am collecting data from a photomultiplier at 10MHz (from NI-PXI6115), to
    produce an image in which
    each pixel will be the average of several samples. That is trivial if the
    number of samples per pixel is an
    integer. But I need to be able to have the pixels created from an arbitrary
    DBL, like 3.5845 samples per
    pixel. (This is to satisfy the constraints of fast mirrors scanning a laser
    to
    produce the light collected by
    the PMT)
    I can't seem to find any VI that does this. How can I do this, and do it
    quickly (images are coming in from
    this 10MHz stream continuously, at about 10 FPS, and should be displayed
    continuously). I did find a vi to
    "align and resample" the data, but that does not seem to be able to take a
    running average. There is also
    the "decimate" command, which only decimates by an integer value.
    I am collecting data from a photomultiplier at 10MHz (from NI-PXI-6115), to produce an image in which each pixel will be the average of several samples. That is trivial if the number of samples per pixel is an integer. But I need to be able to have the pixels created from an arbitrary
    DBL, like 3.5845 samples per pixel. (This is to satisfy the constraints of fast mirrors scanning a laser to produce the light collected by the PMT)
    I can't seem to find any VI that does this. How can I do this, and do it quickly (images are coming in from this 10MHz stream continuously, at about 10 FPS, and should be displayed continuously). I did find a vi to "align and resample" the data, but that does not seem to be able to take a running average. There is also the "decimate" command, which only decimates and averages an integer number of array elements (samples). All that I and an NI engineer came up with so far is to first upsample with interpolation by a large factor, then do the decimation with an integer that is my desired DBL multiplied by the upsampling factor. Any more efficient ways do approximate this? Which specific VIs to use?
    Thanks,
    Steve Potter

    Have you tried the "Resample (constant to constant)" VI in the Signal Processing/Signal Operation palette?  This uses a filter to allow resampling of the signal at an arbitrary dt.  If you need a variable dt (i.e. your sampling rate changes with time), you could try fitting some function (say a cubic or bezier or spline) to the input data and then interpolating values at your desired locations.

  • How do I Format Decimal Places to 0 or 2 Decimal Places

    Hi All;
    Below are the exp in SSRS 2008
    I need to
    To covert negative values into brackets use the below code code
    and to convert decimal value to decimal and non decimal value to integer use the below custom code
    for e.g 1.5 is displayed as 1.5
    2 is diaplyed as 2 and not 2.0
    Any help much appreciated
    Thanks
    =IIf( Fields!new_outputs.Value = "Jobs Created" or
    Fields!new_outputs.Value = "Jobs Safeguarded",
    (Lookup(Fields!new_mainprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_mainprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_fte.Value, "JobOutcome"))
    (Sum(LookupSet(Fields!new_mainprogrammeid.Value & "," &
    Fields!new_subprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_mainprogrammeid.Value & "," &
    Fields!new_subprogrammeid.Value & "," &
    Fields!new_outputs.Value & "," &
    Fields!new_claimmonthid.Value,
    Fields!new_programmeoutputid.Value, "ProgrammeOutput").length()))
    Sum(Fields!new_profilenumberValue.Value)
    Pradnya07

    Hi 
    Below are the custome codes in SSRS 2008 
    To covert negative values into brackets use the below code code 
    #,0;(#,0)
    and to convert decimal value to decimal and non decimal value to integer use the below custom code
    for e.g 1.5 is displayed as 1.5
    2 is diaplyed as 2 and not 2.0
    "#,##0.##" 
    But if i want to join both this custom code in one cell how do i do it?
    Any help much appreciated
    Thanks
    Pradnya07

  • KF rounding issue

    Hi,
    I have a query based on a cube which deals with sales data. In this query a lot of calculations are done based on a small number of base key figures.
    As a simple example, turnover (500) devided by quantity (1000) should lead to a price of 0.5.
    A week ago I had to add some more calculations and since then all values get rounded. It looks as if the result is no longer a decimal but an integer instead.
    The above example now gives me 1 instead of 0.5
    Nothing else was changed, just adding some further calculations. Also the base data has not changed. It's a development system where the last data import was in august, 2009 so the data in the cube is correct.
    Also if I adjust the formula to: turnover/quantity*1000 the result is 500 (according to the example of the beginning). So for some reason the calculation is done with correct values but the presentation has changed.
    I have no clue how to solve this...
    Please advice.

    Hi,
    thanks for the hint but this doesn't help either
    Maybe it wasn't clear enough in my first post:
    It's not one formula, it's any in this query. Except for the new KFs all of the values rounded now were presented as decimals before.
    Very strange...
    I had this issue once before and could not solve it. The "workaround" was to create a new query and built it again from scratch. But also this didn't help this time.
    Regards

  • Error: while Selecting External table

    Hi everybody,
    When i Select an external table i am getting this error. The file is like this:
    229|1|506460|SIGROUP |4890|100|0|0|10:31:01|2007/12/17|M009|20191395001|L|B|12|CLIENT|INE547A01012|10:31:00|
    229|1|506460|SIGROUP |4900|900|0|0|10:31:01|2007/12/17|M009|20191395001|L|B|13|CLIENT|INE547A01012|10:31:00|
    229|1|500407|SWARAJENG |21400|300|0|0|10:33:28|2007/12/17|OWN|20191397001|L|B|154|OWN|INE277A01016|10:33:28|
    I had created the Table like this:
    SQL> CREATE TABLE TEMP_SAUDA
    2 (S_A VARCHAR2(20),
    3 S_TYPE VARCHAR2(20),
    4 S_CO VARCHAR2(20),
    5 S_CONAME VARCHAR2(40),
    6 S_RATE NUMBER,
    7 S_QTY NUMBER,
    8 S_G NUMBER,
    9 S_H NUMBER,
    10 S_TIME TIMESTAMP WITH TIME ZONE,
    11 S_DATE DATE,
    12 S_PCODE VARCHAR2(20),
    13 S_SETNO VARCHAR2(20),
    14 S_M VARCHAR2(20),
    15 S_N VARCHAR2(20),
    16 S_O VARCHAR2(20),
    17 S_CLIENTOWN VARCHAR2(10),
    18 S_ISIN VARCHAR2(12),
    19 S_ORDER_TIME TIMESTAMP WITH TIME ZONE
    20 )
    21 ORGANIZATION EXTERNAL
    22 (TYPE oracle_loader
    23 DEFAULT DIRECTORY BSE17122007
    24 ACCESS PARAMETERS
    25 (RECORDS DELIMITED BY NEWLINE
    26 FIELDS
    27 (
    28 S_A CHAR(20),
    29 S_TYPE CHAR(20),
    30 S_CO CHAR(20),
    31 S_CONAME CHAR(20),
    32 S_RATE CHAR(20),
    33 S_QTY CHAR(20),
    34 S_G CHAR(20),
    35 S_H CHAR(20),
    36 S_TIME CHAR(35) date_format TIMESTAMP WITH TIMEZONE mask "DD-MON-RR HH.MI.SSXFF AM TZH:TZM
    37 S_DATE CHAR(22) date_format DATE mask "mm/dd/yyyy hh:mi:ss ",
    38 S_PCODE CHAR(20),
    39 S_SETNO CHAR(20),
    40 S_M CHAR(20),
    41 S_N CHAR(20),
    42 S_O CHAR(20),
    43 S_CLIENTOWN CHAR(20),
    44 S_ISIN CHAR(20),
    45 S_ORDER_TIME date_format TIMESTAMP WITH TIMEZONE mask "DD-MON-RR HH.MI.SSXFF AM TZH:TZM"
    46 )
    47 )
    48 location (BSE17122007:'BR171207.DAT')
    49 )
    50 ;
    Table created.
    SQL> SELECT * FROM TEMP_SAUDA;
    SELECT * FROM TEMP_SAUDA
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "date_format": expecting one of: "binary_double,
    binary_float, comma, char, date, defaultif, decimal, double, float, integer, (,
    nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned,
    varrawc, varchar, varraw, varcharc, zoned"
    KUP-01007: at line 21 column 14
    ORA-06512: at "SYS.ORACLE_LOADER", line 19
    Is there any mistake in this table creation.
    what i have to declare to the time format if the format in the file id hh:mm:ss
    Thank u...!
    Ravi

    The output you posted is completely wrong, I could not even create the table without errors.
    Try with this.
    CREATE TABLE TEMP_SAUDA
    (S_A VARCHAR2(20),
    S_TYPE VARCHAR2(20),
    S_CO VARCHAR2(20),
    S_CONAME VARCHAR2(40),
    S_RATE NUMBER,
    S_QTY NUMBER,
    S_G NUMBER,
    S_H NUMBER,
    S_TIME TIMESTAMP WITH TIME ZONE,
    S_DATE DATE,
    S_PCODE VARCHAR2(20),
    S_SETNO VARCHAR2(20),
    S_M VARCHAR2(20),
    S_N VARCHAR2(20),
    S_O VARCHAR2(20),
    S_CLIENTOWN VARCHAR2(10),
    S_ISIN VARCHAR2(12),
    S_ORDER_TIME TIMESTAMP WITH TIME ZONE
    ORGANIZATION EXTERNAL
    (TYPE oracle_loader
    DEFAULT DIRECTORY BSE17122007
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY NEWLINE
    FIELDS terminated by "|"
    S_A CHAR(20),
    S_TYPE CHAR(20),
    S_CO CHAR(20),
    S_CONAME CHAR(20),
    S_RATE CHAR(20),
    S_QTY CHAR(20),
    S_G CHAR(20),
    S_H CHAR(20),
    S_TIME CHAR(8) date_format TIMESTAMP WITH TIMEZONE mask "HH.MI.SSXFF AM TZH:TZM",
    S_DATE CHAR(10) date_format DATE mask "yyyy/mm/dd",
    S_PCODE CHAR(20),
    S_SETNO CHAR(20),
    S_M CHAR(20),
    S_N CHAR(20),
    S_O CHAR(20),
    S_CLIENTOWN CHAR(20),
    S_ISIN CHAR(20),
    S_ORDER_TIME char(8) date_format TIMESTAMP WITH TIMEZONE mask "HH.MI.SSXFF AM TZH:TZM"
    location (BSE17122007:'BR171207.DAT')
    ;With this you get:
    SQL> col s_time format a40
    SQL> col s_date format a40
    SQL> col s_order_time format a40
    SQL> r
      1* select s_time,s_date,s_order_time from temp_sauda
    S_TIME                                   S_DATE                                   S_ORDER_TIME
    01-JAN-08 10.31.01.000000 AM +00:00      17.DEC.2007 00:00:00                     01-JAN-08 10.31.00.000000 AM +00:00
    01-JAN-08 10.31.01.000000 AM +00:00      17.DEC.2007 00:00:00                     01-JAN-08 10.31.00.000000 AM +00:00
    01-JAN-08 10.33.28.000000 AM +00:00      17.DEC.2007 00:00:00                     01-JAN-08 10.33.28.000000 AM +00:00Be aware that your file does not contain date information for the time fields, so as you see above it is defaulted to 01-JAN-08 for the S_TIME and S_ORDER_TIME column.

  • How Can I use Mysql's  PROCEDURE by Java Can you give me sample???

    �������^���������������H�iBEGIN�`END�u���b�N�j�@��TOP
    ORACLE�@MSSQL�@SSA�@MySQL�@
    ���{�I���������������������������B
    MySQL�������A ORACLE��MSSSQL��������������BEGIN�`END�u���b�N�����s�������������������������B
    ���������s�������������K���X�g�A�h�v���O�����������R���p�C�������K�v�����������B
    �i�����F�������������������A���w�E�������������K�r�����������j
    --drop PROCEDURE sp_hoge;
    --�f���~�^�����X��������
    delimiter //
    CREATE PROCEDURE sp_hoge()
    DETERMINISTIC
    BEGIN
    /* �������� */
    DECLARE mystr VARCHAR(20);
    DECLARE mycnt INTEGER(2);
    /* �l������ */
    SET mycnt = 0;
    SET mystr = '����';
    /* IF�� */
    IF mycnt = 0 THEN
    SET mystr = '�����Q';
    select mystr;
    ELSE
    select '�����R';
    END IF;
    /* CASE�� */
    CASE extract(month from now())
    WHEN 1 THEN SET mystr = '1��';
    WHEN 2 THEN SET mystr = '2��';
    WHEN 3 THEN SET mystr = '3��';
    WHEN 4 THEN SET mystr = '4��';
    ELSE SET mystr = '1�`4�����O';
    END CASE;
    select mystr;
    /* WHILE-LOOP */
    WHILE mycnt <= 5 DO
    SET mycnt = mycnt + 1;
    select mycnt;
    END WHILE;
    /* BEGIN-END�u���b�N������SELECT�������s */
    /* PROCEDURE�������\�iFUNCTION���������������j */
    select * from help_topic;
    END//
    delimiter ;
    --�X�g�A�h�v���V�[�W�����s
    call sp_hoge();
    �X�g�A�h�v���V�[�W�����T���v���i�J�[�\�����g�p������LOOP�����j�@��TOP
    ORACLE�@MSSQL�@SSA�@MySQL�@
    �J�[�\�����g�p����LOOP�������T���v�������B
    �����p�����[�^���w�����������������Y�������������������A���E���w�X�^�b�t�x�������������A�����������w�c���X�^�b�t�F�x���\���������B
    --drop PROCEDURE sp_hoge;
    --�f���~�^�����X��������
    delimiter //
    CREATE PROCEDURE sp_hoge(inum INTEGER(3))
    DETERMINISTIC
    BEGIN
    /* �������� */
    /* �J�[�\���g�p�����f�[�^�L�����f���g�p */
    DECLARE done INT DEFAULT 0;
    /* �������O������ */
    DECLARE v_mystr VARCHAR(20);
    /* �J�[�\���g�p�� */
    DECLARE v_empnm VARCHAR(40);
    DECLARE v_job VARCHAR(20);
    /* �J�[�\������ �� �����������������`���� */
    DECLARE cur1 CURSOR FOR
    select empnm,job from kemp where deptno = inum;
    /* �f�[�^��������LOOP�E�o�p���������� */
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
    /* �J�[�\���I�[�v�� */
    OPEN cur1;
    /* LOOP */
    LOOPPROC:REPEAT
    FETCH cur1 INTO v_empnm,v_job;
    IF NOT done THEN
    IF v_job = '�X�^�b�t' THEN
    SET v_mystr = '�c���X�^�b�t�F';
    ELSE
    SET v_mystr = '';
    END IF;
    select CONCAT(v_mystr,v_empnm);
    /* ������������LOOP���E�o����������LEAVE�� */
    /* LEAVE LOOPPROC; */
    END IF;
    UNTIL done END REPEAT;
    /* �J�[�\���N���[�Y */
    CLOSE cur1;
    END//
    --�f���~�^���Z�~�R�����i�f�t�H���g�j������������
    delimiter ;
    --�X�g�A�h�v���V�[�W�����s
    call sp_hoge(1);
    12.2. Control Flow Functions
    CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END
    CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
    The first version returns the result where value=compare_value. The second version returns the result for the first condition that is true. If there was no matching result value, the result after ELSE is returned, or NULL if there is no ELSE part.
    mysql> SELECT CASE 1 WHEN 1 THEN 'one'
    -> WHEN 2 THEN 'two' ELSE 'more' END;
    -> 'one'
    mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;
    -> 'true'
    mysql> SELECT CASE BINARY 'B'
    -> WHEN 'a' THEN 1 WHEN 'b' THEN 2 END;
    -> NULL
    The default return type of a CASE expression is the compatible aggregated type of all return values, but also depends on the context in which it is used. If used in a string context, the result is returned as a string. If used in a numeric context, then the result is returned as a decimal, real, or integer value.
    Note: The syntax of the CASE expression shown here differs slightly from that of the SQL CASE statement described in Section 17.2.10.2, �gCASE Statement�h, for use inside stored routines. The CASE statement cannot have an ELSE NULL clause, and it is terminated with END CASE instead of END.
    IF(expr1,expr2,expr3)
    If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3. IF() returns a numeric or string value, depending on the context in which it is used.
    mysql> SELECT IF(1>2,2,3);
    -> 3
    mysql> SELECT IF(1<2,'yes','no');
    -> 'yes'
    mysql> SELECT IF(STRCMP('test','test1'),'no','yes');
    -> 'no'
    If only one of expr2 or expr3 is explicitly NULL, the result type of the IF() function is the type of the non-NULL expression.
    expr1 is evaluated as an integer value, which means that if you are testing floating-point or string values, you should do so using a comparison operation.
    mysql> SELECT IF(0.1,1,0);
    -> 0
    mysql> SELECT IF(0.1<>0,1,0);
    -> 1
    In the first case shown, IF(0.1) returns 0 because 0.1 is converted to an integer value, resulting in a test of IF(0). This may not be what you expect. In the second case, the comparison tests the original floating-point value to see whether it is non-zero. The result of the comparison is used as an integer.
    The default return type of IF() (which may matter when it is stored into a temporary table) is calculated as follows:
    Expression Return Value
    expr2 or expr3 returns a string string
    expr2 or expr3 returns a floating-point value floating-point
    expr2 or expr3 returns an integer integer
    If expr2 and expr3 are both strings, the result is case sensitive if either string is case sensitive.
    Note: There is also an IF statement, which differs from the IF() function described here. See Section 17.2.10.1, �gIF Statement�h.
    IFNULL(expr1,expr2)
    If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2. IFNULL() returns a numeric or string value, depending on the context in which it is used.
    mysql> SELECT IFNULL(1,0);
    -> 1
    mysql> SELECT IFNULL(NULL,10);
    -> 10
    mysql> SELECT IFNULL(1/0,10);
    -> 10
    mysql> SELECT IFNULL(1/0,'yes');
    -> 'yes'
    The default result value of IFNULL(expr1,expr2) is the more �ggeneral�h of the two expressions, in the order STRING, REAL, or INTEGER. Consider the case of a table based on expressions or where MySQL must internally store a value returned by IFNULL() in a temporary table:
    mysql> CREATE TABLE tmp SELECT IFNULL(1,'test') AS test;
    mysql> DESCRIBE tmp;
    -------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    -------------------------------------------+
    | test | char(4) | | | | |
    -------------------------------------------+
    In this example, the type of the test column is CHAR(4).
    NULLIF(expr1,expr2)
    Returns NULL if expr1 = expr2 is true, otherwise returns expr1. This is the same as CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.
    mysql> SELECT NULLIF(1,1);
    -> NULL
    mysql> SELECT NULLIF(1,2);
    -> 1
    Note that MySQL evaluates expr1 twice if the arguments are not equal.
    Previous / Next / Up / Table of Contents
    User Comments
    Posted by I W on July 12 2005 5:52pm [Delete] [Edit]
    Don't use IFNULL for comparisons (especially not for Joins)
    (example:
    select aa from a left join b ON IFNULL(a.col,1)=IFNULL(b.col,1)
    It's terrible slow (ran for days on two tables with approx 250k rows).
    Use <=> (NULL-safe comparison) instead. It did the same job in less than 15 minutes!!
    Posted by [name withheld] on November 10 2005 12:12am [Delete] [Edit]
    IFNULL is like oracle's NVL function (these should help people searching for NVL() ..)
    Posted by Philip Mak on May 26 2006 7:14am [Delete] [Edit]
    When using CASE, remember that NULL != NULL, so if you write "WHEN NULL", it will never match. (I guess you have to use IFNULL() instead...)
    Posted by Marc Grue on June 24 2006 2:03pm [Delete] [Edit]
    You can ORDER BY a dynamic column_name parameter using a CASE expression in the ORDER BY clause of the SELECT statement:
    CREATE PROCEDURE `orderby`(IN _orderby VARCHAR(50))
    BEGIN
    SELECT id, first_name, last_name, birthday
    FROM table
    ORDER BY
    -- numeric columns
    CASE _orderby WHEN 'id' THEN id END ASC,
    CASE orderby WHEN 'desc id' THEN id END DESC,
    -- string columns
    CASE orderby WHEN 'firstname' THEN first_name WHEN 'last_name' THEN last_name END ASC,
    CASE orderby WHEN 'descfirst_name' THEN first_name WHEN 'desc_last_name' THEN last_name END DESC,
    -- datetime columns
    CASE _orderby WHEN 'birthday' THEN birthday END ASC,
    CASE orderby WHEN 'desc birthday' THEN birthday END DESC;
    END
    Since the CASE expression returns the "compatible aggregated type of all return values", you need to isolate each column type in a separate CASE expression to get the desired result.
    If you mixed the columns like
    CASE _orderby
    WHEN 'id' THEN id
    WHEN 'first_name' THEN first_name
    ...etc...
    END ASC
    .. both the id and first_name would be returned as a string value, and ids would be sorted as a string to '1,12,2,24,5' and not as integers to '1,2,5,12,24'.
    Note that you don't need a "ELSE null" in the CASE expressions, since the CASE expression automatically returns null if there's no match. In that case, you get a "null ASC" in your ORDER BY clause which doesn't affect the sort order. If for instance orderby is 'descfirst_name', the ORDER BY clause evaluates to:
    ORDER BY null ASC, null DESC, null ASC, first_name DESC, null ASC, null DESC
    Effectively the same as "ORDER BY first_name DESC". You could even add a new set of CASE expressions for a second order column (or more..) if you like.
    Add your own comment.

    What is that post supposed to be?

  • Error when i fetch the external table in oracle 9i ?

    External table is created.
    But, when i select the external table , it is thrwing the following error.
    I have given READ and WRITE permission to the oracle directory.
    And, i having the flat file with comma delimited data.
    SQL> create table mohan_ext (
    2 EMPNO NUMBER(5) ,
    3 JOB VARCHAR2(15),
    4 SALARY NUMBER(8,2),
    5 MGR NUMBER(5) ,
    6 HIREDATE DATE,
    7 DEPTNO NUMBER(5)
    8 )
    9 organization external
    10 (type oracle_loader
    11 default directory ext_dir
    12 access parameters (records delimited by newline
    13 fields terminated by ','
    14 missing field values are null
    15 (
    16 EMPNO NUMBER(5:5) ,
    17 JOB VARCHAR2(15:15),
    18 SALARY NUMBER(8,2:8,2),
    19 MGR NUMBER(5:5) ,
    20 HIREDATE DATE,
    21 DEPTNO NUMBER(5:5)
    22 )
    23 )
    24 LOCATION('flat.txt'));
    Table created.
    SQL> select * from mohan_ext;
    select * from mohan_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "identifier": expecting one of: "comma, char, date, defaultif,
    decimal, double, float, integer, (, nullif, oracle_date, oracle_number, position, raw, recnum, ),
    unsigned, varrawc, varchar, varraw, varcharc, zoned"
    KUP-01008: the bad identifier was: NUMBER
    KUP-01007: at line 5 column 11
    ORA-06512: at "SYS.ORACLE_LOADER", line 14
    ORA-06512: at line 1
    SQL>

    You may need to scrub some of the data prior to using it as an external table. For instance, ensure that you do not have any extra commas lingering around somewhere within the data as this could cause mapping issues with the data. I've used this process hundreds of times, and more often than not there is an extra comma somewhere that is causing the issue.

  • Problem with external tables in 9i

    Okay I have copied the csv file to that directory. I get this error when I run the select statement... basically the fields dont get populated.
    *** SCRIPT START : Session:ADMAP@DEVDB2(1) 13-Nov-2006 16:38:53 ***
    Processing ...
    select * from proc_args
    select * from proc_args
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "identifier": expecting one of: "comma, char, date, defaultif, decimal, double, float, integer, (, nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned, varrawc, varchar, varraw, varcharc, zoned"
    KUP-01008: the bad identifier was: VARCHAR2
    KUP-01007: at line 5 column 26
    ORA-06512: at "SYS.ORACLE_LOADER", line 14
    *** Script stopped due to error ***
    *** SCRIPT END : Session:ADMAP@DEVDB2(1) 13-Nov-2006 16:38:53 ***
    SCRIPTCREATE OR REPLACE DIRECTORY dir AS '/tmp/ext_dir';
    --grant read,write on directory ext_dir to bulk_load;
    CREATE TABLE proc_args (
    argument_name VARCHAR2(50),
    argument_value VARCHAR2(50)
    ORGANIZATION EXTERNAL (
    -- TYPE ORACLE_LOADER
    DEFAULT DIRECTORY dir
    ACCESS PARAMETERS (
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    MISSING FIELD VALUES ARE NULL
    argument_name VARCHAR2(50),
    argument_value VARCHAR2(50)
    LOCATION ('input_arguments.csv')
    --PARALLEL 5
    --REJECT LIMIT UNLIMITED;
    select * from proc_args

    I think the fields specified in the ACCESS PARAMETERS section should be SQL*Loader datatypes, not standard SQL, e.g.
    CREATE TABLE proc_args (
    argument_name VARCHAR2(50),
    argument_value VARCHAR2(50)
    ORGANIZATION EXTERNAL (
    -- TYPE ORACLE_LOADER
    DEFAULT DIRECTORY dir
    ACCESS PARAMETERS (
    RECORDS DELIMITED BY NEWLINE
    FIELDS TERMINATED BY ','
    MISSING FIELD VALUES ARE NULL
    argument_name CHAR,
    argument_value CHAR
    LOCATION ('input_arguments.csv')
    Other valid types are specified here:
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#sthref1004

Maybe you are looking for

  • How to display the context of a Jbutton to a JTextField

    Hi, There is a key pad (1-9) on a GUI where each key is represented by a JButton. There is also a data entry filed, implemented using JTextField. However, when the user enters the ID using the key pad buttons each number should be displayed in the da

  • Windows 8.1 store apps aren't running after definition update of windows defender!!!

    I am currently running windows 8.1 pro with media centre. 15 days back I installed this update "Definition Update for Windows Defender - KB2267602 (Definition 1.189.752.0)" after which my all windows apps(precisely metro apps/windows store apps) stop

  • Exception while starting server P6 (EPPM 8.3.2) on Weblogic Server 11gR1

    I am a single user for learning purpose. I am trying to install EPPM 8.3.2 on my lenovo Window 7, 32 Bit Laptop. - I have installed weblogic server, - Installed databse and - EPPM 8.3.2. Unfortunately I am getting error "Exception while starting serv

  • [PARTIALLY SOLVED] Arch on MacBook4: can't install GRUB

    I've been running Arch on my MacBook4 (4 years old now) for quite some time in dualboot mode and have already set up GRUB sucessfully several times. I therefore feel kinda bad that I have to open a new thread this time, but after wasting the whole mo

  • Custom fields and Standard Fields

    Hi I'am working on upgrade project from SRM 4.0 to SRM 7.O. we have a client requirement that 1. some custom fields  to hide at SC Header default settings like Company Code, Location, Strorage location. i was able to hide at item level via Field cont