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
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> -
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 -
How to Concatenate 2 Variables in SAP APO DP Macro
Hi All
I am trying to concatenate 2 variables in a single third variable. Can some body please guid me on how this can be achieved
e.g. I have a variable containting a characteristic Value - "1010101" and Another Variable have a number "12345"
I want to show a string - "1010101 with value 12345"
Can somebody please guide on how this can be achieved
Any help in this regard is highly appreciated
Thanks
VijayHi Vijay,
Try with with the command STRINGS_CONCATENATE().
Syntax
STRINGS_CONCATENATE ('String1'...'Stringn')
Thanks and Regards,
Mariano -
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
nullSolomon 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. -
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 :) -
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,
RamyaHi,
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 PMHi,
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). -
Is it possible to concatenate XMLType variable
I'm using XQuery to query relational table and store the result into an xmltype variable as shown below:
SELECT XMLQuery('<Data>
{for $c in ora:view("TABLEA")
let $id := $c/ROW/ID/text(), $code := $c/ROW/CODE/text(),
return
<result>
<type>I</type>
<id>{$id}</id>
<code>{$code}</code>
</result> </Data>' RETURNING CONTENT)
INTO V_Delete FROM dual;
Similarly, I query other tables and store the result in xmltype variable. My requirement is to generate one xml file out of it. This would mean that I would need to consolidate the values stored in different xmltype variables. Is it possible to concatenate the xmltype varialbe? If so, how? If not, what is the alternative? I tried converting it to string, but then the 4000 limit caused an error.Hi, as I said I have not done that myself. But you can read chapter 4 of the XDB Developer's Guide of the Oraclce docs and I think it may help. The examples there show that those functions are used to update a table. It has this example,
UPDATE purchaseorder
SET OBJECT_VALUE =
appendChildXML(OBJECT_VALUE,
'/PurchaseOrder/Actions/Action[1]',
XMLType('<Date>2002-11-04</Date>'))
WHERE existsNode(OBJECT_VALUE,
'/PurchaseOrder[Reference="AMCEWEN-20021009123336171PDT"]')
= 1;
SELECT extract(OBJECT_VALUE, '/PurchaseOrder/Actions/Action[1]')
FROM purchaseorder
WHERE existsNode(OBJECT_VALUE,
'/PurchaseOrder[Reference="AMCEWEN-20021009123336171PDT"]')
= 1;
That was why I thought using a global temp table would help in this kind of operation. What I did was using select xmlelement(namespace declarations) from dual, then using a nested (select xmlelement() ) inside the from dual part. I have to select from many different tables to create one xml and it works for me, but I did not try the other ways. If you just need to attach the prolog and namespace stuff, you can store them in a clob or varchar2 var and convert the xml to clob and that simply concantenate them, and then convert the clob back to xml. In 10g there is also the new XMLProlog (I forgot the exact name at this moment) function. Check that out and see if it will work for you.
ben -
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 -
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,
Johndata: 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
Maybe you are looking for
-
Hello Friends> I want to create Login Page. but main problem is when user click Login Button it checks for validity & display next page but if user click Back Buton of Browser it goes to Login PAge. It should not b like that because if agin user clic
-
Can One Library be used by 3 Macs?
Hi I have a Time Capsule on order which I am going to attach an additional 500GB HD to in order to hold all my tunes and movies etc, which I will be able to access remotely. However if I have one iTunes library, can 3 separate Macs use this library,
-
Oracle Forms6i Hai All I have a table named as Daily attend And the Fields are Intime DATE , Outime DATE... And i have created a form To update the data if the outtime is missing or insert records if both intime and outtime is missing I have created
-
This seems like a silly thing, but I have a VI with 2 graphs on the front, and when I go to change the scale on the Y axis (X is auto-scaled), I can't just type in the number and hit enter. I can type in the number and hit ctrl-enter, and I can type
-
Tranporting variant of a query
Hi all, Anyone is having a idea how to transport a variant of a query know variants are stored in TVARVC but I don't want to transport the entries or table want to transport variant stored in TVARVC. Regards, Nandini