RE: how do I concatenate a string in PL/SQL?

  • From: "Bobak, Mark" <Mark.Bobak@xxxxxxxxxxxxxxx>
  • To: <roger_xu@xxxxxxxxxxx>, "Jared Still" <jkstill@xxxxxxxxx>
  • Date: Wed, 8 Feb 2006 17:20:26 -0500

Roger,
 
We can't help if you don't give us enough info.
 
:= is NOT just for numeric value.  || is the correct concatentation
operator.
 
Here is my proof:
 
SQL> set serveroutput on
SQL> declare
  2  a_strng varchar2(5);
  3  b_strng varchar2(5);
  4  c_strng varchar2(10);
  5  begin
  6  a_strng := 'Hello';
  7  b_strng := 'World';
  8  c_strng := a_strng || b_strng;
  9  dbms_output.put_line(c_strng);
 10  end;
 11  /
HelloWorld
 
PL/SQL procedure successfully completed.
 
SQL> select * from v$version;
 
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE    9.2.0.6.0       Production
TNS for Solaris: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production

 
Now, show us your (complete) test case.
 
-Mark
 

-- 
Mark J. Bobak 
Senior Oracle Architect 
ProQuest Information & Learning 

"There are 10 types of people in the world:  Those who understand
binary, and those who don't." 

 

________________________________

From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Roger Xu
Sent: Wednesday, February 08, 2006 5:01 PM
To: Jared Still
Cc: Oracle-L@Freelists. Org (E-mail)
Subject: RE: how do I concatenate a string in PL/SQL?


Nothing wrong with the cursor, the only problem is: "a_strng := a_ATWRT
|| a_strng;"
 
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 97
 
everything else works fine if I comment out "a_strng := a_ATWRT ||
a_strng;"
 
Again, the question is "How do I concatenate a string?" I guess := is
for numeric value only?
 
Thanks,
 
Roger

        -----Original Message-----
        From: Jared Still [mailto:jkstill@xxxxxxxxx]
        Sent: Wednesday, February 08, 2006 3:17 PM
        To: Roger Xu
        Cc: Oracle-L@Freelists. Org (E-mail)
        Subject: Re: how do I concatenate a string in PL/SQL?
        
        
        It is hard to help when we don't know what the errors are.
        
        Try posting a working example that duplicates the error.
        
        
        
        On 2/8/06, Roger Xu < roger_xu@xxxxxxxxxxx
<mailto:roger_xu@xxxxxxxxxxx> > wrote: 

                I am a PL/SQL newbie and the following gives me errors
while executing.
                 
                a_strng := NULL;
                open b_cursor;
                loop
                    fetch b_cursor into a_ATWRT;
                    a_strng := a_ATWRT || a_strng;
                    exit when b_cursor%NOTFOUND;
                end loop;
                close b_cursor;
                 
                Thanks,
                 
                Roger

                This e-mail is intended solely for the person or entity
to which it is addressed and may contain confidential and/or privileged
information. Any review, dissemination, copying, printing or other use
of this e-mail by persons or entities other than the addressee is
prohibited. If you have received this e-mail in error, please contact
the sender immediately and delete the material. 
        
____________________________________________________________________
                This email has been scanned for all viruses by the
MessageLabs Email Security System. Any questions please call
972-721-8257 or email your request to tech_support@xxxxxxxxxxxx
                




        -- 
        Jared Still
        Certifiable Oracle DBA and Part Time Perl Evangelist
        
        For technical support please email tech_support@xxxxxxxxxxx or
you can
        call (972)721-8257. 
        This email has been scanned for all viruses by the MessageLabs
Email Security System.
        


This e-mail is intended solely for the person or entity to which it is
addressed and may contain confidential and/or privileged information.
Any review, dissemination, copying, printing or other use of this e-mail
by persons or entities other than the addressee is prohibited. If you
have received this e-mail in error, please contact the sender
immediately and delete the material. 
____________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. Any questions please call 972-721-8257 or email your
request to tech_support@xxxxxxxxxxxx

BEGIN:VCARD
VERSION:2.1
N:Bobak;Mark
FN:Bobak, Mark
ORG:ProQuest Information and Learning;Database Group
TITLE:Software Architect, Sr-TPD
TEL;WORK;VOICE:734.975.6086
ADR;WORK:;ECC4-N01E04;1400 Eisenhower Parkway
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:ECC4-N01E04=0D=0A1400 Eisenhower Parkway
EMAIL;PREF;INTERNET:Mark.Bobak@xxxxxxxxxxxxxxx
REV:20051213T223654Z
END:VCARD

Other related posts: