Doubt in length function

I am beginner in PL/SQL.The Following statement returns only 40 thugh the exact length is 91.
SELECT
length(1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950)
FROM dual
Also, I get the same result whenever the input number's length exceeds 40. It is working successfully if the input numbers length is below 40.
I am using PL/SQL developer.
Please suggest

You need to use quotes when using character data in SQL:
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> SELECT
  2  length(1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950)
  3  FROM dual;
LENGTH(1234567891011121314151617181920212223242526272829303132333435363738394041
                                                                              40
SQL> SELECT
  2  length('1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950')
  3  from dual;
LENGTH('123456789101112131415161718192021222324252627282930313233343536373839404
                                                                              91

Similar Messages

  • LENGTH function for a large number returns 40 not the number of digits

    In SQL*Plus:
    SQL> select length(12345678901234567890123456789012345678901234567890)lngth
    2 from dual;
    LNGTH
    40
    SQL> select length('12345678901234567890123456789012345678901234567890')lngth
    2 from dual;
    LNGTH
    50
    It seems that the implicit conversion from number to char in the first query causes an unexpected result. From the documentation of the LENGTH function at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions181.htm#i79330:
    "If you omit fmt, then n is converted to a VARCHAR2 value exactly long enough to hold its significant digits."
    Perhaps Oracle considers that only 40 digits are significant (?)

    Additional reason.
    There is implicit data conversion as like to_char(number).
    SQL> set numwidth 50
    SQL> select 12345678901234567890123456789012345678901234567890 num from dual;
                                                   NUM
    12345678901234567890123456789012345678900000000000
    SQL> select length(12345678901234567890123456789012345678901234567890) numlen from dual;
                                                NUMLEN
                                                    40
    SQL> select to_char(12345678901234567890123456789012345678901234567890) numlen from dual;
    NUMLEN
    1.2345678901234567890123456789012346E+49
    SQL> select length(to_char(12345678901234567890123456789012345678901234567890)) numlen from dual;
                                                NUMLEN
                                                    40
    SQL> select to_char(12345678901234567890123456789012345678901234567890,
      2                '09000000000000000000000000000000000000000000000000')
      3  num from dual;
    NUM
    12345678901234567890123456789012345678900000000000
    SQL> select length(to_char(12345678901234567890123456789012345678901234567890,
      2                '09000000000000000000000000000000000000000000000000'))
      3  num from dual;
                                                   NUM
                                                    51
    SQL> select to_char(12345678901234567890123456789012345678901234567890,
      2                'fm09000000000000000000000000000000000000000000000000')
      3  num from dual;
    NUM
    12345678901234567890123456789012345678900000000000
    SQL> select length(to_char(12345678901234567890123456789012345678901234567890,
      2                'fm09000000000000000000000000000000000000000000000000'))
      3  num from dual;
                                                   NUM
                                                    50

  • Length function?

    Is there a Length function in iSQL?
    I'm trying to create the following query in TOAD
    select A
    From B
    Where length(A) = 11
    Order By A
    but, as long as I have the Where clause in there, it complains about "Invalid Column Name". I tried "len" instead of "length", but no improvement.
    Your help is appreciated.

    You have a syntax error in the column name perhaps?
    example of use of length function:
    SQL> select table_name
      2  from dba_tables
      3  where length (table_name) = 1 ;
    TABLE_NAME
    T

  • Doubt in ABAP function

    Hi,
    I have a doubt in one of the abap function module i use.
    This contain code to retrieve ,update and delete and create values in table. I am using this function  module to
    retrieve ,update and delete and create values in table.  This is the ABAP code.
    FUNCTION ZUP_DESIG12.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(DESG_CODE) TYPE  ZUP_DESIG-DESG_CODE OPTIONAL
    *"     VALUE(DESG_DESC) TYPE  ZUP_DESIG-DESG_DESC OPTIONAL
    *"     VALUE(DESG_ACT) TYPE  ZUP_DESIG-DESG_ACT OPTIONAL
    *"     VALUE(DESG_OPT) TYPE  ZUP_DESIG-DESG_OPT OPTIONAL
    *"  EXPORTING
    *"     VALUE(DESG_CODE_C) TYPE  ZUP_DESIG-DESG_CODE
    *"     VALUE(DESG_DESC_C) TYPE  ZUP_DESIG-DESG_DESC
    *"     VALUE(DESG_ACT_C) TYPE  ZUP_DESIG-DESG_ACT
    *"     VALUE(DESG_OPT_C) TYPE  ZUP_DESIG-DESG_OPT
    *"  TABLES
    *"      WA STRUCTURE  ZMSTR_DESIG
    DATA CNT TYPE I.
    SELECT MANDT DESG_CODE DESG_DESC DESG_ACT FROM ZMSTR_DESIG
      INTO TABLE WA.
    IF DESG_OPT = 'U'.
    UPDATE ZMSTR_DESIG
        SET DESG_DESC = DESG_DESC
        DESG_ACT = DESG_ACT
        WHERE DESG_CODE = DESG_CODE.
    MESSAGE 'Updated Successfully' TYPE 'I'.
    ELSEIF DESG_OPT = 'C'.
    SELECT COUNT( * ) FROM ZMSTR_DESIG INTO CNT
       WHERE DESG_CODE = DESG_CODE.
       IF CNT > 0.
       MESSAGE 'Duplicate Designation code' TYPE 'I'.
       ELSE.
      WA-DESG_CODE = DESG_CODE.
      WA-DESG_DESC = DESG_DESC.
      WA-DESG_ACT = DESG_ACT.
      MODIFY ZMSTR_DESIG FROM WA.
       MESSAGE 'Inserted successfully' TYPE 'I'.
    ENDIF.
    ELSEIF DESG_OPT = 'D'.
       DELETE FROM ZMSTR_DESIG WHERE DESG_CODE = DESG_CODE.
       MESSAGE 'Deleted successfully' TYPE 'I'.
    ENDIF.
    ENDFUNCTION.
    can any one what is  wrong in this function.
    Regards,
    H.V.Swathi

    My doubt is how to write code to insert data to table. I have written code like this.
    try{
             String str1= wdContext.currentTestElement().getCode();
              String str2= wdContext.currentTestElement().getDesc();
              boolean str3= wdContext.currentTestElement().getAct();
              String str4= wdContext.currentTestElement().getOpt();
              String str5;
              if(str3)
              str5=new String("x");
              else
              str5=new String(" ");
              Zup_Desig12_Input input=new Zup_Desig12_Input();
              input.setDesg_Code(str1);
              input.setDesg_Desc(str2);
              input.setDesg_Act(str5);
              input.setDesg_Opt(str4);
              wdContext.nodeZup_Desig12_Input().bind(input);
              wdContext.currentZup_Desig12_InputElement().modelObject().execute();
        }catch(Exception e)
             wdComponentAPI.getMessageManager().reportSuccess(e.toString());
    But i am getting      java.lang.ArrayIndexOutOfBoundsException: -1
    in line
    input.setDesg_Act(str5);
    can any one help me plz

  • Doubt in RFC Function module

    Hi,
    I am creating one RFC in that i need to declare one import parameter whose length is is.
    when i am giving like i_exclide like kna1-loevm is not accepting.
    when i am declaring like i_exclude like char1.
    it is giving error like reference parameters are not allowed in RFC.
    anybody can tell me how to declare.
    thanks,
    maheedhar

    Hi,
    Go to se37,
    Give ur RFC function module and click change.
    Go to "Import" tab , you can find a checkbox "Pass Value" , check this checkbox.
    Now you try to compile the code , you wont get that error.
    Reward points for useful answer.
    Thanks,
    Jey

  • Doubt in keyPressed() function!

    Hi to all,
    Im doing project in J2ME. In my source code, i used keyPressed() function to get the user's choice by using switch case.Now my doubt is, should i use one more keyPressed() function in inside my previous keyPressed() func.(i.e. nested keypressed() func)?.. For eg: In my application, there will be four choices.. 1.Cars 2. Bikes 3.Mobiles 4.exit...If an user press the key '3' means, i need to giv him one more choice screen like 1.Nokia 2.Sony ericsson 3.Motorola.. If an user press '2' means, have to display the info about sony ericsson...Right now im using code like the following:
    public void keyPressed(int key)
    switch(key)
    case KEY_NUM1:
    break;
    case KEY_NUM2:
    break;
    case KEY_NUM3:
    break;
    case KEY_NUM4:
    break;
    Now my doubt is....Should i use like the following:
    public void keyPressed(int key)
    switch(key)
    case KEY_NUM1:
    break;
    case KEY_NUM2:
    break;
    case KEY_NUM3:
    public void keyPressed(int key)
    switch(key)
    case KEY_NUM1:
    break;
    case KEY_NUM2:
    break;
    case KEY_NUM3:
    break;
    case KEY_NUM4:
    break;
    break;
    case KEY_NUM4:
    break;
    }

    My doubt is how to write code to insert data to table. I have written code like this.
    try{
             String str1= wdContext.currentTestElement().getCode();
              String str2= wdContext.currentTestElement().getDesc();
              boolean str3= wdContext.currentTestElement().getAct();
              String str4= wdContext.currentTestElement().getOpt();
              String str5;
              if(str3)
              str5=new String("x");
              else
              str5=new String(" ");
              Zup_Desig12_Input input=new Zup_Desig12_Input();
              input.setDesg_Code(str1);
              input.setDesg_Desc(str2);
              input.setDesg_Act(str5);
              input.setDesg_Opt(str4);
              wdContext.nodeZup_Desig12_Input().bind(input);
              wdContext.currentZup_Desig12_InputElement().modelObject().execute();
        }catch(Exception e)
             wdComponentAPI.getMessageManager().reportSuccess(e.toString());
    But i am getting      java.lang.ArrayIndexOutOfBoundsException: -1
    in line
    input.setDesg_Act(str5);
    can any one help me plz

  • Doubt in using :Function Module : MS_CONVERT_TO_OTHER_CURRENCY

    Hi ,.
    In the Function Module :MS_CONVERT_TO_OTHER_CURRENCY.
    I have to export following parametes:
    DATE            
    FROM_CURRENCY   
    FROM_AMOUNT     
    TO_CURRENCY     
    COMPANY_CURRENCY
    RATE  (optional)    .
    Here my doubt is :what is the purpose of COMPANY_CURRENCY .What value i have to populate here , how i have to find the  company currency?
    I think we have to find this COMPANY_CURRENCY  based on the sales organization.
    Please update me regarding this COMPANY_CURRENCY .
    Thanks,
    Suresh.

    Have you tried using 'CONVERT_TO_FOREIGN_CURRENCY' instead?
    DATA: v_amount TYPE p DECIMALS 2.
    CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
    EXPORTING
    date = sy-datum
    foreign_currency = 'INR'
    local_amount = '1.00'
    local_currency = 'USD'
    IMPORTING
    foreign_amount = v_amount
    EXCEPTIONS
    no_rate_found = 1
    overflow = 2
    no_factors_found = 3
    no_spread_found = 4
    derived_2_times = 5
    OTHERS = 6.
    IF sy-subrc = 0.
    WRITE: / 'US dollar to Indian rupees - ', v_amount.
    ENDIF.

  • Doubt in Analytical Functions

    Hi,
    I am new to oracle , i have a doubt : I have written a query using analytical functions to get the desired , but i wanted the same in a normal query .
    INPUT TABLE :
    NAME AMOUNT
    A 100
    A 200
    A 300
    B 200
    B 300
    C 300
    Query : SELECT name,AMOUNT,ROW_NUMBER( ) OVER (PARTITION BY name order by name NULLS LAST) SRLNO
    FROM data ORDER BY name, SRLNO;
    output table:
    NAME AMOUNT SRLNO
    A 100 1
    A 200 2
    A 300 3
    B 200 1
    B 300 2
    C 300 1
    QUESTION: I wanted the same output table with normal SQL quey , but i don't want to use any partition statement here (nor any analytical functions) .
    Please provide solution for this .

    i don't want to use any partition statement here (nor any analytical functions) .Why not? What you want to do is what analytics does. I get suspicious when anybody - but especially somebody who's new to Oracle - aks how to do something different from using the built-ins provided by Oracle.
    I wanted the same output table with normal SQL queySo you're ruling out Pipelined functions and MODEL clauses? Or not?
    Cheers, APC
    blog : http://radiofreetooting.blogspot.com

  • Doubt in enqueue_array functionality

    Hi,
    I am using enqueue_array function to insert multiple rows in the queue. Payload type is user defined object (obj) containing one attribute: JMS Message. If I create a type (tbl) which is table of obj at the schema level then enqueue_array works perfectly and inserts all the rows into the queue.
    But If I don't declare a type at the schema level and instead declare it in the pl/sql block, then enque_array function doesn't work. I don't get any error but no row gets inserted in the queue.
    My doubt is why no row is getting inserted in the 2nd case? Does Oracle treats the 2 types in different ways? Please clarify. Thank you.

    Hi,
    I am using enqueue_array function to insert multiple rows in the queue. Payload type is user defined object (obj) containing one attribute: JMS Message. If I create a type (tbl) which is table of obj at the schema level then enqueue_array works perfectly and inserts all the rows into the queue.
    But If I don't declare a type at the schema level and instead declare it in the pl/sql block, then enque_array function doesn't work. I don't get any error but no row gets inserted in the queue.
    My doubt is why no row is getting inserted in the 2nd case? Does Oracle treats the 2 types in different ways? Please clarify. Thank you.

  • Confusion with length function ... ?

    I have avery basic question, i have a table ( Item Master ) in oracle which has a field called Item, which is declared as CHAR(50)
    now this field contains data as
    ITEM
    Car
    Pencil
    Televsion
    There are some 5,00,000 records in this table and i would like to find the length of data.
    For example when i execute the new proposed query it should give me output as
    ITEM          LENGTH
    Car          3     
    Pencil          6
    Televsion     9
    but currently when i execute the below mentioned query , it gives me output as mentioned below which i dont want
    select itemcode, length(itemcode) from itemmaster;
    Item          Length
    Car          50
    Pencil          50
    Televsion     50
    sorry i am new to oracle syntax, i tried to locate the excact function , but could not find :-(

    how do i display only top 10 records descending by character length
    SQL> select   object_name, len
      from   (select   object_name,
                       length (object_name) len,
                       row_number () over (order by length (object_name) desc) rn
                from   all_objects
               where   owner = 'SYS')
    where   rn <= 10
    OBJECT_NAME                           LEN
    RESOURCE_STORAGE_POOL_MAPPING$         30
    I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST         30
    APPLY$_CONSTRAINT_COLUMNS_UIX1         30
    V_$PGA_TARGET_ADVICE_HISTOGRAM         30
    I_FGR$_FILE_GROUP_EXPORT_INFO1         30
    APPLY$_CONSTRAINT_COLUMNS_IDX1         30
    GV_$RSRC_CONSUME_GROUP_CPU_MTH         30
    GV_$CONTROLFILE_RECORD_SECTION         30
    GV_$FLASHBACK_DATABASE_LOGFILE         30
    GV_$PGATARGET_ADVICE_HISTOGRAM         30
    10 rows selected.

  • Doubt in GUI_UPLOAD function

    Hi friends,
    CALL FUNCTION 'GUI_UPLOAD '
    EXPORTING
    FILENAME = FILE
    FILETYPE = 'ASC'
    *HAS_FIELD_SEPARATOR = 'X'
    TABLES
    DATA_TAB = ITAB.
    In the GUI_UPLOAD function what the filetype should be and has_field_separator should be given what value? What does it mean.How should i prepare the file for example for VA01 transaction if i have a file like this it is not working. What is the problem. I am new to BDC so i need your help on this.
    Thanks in Advance.

    try the following.
    DATA: begin of ITAB occurs 0,
          field1 type char10,
          field2 type char10,
          end of itab.
    data: filename type string value 'C:\TMP.TXT'.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
       FILENAME                      = filename
       FILETYPE                      = 'ASC'
      TABLES
        DATA_TAB                      = itab.
    loop at itab.
      write:/ itab-field1, 20 itab-field2.
    endloop.
    create a file with tab-delimitations.

  • Doubt in update function module

    dear friends..
    i have created an UPDATE function module with Processing type- Update Module, Start Immediate. i have handled the exceptions using Raise statement in the function module..
    the call function looks as..
      CALL FUNCTION 'ZFI_LCTXN_TABLES_UPDATE'
        in update task
        EXPORTING
          ZLCTMB1  = p_lctmb1
          NU_ENTRY = p_global-ins_zlctmb1
        TABLES
          UPD_PO   = UPD_PO
          UPD_SH   = UPD_SH
        EXCEPTIONS
          ERROR    = 1
          OTHERS   = 2.
      p_subrc = sy-subrc.
      commit work.
    but if the update fails, and even though the RAISE ERROR works, and update termination message is registered in SM13, i dont get the value for sy-subrc as 1 .
    is it the right way..if yes please tell me how to generate an error message within the transaction..so that the user knows the update has failed..
    thank you for your time
    Nivin

    Hi,
    Maybe it's usefull  for you.
    <b>
      IF sy-subrc EQ 4.
        MESSAGE e001 RAISING not_found.
      ELSEIF sy-subrc EQ 8.
        MESSAGE e002 RAISING not_found.
      ELSE.
      ENDIF.</b>
    Using this to create a message and raise in the same time !
    Regards.
    Marcelo Ramos

  • Doubt in Read_text function

    Hi all
    I have created one support message in crmd_order solution manager. In that i have entered Description (Su99). I can see the description in SUZZ LOG. but i can read the text using function module READ_TEXT
    How can i access.
    Parameters
    CLIENT 900
    ID SUZZ
    LANGUAGE EN
    NAME 469D18B8C04721CFE10000000A210107
    OBJECT CRM_ORDERH
    ARCHIVE_HANDLE 0
    LOCAL_CAT
    Export parameters Value
    HEADER
    Tables Value
    LINES 0 Entries
    Result: 0 Entries
    anybody help me

    Hi Muthu,
    check the code,
    DATA: it_lines LIKE TABLE OF tline WITH HEADER LINE.
    CALL FUNCTION 'READ_TEXT'
    EXPORTING
    id = 'LTXT'
    language = sy-langu
    name = '000001100184'
    object ='AUFK'
    IMPORTING
    HEADER =
    TABLES
    lines = it_lines
    EXCEPTIONS
    id = 1
    language = 2
    name = 3
    not_found = 4
    object = 5
    reference_check = 6
    wrong_access_to_archive = 7
    OTHERS = 8.
    Thanks.

  • Doubt pertaining Partner Function Role ES..

    Hi,
    What is the significance of the Role ES defined as a Partner Function in a One time customer.
    I am using the default system created Account assignement Group: CPD.
    THNX n Regards,
    Subbzz..

    Hi Raghav,
    While creating a One Time customer Using the Account Group CPD what value should be entered against the PF-ES??
    The system prompts me to enter the PF and doesnt allow me to save without the data.
    Where do we need to create it for assigining here.
    Cheerzz..
    Subbzz.

  • Doubt in Generating Function!!!!!:(

    Hi All,
    It is said that
    "A target field with maxOccurs=<n> that is assigned a generating function is generated <n> times in the target structure. if maxOccurs=unbounded for the target field, then exactly 5 target field are created".
    But if we have done Message Mapping, we could realise that this statement does not hold.
    Could anyone please help me out by explaining what this statement actually means.
    Regards,
    Sundar.

    Hi,
    Are you sure it is said like that?
    Because in help.sap it says
    http://help.sap.com/saphelp_nw04/helpdata/en/e4/82cf0ec8b9494db92e27e2be69524f/frameset.htm
    +If generating functions are assigned to a target field, the attributes minOccurs and maxOccurs determine how frequently a value is generated:
    If minOccurs = 0 the value of the function is generated once.
    · Otherwise, the value of the function is generated as often as is specified by minOccurs.
        ( This applies regardless of the value set in maxOccurs. Even if maxOccurs = “unbounded“, the mapping runtime will still only generate the value as often as is specified by minOccurs.)+
    Regards
    Suraj

Maybe you are looking for