I got quite large xml saved in BLOB and I need to edit value its value.
I'm trying following
UPDATE MY_TABLE
SET MY_BLOB=REPLACE(CONVERT(MY_BLOB USING UTF8), 'oldValue', 'newValue')
WHERE MY_ID = 'someID'
Still, I keep getting SQL Error: ORA-00907: missing right parenthesis
but srsly, where do I miss something?
CONVERT needs a least two input parameters and is not for BLOB
Documentation
Here is useful information about update a text in BLOB column.
You can consider converting blob to clob and then calling replace function on it. Some useful info: http://fazlansabar.blogspot.com/2012/03/replace-function-for-blob-fields-in.html
Related
Using PGSQL, I had query error like
invalid byte sequence for encoding "UTF8": 0xea 0x3c 0x68
when I was just using SELECT statements.
SELECT id, data, test FROM t_example WHERE id = 'hello';
-- Error!
And I have found that the query goes well without the 'data' column.
SELECT id, test FROM t_example WHERE id = 'hello';
-- Works well...
So it seems the cause of the error probably is on the data column. I want to check or view what kind of text is inside the data column, but it seems I cant take it because the SELECT query itself is not working here because of the encoding problem...
Is there anyway I can check the data inside without encoding or whatever please.
But the thing is that I don't want to do dumping or migration because the database is too huge to do that. Please let me know if there is something easy and fast way to solve this problem.
Thank you
I'm trying to resize a column down to 64 characters in length:
ALTER TABLE [dbo].[consumption]
ALTER COLUMN [resourceGroup] VARCHAR(64) NOT NULL
but I get the following error:
String or binary data would be truncated in table 'dbo.consumption', column 'resourceGroup'. Truncated value: ''.
This doesn't make sense to me: how can you truncate nothing?
Any help would be appreciated.
Thanks to comments by #MartinSmith and #DaleK, I think I've come to the answer on this one.
The documentation provided with the data source I'm writing to this column stated that it should not be longer than 64 characters. Then, when I tried changing the length of the column, the error message led me to believe that SQL Server was issuing an error over an empty string. According to #MartinSmith, this type of error message is a recent development and so the offending value probably hasn't been injected into it yet for ALTER TABLE commands. Moreover, queries against the column reveal that it does contain values longer than 64 characters.
Therefore, this error message should be taken at its meaning and the truncation value ignored.
I am trying to update a column of long raw datatype and later append the value. Is it possible? I have tried || already but not working.
Update acert SET atrt= 'ddddd'
update acert SET atrt = atrt || 'updated value'
Error :
ORA-00932- expected char got binary
I want something like above work.
Also, I cannot use any DDL queries to temporarily alter the table. Is there any other way I could do this?
To manipulate a LONG RAW you pretty much need an external interface (C, Java, etc).
There is not anything natively in SQL or PLSQL that will do it, hence the preference to use CLOB and BLOB.
I have been working with Oracle XML DB of version 11gR2. I have created a XML table with column as XMLType(Binary XMLType).
Question 1:
When I insert a XML document, all the single quotes in the attributes list gets converted to double quotes automatically. How can I get rid of this? Because I have to reprocess the entire XML document when I have to fetch it.
Question 2:
When I tried to retrieve I have used function getclobval(). This is working well with SQLPLUS and SQL Developer. However when I run this query through OCI, I am getting the error "ORA-00911: invalid character"
Can anyone help me on the above two questions?
Q1:
Have a look on Oracle support at bug 9871299: LOSS OF UNESCAPING WITH XMLTABLE
This bug was introduced in 11.2.0.1.
I have the following situation,
in my database table I have a column for storing xml data. When I try to insert data into this table by using Insert query, I am getting string is too large exception.
I tried keeping the type as XML and VACHAR(32000), I get the same exception.
Can anyone help me with this?
UPDATE
This is the error I am getting while inserting.
The string constant beginning with "'<!--Sample XML file generated by XMLSpy v2013 sp1 (http://www.altova." is too long.. SQLCODE=-102, SQLSTATE=54002, DRIVER=3.59.81
The XMLPARSE function is useful for converting text strings into DB2's XML data type. Have you tried wrapping your XML text with a call to XMLPARSE?
If your XML document is in a file, there's a UDF you can add that makes it easier to pull the file contents directly into an XML column.
you can set the size of each column in your table. Try changing the default size(which is not max size) to an appropriate one.
Also when you try to query directly using SQL command line, the DBMS has to create a large string constant form its string pool that can hold your XML(which in this case, is very large and hence String cannot be created). If you query the same programmatically though, it works.
If the same error persists or if DBMS throws Data Integrity error, then try changing the data structure to a bigger one like CLOB(most likely in this case) or BLOB(in case of images and multi media).
It's a bit silly but the answer is use the XMLPARSE and segment your XML string in 32K chunks and prepend a CLOB statement to override the string size limitation
XMLPARSE ( DOCUMENT
CLOB('<?xml version="1.0"?>') ||
'<aLotOfVeryBigXmlData32kPart1 ......
' ||
'<aLotOfVeryBigXmlData32kPart2 ......
' ||
... etc ...
'<aLotOfVeryBigXmlData32kPartN ......
' )