Solved

Appending VARCHAR to CLOB

Posted on 1999-01-29
4
3,472 Views
Last Modified: 2011-09-20
I'm writing a trigger which will, when a row is INSERTed, populate a field with a concatenation of four of the inserted fields.  Some fields are CLOBs and some are VARCHARs.  Appending CLOBs to each other is easy - DBMS_LOB.APPEND(), as is appending VARCHARs to each other - using ||.  But how do I append a VARCHAR to a CLOB?

DBMS_LOB.APPEND() throws all its toys on the floor and I can't find a suitable conversion function.
0
Comment
Question by:NukeEmUp
  • 3
4 Comments
 

Author Comment

by:NukeEmUp
ID: 1083900
Points increased to 75 as no answer in 24hrs.
0
 

Author Comment

by:NukeEmUp
ID: 1083901
Points increased to 200 cos this is getting urgent ;-)
0
 
LVL 6

Accepted Solution

by:
zebada earned 200 total points
ID: 1083902
If it is urgent then this answer may be a little late......
but anyway try this:
SQL> desc x
 Name                            Null?    Type
 ------------------------------- -------- ----
 KEY                                      VARCHAR2(8)
 DATA                                     CLOB

SQL> select * from x;

KEY      DATA
-------- -----------------------------------------------------------------------
---------
One      First

SQL> select dbms_lob.substr(data,dbms_lob.getlength(data)) || key from x;

DBMS_LOB.SUBSTR(DATA,DBMS_LOB.GETLENGTH(DATA))||KEY
--------------------------------------------------------------------------------
--------------------
FirstOne
0
 

Author Comment

by:NukeEmUp
ID: 1083903
You're right - it was too late.  To get the code finished on time I didn't bother with a trigger, just did the concatenation in perl before bunging the data into Oracle.  But now I know how it _should_ be done so I'll give you the points anyway ;-)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle -- identify blocking session 24 52
pl/sql - query very slow 26 61
Oracle - Query link database loop 8 39
Oracle collections 15 23
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question