Solved

Appending VARCHAR to CLOB

Posted on 1999-01-29
4
3,443 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
Comment Utility
Points increased to 75 as no answer in 24hrs.
0
 

Author Comment

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

Accepted Solution

by:
zebada earned 200 total points
Comment Utility
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
Comment Utility
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.

Join & Write a Comment

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.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now