Understanding LONG variable

I saw a code where they had stated " long n = 1L" , what is the L is the code for? What does it do?

it makes it faster. Its like integer but 1 better.
Really, though? It tells the compiler that the value is a long literal, otherwise it interperets it as an integer literal. In this case, it doesn't do too much. But if the value were greater than the maximum integer value, then the compiler would complain unless the L were there.
long l = 1;
long l2 = 1L;yields the following byte-code:
0: lconst_1
1: lstore_1
2: lconst_1
3: lstore_3

Similar Messages

  • How to process a large XML string passed to a LONG variable?

    I am attempting to extract and loop through some XML that is stored in a variable (v_xml_string) that is defined as LONG data type. However, I am receiving an ORA-01460: unimplemented or unreasonable conversion requested when the string value exceeds 20 records in the XML layout below. When I performed a LENGHTB on a sample XML string containing 19 records (just below the threshold of erroring), I get 3895, which I'm assuming is in BYTES...this is not near the 32,760 byte limit of PL/SQL variables defined as LONG. I suppose my other alternative is that I use CLOB datatype instead of LONG.
    XML layout:
    <?xml version="1.0"?>
    <DocumentElement>
      <tblElections>
        <EmpID>872G4</EmpID>
        <MgrNTID>JohnDoe</MgrNTID>
        <Entity>050595</Entity>
        <AddlAmt>1000</AddlAmt>
        <CheckedForSave>Y</CheckedForSave>   
      </tblElections>
    </DocumentElement>sample of code where error appers to be occurring:
    DECLARE
      v_xml_string LONG;
    BEGIN
        FOR v_xml_rec IN (SELECT t.COLUMN_VALUE.extract('/tblElections/EmpID/text()') .getStringVal() EmpID,
                                 t.COLUMN_VALUE.extract('/tblElections/MgrNTID/text()') .getStringVal() MgrNTID,
                                 t.COLUMN_VALUE.extract('/tblElections/FAEntity/text()') .getStringVal() FAEntity,
                                 t.COLUMN_VALUE.extract('/tblElections/AddlSLEAAmt/text()') .getStringVal() AddlSLEAAmt,
                                 t.COLUMN_VALUE.extract('/tblElections/CheckedForSave/text()') .getStringVal() CheckedForSave
                            FROM TABLE(xmlsequence(XMLTYPE(v_xml_string) .extract('/DocumentElement/tblElections'))) t)
        LOOP
    ... <do some stuff here>
       END LOOP;
    END;

    Strings in SQL are limited to 4000 in length, the long variable will work up to 32K as long as it is not used in SQL, if it goes over 4000 you will get the error.
    SQL> declare
      2    l long;
      3  begin
      4    l := rpad('x',32000,'x');
      5    dbms_output.put_line('length is : ' || to_char(length(l)));
      6  end;
      7  /
    length is : 32000
    PL/SQL procedure successfully completed.
    SQL> edi
    Wrote file afiedt.sql
      1  declare
      2    l long;
      3    n number;
      4  begin
      5    l := rpad('x',32000,'x');
      6    select length(l) into n from dual;
      7    dbms_output.put_line('length is : ' || to_char(n));
      8* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-01460: unimplemented or unreasonable conversion requested
    ORA-06512: at line 6
    SQL> edi
    Wrote file afiedt.sql
      1  declare
      2    l long;
      3    n number;
      4  begin
      5    l := rpad('x',4000,'x');
      6    select length(l) into n from dual;
      7    dbms_output.put_line('length is : ' || to_char(n));
      8* end;
    SQL> /
    length is : 4000
    PL/SQL procedure successfully completed.
    SQL> edi
    Wrote file afiedt.sql
      1  declare
      2    l long;
      3    n number;
      4  begin
      5    l := rpad('x',4001,'x');
      6    select length(l) into n from dual;
      7    dbms_output.put_line('length is : ' || to_char(n));
      8* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-01460: unimplemented or unreasonable conversion requested
    ORA-06512: at line 6
    SQL>

  • How to retrieve data from the serial port and decode it each 2 bytes is a long variable and 1 frame is about 6 bytes

    I send the frame by a microcontroller ( 8bits) the fram contains 6 bytes, 2bytes conform a long variable, I want to decode the frame and make operations with these long variables and then plot them

    Hey jpvans,
    I would first suggest using NI-VISA to talk to the serial port. Then, you can use the LabVIEW Type Cast or the Flatten to String and UnFlatten From String VIs to convert the data.
    You can setup the read so that it reads just two characters at a time to form an individual long or you can set the read up to read it all and then use the string functions like String Subset to cut the information into chunks.
    I hope this helps out.
    JoshuaP

  • Add long variable to a collection

    I have a long variable
    long userIDand need to add it to a collection object
                   Collection users = new ArrayList();
                   users.add(userID);but i get this error. How can I make it compatible ?

    raychen wrote:
    Unfortunately bad things too :-(
    Autoboxing is a double-edged sword.Can you list these bad things?Well performance for one. If you start thinking that List<Integer> is just a flexible version of int[] then you could get in trouble. I think that actually happened recently. Someone was loading/processing an image of some sort using Lists of Integers.
    It's obviously not the auto-boxing itself that's the issue in that case, but just that it hides from the unaware the wrapping etc that is going on.
    A second one is that are some rather byzantine rules regarding autoboxing when it comes to Generics and overloading and a few other things that can cause you unexpected results if you aren't careful.
    Personally I think that the first is more of a problem as it can catch neophyte programmers but the second can lead to more bizarre results when it happens. I don't think either of these make a good case against auto-boxing to be honest though. Like many things in programming, not knowing what you are doing can make X dangerous but that doesn't really mean that X is bad, it just means that you or someone doesn't know what they are doing.

  • (Another) problem with long variables

    I just got an error message that I really didn't expect.
    �Operator '&' can not be applied to 'long'�
    errrr, help?... Could anyone please tell me if there is another way of doing this (other than writing a function that splits each long variable into two int variables, masks them with '&' and reassembles them back into a long variable)

    I just got an error message that I really didn't
    expect.
    �Operator '&' can not be applied to 'long'�
    errrr, help?... Could anyone please tell me if
    there is another way of doing this (other than writing
    a function that splits each long variable into two int
    variables, masks them with '&' and reassembles them
    back into a long variable)Have you considered class BigInteger

  • How do you initialise a long variable?

    I want to initialise my long variable..how do i do it?
    is it
    long myLong = 0.00L
    ?

    long myLong = 0;Or
    long myLong = 0L;
    to avoid an implicit cast because 0 is an int
    literal.However, I'm sure the compiled bytecode would be the same in this case (or at least it should be).

  • Raising exception for LONG variable

    Hi
    I am calling a procedure from HTML which passes data into a LONG
    type variable. If the length of data is more than 32KB , NULL is
    assigned to the LONG variable and no error is raised. Is there
    any way this exception can be trapped ? Any info in this regard
    will be much appreciated.
    Sharon
    null

    Solomon Yakobson wrote:
    Jiri in SF wrote:
    I would say right before you query the data from dblink, use DBMS_APPLICATION_INFO to set module or/and action for that session, then have a separate job scheduled every 5? minutes to scan for sessions with your module/action (it can be really any static text you want BLABLABLA works - the point is that you can easily identify these sessions) which hang for more than 2? minutes and send email or kill these sessionsWell, although it would give you geat level of flexibility, it would mean rewriting code and results in some overhead. Also, it would kill distributed transactions running for longer than set time, not distributed transactions waiting for locked resources longer than set time. To kill distributed transaction waiting for a locked resource more then a set time (as OP requested) OP could set initialization parameter DISTRIBUTED_LOCK_TIMEOUT to desired value. Obviously, same timeout will apply to all distributed queries, unfortunately, DISTRIBUTED_LOCK_TIMEOUT is not dynamic parameter
    SY.not sure what his issue is (maybe different from what we were facing), but our was not related to locking, it was basically hanging session. Remote server did not even see the session being connected yet it was hanging for hours on query across db-link. It was very rare - the session ran daily and hang maybe once a 6 months. In our case we just wanted to be informed that it hang, so production support could follow up on the issue.

  • The long variable

    Is there anything bigger than the "long" variable?

    I've just seen the source of Double and i read this :
         * The largest positive finite value of type <code>double</code>.
         * It is equal to the returned by:
         * <blockquote><pre>
         * <code>Double.longBitsToDouble(0x7fefffffffffffffL)</code>
         * </pre></blockquote>
         public static final double MAX_VALUE = 1.79769313486231570e+308;
    Then, Double are coded in 64 bits like long.
    The coding of double allow big number without precision:
    (to return to initial question)use what you need :)

  • Concatenate long variable

    I am try concatenate long variable, but error ora-06502.
    How I concatenate long variable.
    Thanks.
    Aline

    But it does with a long variable -
    SQL> declare
      2  l_lng long;
      3  begin
      4  l_lng := '1';
      5  l_lng := l_lng || '2';
      6  dbms_output.put_line('concat long: '||l_lng);
      7  end;
      8  /
    concat long: 12

  • Query "LONG" variable using select

    Hi,
    I am trying to fetch the data of the table in which one of the column is of type LONG. And i get the below error:
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected NUMBER got LONG BINARY
    I tried this:
    set long 20000
    But of no use.
    My DB version is 10g R2 on RHEL 4AS.
    Query used is:
    set long 20000
    select field1,field2,field3,field4,field5,field6,field7 from <table>;
    Table looks like this:
    Name Null? Type
    field1 NOT NULL LONG RAW
    field2 NOT NULL VARCHAR2(50)
    field3 NOT NULL NUMBER(10)
    field4 NOT NULL VARCHAR2(255 CHAR)
    field5 NOT NULL VARCHAR2(128)
    field6 NOT NULL VARCHAR2(512)
    field7 NOT NULL VARCHAR2(1024)
    Any help appreciated.
    Thanks,
    Ramya

    Hi,
    Sorry, I was able to get that into the file. But since it is binary variable couldnt get that actual data.
    Is there any way to get the actual data of that column.
    Table structure is:
    Name Null? Type
    CartID NOT NULL LONG RAW
    SessionID NOT NULL VARCHAR2(50)
    CartEntryID NOT NULL NUMBER(10)
    TransRef NOT NULL VARCHAR2(255 CHAR)
    Slug NOT NULL VARCHAR2(128)
    ImagePath NOT NULL VARCHAR2(512)
    ThumbNailID NOT NULL VARCHAR2(1024)
    ImageID NOT NULL VARCHAR2(128)
    DownloadID NOT NULL VARCHAR2(1024)
    CreatedAt NOT NULL DATE
    DeliveryMethod NUMBER(10)
    PrintSize VARCHAR2(50)
    Price NUMBER(19,4)
    ImgRights NOT NULL VARCHAR2(128)
    Last_Active NOT NULL DATE
    SourceName VARCHAR2(128)
    ItemType VARCHAR2(5)
    Thanks,
    Ramya

  • Read XML (stored in Long Variable) through PL SQL

    Hi,
    We are on 11g2 Database. We have xml content in Long column/variable.
    Can anyone help me out to read xml attribute value ?
    eg.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE labels SYSTEM "label.dtd">
    <labels QUANTITY="1" JOBNAME="LBL213685">
    <label FORMAT="XEINSP_REQ_LBL.lwl">
    <variable name= "L_DATE">04-JAN-2012</variable>
    <variable name= "L_TIME">10:45:17</variable>
    <variable name= "L_LPN">K01-4713BE</variable>
    <variable name= "L_ITEM">XXXXWT88-002</variable>
    <variable name= "L_ITEMDESC">SPRING,REVERSIBLE EXPANSION GE14 234C6745P001 REV.01</variable>
    <variable name= "L_QTY">1</variable>
    <variable name= "L_POREV"></variable>
    <variable name= "L_PONUM">837037254</variable>
    <variable name= "L_ITEMREF">834C6745P001</variable>
    <variable name= "L_PROJECT"></variable>
    <variable name= "L_ISIS"></variable>
    <variable name= "L_LABEL">1</variable>
    <variable name= "L_LINE_NO">1</variable>
    <variable name= "L_SUPPLIER">RECISION OIL, INC</variable>
    </label>
    </labels>
    We want to read value next to <variable name= "L_LPN"> . Need to return K01-4713BE programmatically.
    Appreciate your help.
    Thanks,
    Abhi
    Edited by: user649769 on Jan 4, 2012 2:52 PM
    Edited by: user649769 on Jan 4, 2012 2:53 PM

    Hi,
    As you may be aware, LONG datatype is obsolete for quite some time now.
    If you can you should really consider migrating it to CLOB, or in this specific case store XML data in an XMLType column.
    In particular, we can't use XMLType constructor directly on a LONG.
    Here's a simple PL/SQL solution though, provided the data is not larger than 32k :
    SQL> create table test_long (xmldoc long);
    Table created
    SQL> insert into test_long values('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
      2  <!DOCTYPE labels SYSTEM "label.dtd">
      3  <labels _QUANTITY="1" _JOBNAME="LBL213685">
      4  <label _FORMAT="XE_INSP_REQ_LBL.lwl">
      5  <variable name= "L_DATE">04-JAN-2012</variable>
      6  <variable name= "L_TIME">10:45:17</variable>
      7  <variable name= "L_LPN">K01-4713BE</variable>
      8  <variable name= "L_ITEM">XXXXWT88-002</variable>
      9  <variable name= "L_ITEMDESC">SPRING,REVERSIBLE EXPANSION GE14 234C6745P001 REV.01</variable>
    10  <variable name= "L_QTY">1</variable>
    11  <variable name= "L_POREV"></variable>
    12  <variable name= "L_PONUM">837037254</variable>
    13  <variable name= "L_ITEMREF">834C6745P001</variable>
    14  <variable name= "L_PROJECT"></variable>
    15  <variable name= "L_ISIS"></variable>
    16  <variable name= "L_LABEL">1</variable>
    17  <variable name= "L_LINE_NO">1</variable>
    18  <variable name= "L_SUPPLIER">RECISION OIL, INC</variable>
    19  </label>
    20  </labels>');
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> set serveroutput on
    SQL> DECLARE
      2 
      3    v_xmldoc   varchar2(32767);
      4    v_result   varchar2(30);
      5 
      6  BEGIN
      7 
      8    select xmldoc into v_xmldoc from test_long;
      9 
    10    /* disable DTD validation for the current session */
    11    execute immediate 'alter session set events = ''31156 trace name context forever, level 2''';
    12 
    13    select xmlcast(
    14             xmlquery('/labels/label/variable[@name="L_LPN"]'
    15                      passing xmltype(v_xmldoc)
    16                      returning content)
    17             as varchar2(30)
    18           )
    19    into v_result
    20    from dual
    21    ;
    22 
    23    execute immediate 'alter session set events = ''31156 trace name context off''';
    24 
    25    dbms_output.put_line(v_result);
    26 
    27  END;
    28  /
    K01-4713BE
    PL/SQL procedure successfully completed
    Note that I used event 31156 to temporarily disable DTD validation on the XML document, and avoid this :
    ORA-31001: Invalid resource handle or path name "/label.dtd"If you want to actually use validation, the DTD has to be stored in the XML DB repository (in the root folder).

  • Trying to understand long sync time after 4 update :re blurry photos

    hi i wanted to take out the 1 photo album that was blurred/grainy after update and then re-install them so that they are optimized. however when i sync it is taking hours. the album in question has 800 photos in it, but it should delete right away. i have had to exit the sync several times.
    can anyone tell me first the steps to removing a photo album. so at least i am clear on that?
    and then im wondering if these long syncs are normal. i have very little data on the phone itself. before the update it was synching quick. i have windows 7 and itunes 9.2.
    thanks in advance.

    ok its optimizing. thanks again.
    thanks tamara. i will give that a shot. in order to do that do i have to select in the options "sync only checked songs and videos"? also does videos refer to photos as well?
    sorry i know im flatlining here, i appreciate the help.
    Message was edited by: Radium88

  • Long variable can not hold 20030414153045

    I have the following code
    long trackNo = 20030414153045
    but the compiler keeps giving me error message:
    integer number too large: 20030414156060
    but the maximum value for long should be greater than this,
    I am really confused, help please.

    Integer constants are of type "int" by default. Your number is too big to fit in an int, so you need to explicitely state that it is of type long:
    long trackNo = 20030414153045L;

  • Truncate long variable into a short one

    Hi,
    I have a 40 character variable that needs to be truncated in a 20 character variable.
    How do I do this?
    Thanks,
    John

    data:   var1(40) type c.
    data:   var2(20) type c.
    if u want first 20 chars of var1 to be moved to var2..
    then simply use...  var2 = var1.  " First 20 chars will be moved to var2 from var1
    If u want last 20 chars then
    var2 = var1+20(20).
    if u want 20 chars of specific position like  pos 10 to 30.. then
    var2 = var1+10(20).
    Reward if helpful
    Regards
    Prax

  • 10G UTL_MAIL.SEND and message bigger than a LONG variable ?

    Hi,
    Is it possible to send out a message containing more that 32767 characters (LONG) using 10G UTL_MAIL.SEND. I have to send a big HTML report (inline).
    Thank's

    Hi
    its true we cannot use UTL_MAIL package for sending mails with Attachments as it can be used only for attachments of size less than 32KB. For higher sizes i referred Metalink an found the below info regarding UTL_SMTP.
    This is the doc Id
    Doc ID:      Note:357385.1
    Doc ID:      Note:414062.1
    Doc ID:      Note:334734.1
    Doc ID:      Note:302943.1
    Hope this docs helps u in your findings.
    however, i have dropped my plans to send mail with attachments as mailbox has size limits and my files can be very big. SO, i would instead store the file in to a customr notified location and send him a mail about the presence of the file. I know this is not the right approach but i cudnt find a better approach than this. If any one can fin a better solution plz post it here.
    Regards
    Vibhuti

Maybe you are looking for

  • [CS2][AS] Make XML import map is calling a refresh on styles?

    If this can be of use to someone else... it's probably not CS2,AS specific.. but this is what i use. It's the second time i have a bug like this, where changing the order of my calls is fixing the problem. With this one, i was getting random missing

  • CAP file generating ERROR

    Hi everybody , I'm trying to build a javacard project by using ANT tool . The problem is when i use the JCOP tool converter (tric.jar) with JRE 1.4 or 1.5 i got the following error : Error: class java.lang.RuntimeException, resolving constant-pool of

  • [HOWTO] Nautilus and mp3 metadata columns in list view (bitrate etc.)

    Hidden deeply in the wikipages, I just added a small howto on adding music metadata columns to nautilus's list view: http://wiki.archlinux.org/index.php/Gno - te_etc..29 It allows for Album, Artist, Track Title and Bitrate Columns in list view mode.

  • Period 002/2009 is not open for account type S and G/L 399999

    I am getting this error while doing GR with 561 movment type, how to overcome this? Thank You.

  • Problem Upload to FTP host...

    Hi can you help me I have a web site content many Assets link (pdf files like 10 mo each) and when i want to upload to my FTP host, it's very very long to accomplish this part i must Cancel and proceed with Export as html to transfert all i'm sad bec