Oracle to_number function pramaters

I have problems with TO_NUMBER function second and third parameters. One dependent on the other? How does the nls_params parameter? I don't understand how the result of the query

SELECT TO_NUMBER ('17,000, 23',
"999G999D99,"
' nls_numeric_characters = ",". ')
REFORMATTED_NUMBER
FROM DUAL;

can be 17000.23. Could someone please explain the above conversion process. I looked towards the top of the documentation, but it is not explanatory eneogh.

P.S. The query above is taken from a book of preperation certificate Expert Oracle database SQL.

See
TO_NUMBER problem
Re: number format

Tags: Database

Similar Questions

  • In Oracle lag function

    Hi all

    I want to understand the inner workings of the Lag function in Oracle, which could help to solve my problem.

    I have the table as the structure below.

    P_ID ENTRY_TIMESTAMP SIZE C_ID
    152871 NOVEMBER 15 05.45.00 PM3092
    1529506.00.00 PM 1ST NOVEMBER 151592
    1530606.00.00 PM 1ST NOVEMBER 15192

    Now, when I write a query as below:

    Select the size, CURR_TIMESTAMP TO_TIMESTAMP (TO_CHAR (ENTRY_TIMESTAMP, 'YYYYMMDDHH24MI'), 'YYYYMMDDHH24MI'),

    TO_TIMESTAMP (TO_CHAR (LAG (ENTRY_TIMESTAMP) OVER (PARTITION BY ORDER BY ENTRY_TIMESTAMP ASC C_ID), 'YYYYMMDDHH24MI'), 'YYYYMMDDHH24MI') LAG_TIMESTAMP

    OF Entry_log

    where ENTRY_TIMESTAMP BETWEEN to_date (1 November 15 18.00.00','DD-MON-YY HH24.MI.) SS') AND to_date (1 November 15 18.00.00','DD-MON-YY HH24.MI.) SS')

    Query will lead to give Lag_timestamp as 06.00.00 PM for size = 1 but will be NULL for size = 15.

    Why is that Oracle will never lag_timestamp = 06.00.00 PM for size = 15.

    Could someone please explain this behavior.

    I'm using Oracle 11 g.

    Thank you

    I had a small mistake in the above query. now, I fixed it

  • Oracle Spatial function to find the closest channel line according to lat/long

    Hello

    Here's my scenario. I have a table that contains the geometries of type line (road network) channels. The line geomteries are of type Ohio state South (SRID 41104) plan.
    I have a requirement - given a lat/long, find the string line that aligns with this lat/long or the nearest set of strings of line at 0.02 miles.
    It is a typical example of an attempt to identify an accident on our road network situation. Accidents reported us in lat/long through the GPS system.
    How can I achieve this through any space function?

    Thanks for the help in advance.

    Thank you
    L.

    Hello L,

    SELECT
      r.
    FROM
      roadsegments r
    WHERE SDO_NN(r.geometry,
                 sdo_geometry(2001, 41104, sdo_point_type(lat,lon,NULL), NULL, NULL),
                 'sdo_num_res=2 distance=0.02 unit=mile') = 'TRUE';
    

    This will give you the two segments of road nearest you at 0.02 miles. See [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_operat.htm#i78067] documentation on the operator SDO_NN, especially the bit about the use of the index indicator.

    HTH,
    Stefan

  • Oracle form functions and procedures in the APEX, how?

    I'm working to recreate in the APEX, already existing read only forms in Oracle Forms. Report features interactive APEX among other things, in fact worth as well as to target a different audience than utilizies versions of Oracle Form. Versions of Oracle Forms use a lot of pre and post query triggers, PLSQL functions.

    In Oracle Forms that places, these functions can be found in the "Units of program" section of the form. A feature typical of this kind, based on a particular Mission ID route, collecting names of regular passengers, is shaped with a comma and a space after each of them, in a single string that is returned and displayed the list of passengers of a line.

    I have all of this written code so I can move most of the main request of the Oracle form in an interactive report. These functions and triggers called in the form of the "Units of program" section of the Oracle form rather than stored in the database schema in a package, where they would go inside the APEX? Can I create a 'shortcut' in the APEX and call it from the interactive report "Source Région"? I can create the PLSQL function at the level of the region of the interactive report or page level? Or, my best bet creates a package that is stored in the database, all these functions and/or proecedures I might need the original form of Oracle?

    Some advice would be greatly appreciated.

    RLBickham wrote:
    I don't think I've been pretty clear in the description of the specific thing I want to do, simply, it does not reach the level of forms of conversion of the APEX. It is basically a problem of PLSQL function.

    I have an interactive report which is currently 90 percent of what I want however, each line, which represents a Mission may have several feet. Each arm has two places or ICAO codes attached to it. Based on the number of Mission, I want to loop through the array of leg, collect all the codes of ICAO for this Mission, put them together in 1 variable separated by a coma and add this variable to display the columns in this interactive report as the last column.

    In Oracle Forms, I have a function registered in the database, which is called in the main query. Maybe I ask a question that does not need to be asked, but anyway my question is can I put this function currently in the database somewhere within the interactive report and somehow reference it via Http, or should I just stick with set of functions and procedures in the packages stored in the database and called the conventional way?

    You could switch the function to the database and call it from the report query, but it sounds as if it were superfluous. In the report query using any form of Re: 4. How can I convert rows to columns? is appropriate for your version of the (unspecified) database.

    -----

    When you have a problem, you will get an answer faster, more efficient including information as much information as possible from the outset. This should include:

  • Full version of APEX
  • Complete operating system DB, version, edition, host
  • Architecture of Web server (EPG, SST or APEX listener/host operating system)
  • Browser (s) and version (s) used
  • Theme
  • Model (s)

  • Region/section type (s) (particularly as to distinguish if a 'report' is a standard report, an interactive report, or indeed a 'update report' (i.e. a tabular presentation))

    With APEX, we also had the chance to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproduce things is the best way to solve most of the questions, particularly those relating to the layout and Visual formatting. If you expect a detailed response it is appropriate that you take on an important part of the effort by getting as much as possible with an example of the problem on apex.oracle.com before asking for help on specific issues, then we can see firsthand.

  • No support for oracle sql functions

    Hi all

    Please can someone explain why the B-tree indexes are not capable of supporting SQL queries using the built-in functions of Oracle.

    We have indexes of tree b on account_no column.

    Select * from test_table where account_no = 11005208

    the above query use the index on account_no

    Select * from test_table where superior (account_no) = 11005208

    But this query does not use the index on the account_no, going for the full table scan.

    My question here is account_no is the numeric data type.
    Then, there is no difference between the data in the columns account_no and upper (account_no) column data, so why he does not use index when using sql functions in an sql query?

    Hello

    If you apply the upper function, Oracle implicitly converts its argument to a string, so your query is actually upper (to_char (account_no)).
    There is none HAVE fully functional in the optimizer and you do not expect to know everything and do all the conclusions that a human being can do. Why should Oracle re - write this type of query analysis the data type of the columns and features when it seems more natural programmer write a correct query (without capital letters in this example) or, if necessary, create an index based on a function?

  • Oracle LISTAGG function

    Hi all

    I'm still reviewing the analytical functions and I was wondering if someone can help me with the LISTAGG function. If this has nothing to do with some school or as homework. It's just me discover Oracle.

    So, here is some code to insert data of base. It's just a person table and an array of phone number.
    -- to avoid name conflicts ;-)
    DROP TABLE PERSONNES CASCADE CONSTRAINTS purge;
    DROP TABLE TELEPHONES CASCADE CONSTRAINTS purge;
    
    -- create a person table with an id and a name.
    CREATE TABLE PERSONNES (
        ID_PERSONNE NUMBER(10)
      , NOM         VARCHAR2(100)
      , CONSTRAINT PK_PERSONNES PRIMARY KEY(ID_PERSONNE)
    );
    
    -- table with phone number for persons. 
    CREATE TABLE TELEPHONES (
        ID_TELEPHONE NUMBER(10)
      , ID_PERSONNE  NUMBER(10)
      , NUMERO       VARCHAR2(100)
      , ACTIF        CHAR(1) DEFAULT '0' -- is the number active or not.
      , CONSTRAINT PK_TELEPHONES PRIMARY KEY(ID_TELEPHONE)
      , CONSTRAINT UK_NUMERO     UNIQUE(ID_TELEPHONE, NUMERO)
      , CONSTRAINT C_ACTIF_BOOLEAN CHECK(ACTIF IN ('0', '1'))
      , CONSTRAINT FK_PERSONNE   FOREIGN KEY(ID_PERSONNE) REFERENCES PERSONNES
    );
    
    -- insert some data.
    BEGIN
      -- create a person with a random name.
      FOR i in 1 .. 10 LOOP
        INSERT INTO PERSONNES(ID_PERSONNE, NOM)
          VALUES (i, InitCap(DBMS_RANDOM.STRING('l', 5)));
        
         -- for each newly inserted person, insert 5 different phone numbers.
        FOR j in 1 .. 5 LOOP
          INSERT INTO TELEPHONES(ID_TELEPHONE, ID_PERSONNE, NUMERO, ACTIF) 
            VALUES(((i-1)*10) + j, i,  
                '+32.' ||
                  TRUNC(DBMS_RANDOM.VALUE(1, 9)) || '.' ||
                  TO_CHAR(DBMS_RANDOM.VALUE(1, 999), 'fm099') || '.' ||
                  TO_CHAR(DBMS_RANDOM.VALUE(1, 99), 'fm09') || '.' ||
                  TO_CHAR(DBMS_RANDOM.VALUE(1, 99), 'fm09'), 
                CASE MOD(j, 2) WHEN 0 THEN '0' ELSE '1' END
            );
        END LOOP;
      END LOOP;
      
      -- now insert two different person without any phone number.
      INSERT INTO PERSONNES(ID_PERSONNE, NOM)
        VALUES (100, InitCap(DBMS_RANDOM.STRING('l', 5)));
    
      INSERT INTO PERSONNES(ID_PERSONNE, NOM)
        VALUES (101, InitCap(DBMS_RANDOM.STRING('l', 5)));
    
    END;
    The following query returns all the person with their different phone numbers into a single line.
    SELECT NOM, LISTAGG(NUMERO, ', ') WITHIN GROUP (ORDER BY NULL)
      FROM PERSONNES A
     LEFT JOIN TELEPHONES B ON A.ID_PERSONNE = B.ID_PERSONNE
     GROUP BY NOM 
     ORDER BY 2 NULLS LAST;
    But what I would like is to have numbers grouped by the flag of the ASSET.
    Name1   Actif=0  +32... , +3200000000
    Name1   Actif=1  +32... , +...........
    Name2   Actif=0  +32... , +3200000000
    Name2   Actif=1  +32... , +...........
    I thought that maybe using the PARTITION CLAUSE but I couldn't understand it. So maybe one of you has a better idea? I want to do in a single query (without using the inline views or with clause). But all the tips are welcome. I just discover Oracle ;-)

    Thank you

    Hello

    user13117585 wrote:
    ... But what I would like is to have numbers grouped by the flag of the ASSET.

    This is the solution! You want to have results grouped by asset, so add assets to the GROUP BY clause:

    SELECT NOM
    ,      ACTIF          -- New
    ,      LISTAGG(NUMERO, ', ') WITHIN GROUP (ORDER BY NULL)
      FROM PERSONNES A
     LEFT JOIN TELEPHONES B ON A.ID_PERSONNE = B.ID_PERSONNE
     GROUP BY NOM
     ,        ACTIF     -- New
     ORDER BY 3 NULLS LAST     -- Changed
    ;
    

    If you want to display ACTIVE, you will need to add it to the SELECT clause.
    Don't forget to change the ORDER BY clause, which changes what is in the column #2, as stated above (assuming that it is how you want the output sorted). However, a better way is to give this column alias, which can be used in the ORDER BY clause:

    SELECT NOM
    ,      ACTIF
    ,      LISTAGG(NUMERO, ', ') WITHIN GROUP (ORDER BY NULL)     AS NUMEROS     -- Alias defined
      FROM PERSONNES A
     LEFT JOIN TELEPHONES B ON A.ID_PERSONNE = B.ID_PERSONNE
     GROUP BY NOM
     ,        ACTIF
     ORDER BY NUMEROS NULLS LAST     -- Alias used
    ;
    
  • Oracle analytic function setting

    Hi all
    Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - 64bi
    PL/SQL version 10.2.0.3.0 - Production
    CORE Production 10.2.0.3.0
    AMT for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - production
    NLSRTL Version 10.2.0.3.0 - Production
    I have a query that has analytic function uses space on temporary tablespace resulting in temp of direct path read and track direct writing temp waiting events taking too much time. Is it possible to set this query?

    Thanks in advance.

    user9074365 wrote:
    Hi all
    Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - 64bi
    PL/SQL version 10.2.0.3.0 - Production
    CORE Production 10.2.0.3.0
    AMT for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - production
    NLSRTL Version 10.2.0.3.0 - Production
    I have a query that has analytic function uses space on temporary tablespace resulting in temp of direct path read and track direct writing temp waiting events taking too much time. Is it possible to set this query?

    With your version of Oracle and high-volumes of data through the analytical function, it is likely that this blog note applies. You may need a patch upgrade or special. http://jonathanlewis.WordPress.com/2009/09/07/analytic-agony/

    Concerning
    Jonathan Lewis

  • Oracle Apps functional in finance career

    Hi all

    I would be grateful to you if someone can guide me to pursue a career in finance functional Oracle applications. For your information here is my path passed – I did BSc (Computer Science), MBA & MSc and currently I work as an Accounts Assistant in a company based in Scotland.

    I'm going on vacation in Hyderabad, India. I need to know what will be the best way to learn the course above, in an Institute or under a personal instructor. Please suggest

    Any suggestions will be appreciated kindly.

    Thank you.

    Imran

    I'm going on vacation in Hyderabad, India. I need to know what will be the best way to learn the course above, in an Institute or under a personal instructor. Please suggest

    Please visit the following link:

    Oracle authorized training in India
    http://www.Oracle.com/global/in/education/maps/index.html

  • Using Oracle analytic function

    Hi all

    I use Oracle 10 g Release 10.0.2

    Here's the situation:

    I visited in my table of looks like this:

    Cust_id beg_dt end_dt sg_cd

    264321502 1 MAY 97 19 MARCH 98 1

    264321502 21 MAY 98 15 OCTOBER 98 6

    264321502 20 OCTOBER 98 22 APRIL 99 6

    264321502 23 APRIL 99 25 APRIL 00 6

    264321502 27 APRIL 00 20 JANUARY 02 6

    264321502 25 JANUARY 02 15 MAY 02 6

    264321502 MAY 21 02 27 MAY 02 6

    264321502 31 MAY 02 17 FEBRUARY 03 6

    264321502 21 FEBRUARY 06 03-7.-04 1

    264321502 25 FEBRUARY 03 25 FEBRUARY 03 1

    264321502 31 MARCH 03 30 APRIL 03 1

    264321502 07 - SEP - 04 26 DECEMBER 04 6

    264321502 29 DECEMBER 04 3 JANUARY 06 6

    264321502 4 JANUARY 06 3 JANUARY 07 12

    264321502 4 JANUARY 06 3 JANUARY 07 12

    264321502 4 JANUARY 06 3 JANUARY 07 12

    I need the results of the query as

    Cust_id beg_dt end_dt sg_cd

    264321502 1 MAY 97 19 MARCH 98 1

    264321502 21 MAY 98 17 FEBRUARY 03 6

    264321502 21 FEBRUARY 03 30 APRIL 03 1

    264321502 07 - SEP - 04 3 JANUARY 06 6

    264321502 4 JANUARY 06 3 JANUARY 07 12

    Basically, I need take a min max (end_dt) of sg_cd for this cust id (beg_dt).

    Any help is very much appreciated:

    My query is like that

    Select cust_id, end_dt, beg_dt, sg_cd,

    min (beg_dt) more (partition of cust_id, sg_Cd) as new_beg_dt,

    Max (end_dt) more (partition of cust_id, sg_cd) as end_Dt_nw

    of cust_tab.

    can be like that?

    1 data

    () 2

    3 select Cust_id 264321502, to_date('01-MAY-97','dd-mon-rr') beg_dt, to_date('19-MAR-98','dd-mon-rr') end_dt, 1 sg_cd of all the double union

    4. Select 264321502, to_date('21-MAY-98','dd-mon-rr'), to_date('15-OCT-98','dd-mon-rr'), 6 Union double all the

    5 select 264321502, to_date('20-OCT-98','dd-mon-rr'), to_date('22-APR-99','dd-mon-rr'), 6 Union double all the

    6. Select 264321502, to_date('23-APR-99','dd-mon-rr'), to_date('25-APR-00','dd-mon-rr'), 6 Union double all the

    7. Select 264321502, to_date('27-APR-00','dd-mon-rr'), to_date('20-JAN-02','dd-mon-rr'), 6 Union double all the

    8 select 264321502, to_date('25-JAN-02','dd-mon-rr'), to_date('15-MAY-02','dd-mon-rr'), 6 Union double all the

    9. Select 264321502, to_date('21-MAY-02','dd-mon-rr'), to_date('27-MAY-02','dd-mon-rr'), 6 Union double all the

    10. Select 264321502, to_date('31-MAY-02','dd-mon-rr'), to_date('17-FEB-03','dd-mon-rr'), 6 Union double all the

    11. Select 264321502, to_date('21-FEB-03','dd-mon-rr'), to_date('06-SEP-04','dd-mon-rr'), 1 Union double all the

    12 select 264321502, to_date('25-FEB-03','dd-mon-rr'), to_date('25-FEB-03','dd-mon-rr'), 1 Union double all the

    13 select 264321502, to_date('31-MAR-03','dd-mon-rr'), to_date('30-APR-03','dd-mon-rr'), 1 Union double all the

    14 select 264321502, to_date('07-SEP-04','dd-mon-rr'), to_date('26-DEC-04','dd-mon-rr'), 6 Union double all the

    15 select 264321502, to_date('29-DEC-04','dd-mon-rr'), to_date('03-JAN-06','dd-mon-rr'), 6 Union double all the

    16 select 264321502, to_date('04-JAN-06','dd-mon-rr'), to_date('03-JAN-07','dd-mon-rr'), 12 Union double all the

    17 select 264321502, to_date('04-JAN-06','dd-mon-rr'), to_date('03-JAN-07','dd-mon-rr'), 12 Union double all the

    18 select 264321502, to_date('04-JAN-06','dd-mon-rr'), to_date('03-JAN-07','dd-mon-rr'), 12 of the double

    (19) - select * from data

    20. Select Cust_id, beg_dt, max (end_dt) as end_dt, min (beg_dt), sg_cd

    21 of

    (22)

    23 select x.*, sum (flg) over (order by end_dt Cust_id partition) as grp

    24 of

    (25)

    26 select

    27 wagneur, case when lag (sg_cd, 1-9) over (order by end_dt Cust_id partition)! sg_cd = 1 END so that flg

    28 from data d

    x 29)

    x 30)

    Group 31 by Cust_id, sg_cd, grp

    32 * order of Cust_id, end_dt

    CUST_ID BEG_DT END_DT SG_CD

    ---------- --------- --------- ----------

    264321502 1 MAY 97 19 MARCH 98 1

    264321502 21 MAY 98 17 FEBRUARY 03 6

    264321502 21 FEBRUARY 06 03-7.-04 1

    264321502 07 - SEP - 04 3 JANUARY 06 6

    264321502 4 JANUARY 06 3 JANUARY 07 12

  • TO_NUMBER FUNCTION ERROR

    Hello

    Select to_number ('1500000',' $99 999, 99.99') of double; It displays the number not valid error, why?

    How does it work?

    Hello

    2611797 wrote:

    Hello

    Select to_number ('1500000',' $99 999, 99.99') of double; It displays the number not valid error, why?

    How does it work?

    The 1st argument does not have the reason for the 2nd argument.  The argument is 2, the channel will start with a sign of $; Since '1500000' does not start with a sign $, is not a valid string in this model.

    It goes the same for commas.  If you say TO_NUMBER 1 argument contains commas between groups of numbers, you better provide commas between groups of numbers.

  • Hi all, I want to learn Oracle HRMS functional

    Please suggest me

    Have you been in the documentation guides -

    Oracle E-Business Suite documentation

    See also http://apps2fusion.com/

  • Regexp_like instead of to_number function

    All good Dale

    I'm writing a query to check if something is a number. So far, I've had this

    Select 1

    of the double

    where regexp_like (1.1, ' ^ [--------+---------]?) [ 0-9] * \. ? [0-9]+$');

    But it won't work for floating numbers and I don't know why.

    [\+\-]?   -This should mean corresponds to + or - o or 1 times

    [0-9] *-match number 0 or more times

    \.?       -Time match 0 or 1 point

    [0-9] + -match 1 or more times number


    Best regards

    Igor

    'E' is also part of the numbers, if you use scientific notation...

    SQL > select 1.3E18 from double;

    1.3E18
    ----------
    1.3000E + 18

    So, is it not better to use "TO_NUMBER" which takes into account all the numbers rather than trying to build your own?

    Why reinvent the wheel?

  • Using Oracle date function

    Hi all

    I need to write a function under scenario
    I need to pass two parameters from_date and to_date
    I want to get all the dates between from_date and to_date except Saturday and also include from_date and to_date.

    Please help me.

    Thank you

    Published by: carmac on 29 January 2013 17:04

    Hello

    Carmac says:
    I want to get all the dates between from_date and to_date except Saturday and also include from_date and to_date

    You can change the Manik solution like this:

    WITH t AS
            (SELECT TO_DATE (:dt1, 'YYYYMMDD') startdt,
                    TO_DATE (:dt2, 'YYYYMMDD') enddt
               FROM DUAL)
    SELECT *
      FROM (    SELECT DECODE ( TO_CHAR (startdt + ROWNUM - 1     -- ***  CHANGED  ***
                                   , 'DY'),
                               'SAT', NULL,
                               startdt + ROWNUM - 1               -- ***  CHANGED  ***
                     )
                          dt
                  FROM t
            CONNECT BY ROWNUM <= (enddt + 1                    -- ***  CHANGED  ***
                                    - startdt))
     WHERE dt IS NOT NULL;
    
  • Invalid number when you use to_number function

    Hello
    Both in SQL * more and SQL Deveoper when I type and run

    Select to_number ('1234.64 ','9999.9 ') of double;

    I get ORA-01722: invalid number error. What can be the reason for this error?

    Mikhail says:
    SQL > select to_number('1234.64','9999D9') from double;
    Select double to_number('1234.64','9999D9')
    *
    ERROR on line 1:
    ORA-01722: invalid number

    You pass it a string ("1234.64'") with two digits to the right of the decimal separator, but you tell it that you have only one digit to the right of the decimal separator ('9999 D 9')

  • Oracle Table function

    I want to extract certain age using the TABLE function.
    declare
    type is rendered
    (
    name varchar2 (20).
    sex varchar2 (10),
    number (5) age
    );

    type emp_table is table of SheikYerbouti;

    var emp_table: = emp_table();

    number of l_age;
    Start

    var.extend;
    var (1) .name: = "test1";
    var (1) .sex: = 'male ';
    var (1) .age: = 19;

    var.extend;
    var (2) .name: = "test2."
    (2) var .sex: = 'female ';
    var (2) .age: = 20;

    Select age
    IN l_age
    table (var)
    where var.name = "test1";

    dbms_output.put_line (l_age);
    end;

    I was expection here.

    Can you help me solve this problem.

    Thank you!

    Local types are not allowed in the SQL statement. This means that you said

    type emp_rec is record
    (
    name varchar2(20),
    *** varchar2(10),
    age number(5)
    );
    
    type emp_table is table of emp_rec;
    

    locally. Instead the defined in the database.

Maybe you are looking for