Solved

Appending VARCHAR to CLOB

Posted on 1999-01-29
4
3,456 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

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

932 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

10 Experts available now in Live!

Get 1:1 Help Now