Re: Database link: Wrong column length from cursor

From: Frank <fbortel_at_nescape.net>
Date: Tue, 16 Dec 2003 21:54:20 +0100
Message-ID: <brnqt0$9jj$1_at_news4.tilbu1.nb.home.nl>


Dmitry Duginov wrote:
> Here's a problem
>
> --------------------------------------------
> set serveroutput on
> DECLARE
> CURSOR cur is select ed_no, length(ed_no) as len from
> listtext_at_pubdb.world; BEGIN
> for cur_rec in cur
> loop
> DBMS_OUTPUT.PUT_Line
> ('>'||cur_rec.ed_no||'<'||to_char(cur_rec.len) );
> end loop;
> end;
> /
> -------------------------------------------
>
> this returns
>
>

>>ABC      <3
>>XYZ      <3

>
> ...
>
> i.e. result has correct value plus six trailing spaces
>
> Column ed_no is CHAR(3)
>
> I have the same problem with all CHAR columns in all tables. The
> column length is tripled and trailing spaces added if I define the
> cursor through the database link.
>
> However, if I login to that database directly and get rid of
> "_at_pubdb.world" in cursor definition, everything works fine and the
> code returns
>
>
>>ABC<3
>>XYZ<3

>
> ...
>
> Any comments, suggestions, workarounds, please... This bug (I believe
> it's a bug) gonna ruin a month of my work :(((
>
> I NEED the database link and I cannot employ RTRIM() everywhere.
>
> Regards,
> Dmitry

Could it be someone is concatenating empty fields? If the programmer is believing these are varchars, concatenating not initialized (NULL) fields make no difference. CHAR fields start off with 3 spaces. CHAR(3)||CHAR(3)||CHAR(3) yields 9 characters

-- 
Regards, Frank van Bortel
Received on Tue Dec 16 2003 - 21:54:20 CET

Original text of this message