Database link: Wrong column length from cursor

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dmitry Duginov

    Database link: Wrong column length from cursor

    Here's a problem

    --------------------------------------------
    set serveroutput on
    DECLARE
    CURSOR cur is select ed_no, length(ed_no) as len from
    listtext@pubdb. world; BEGIN
    for cur_rec in cur
    loop
    DBMS_OUTPUT.PUT _Line
    ('>'||cur_rec.e d_no||'<'||to_c har(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
    "@pubdb.wor ld" 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
  • Frank

    #2
    Re: Database link: Wrong column length from cursor

    Dmitry Duginov wrote:
    Here's a problem
    >
    --------------------------------------------
    set serveroutput on
    DECLARE
    CURSOR cur is select ed_no, length(ed_no) as len from
    listtext@pubdb. world; BEGIN
    for cur_rec in cur
    loop
    DBMS_OUTPUT.PUT _Line
    ('>'||cur_rec.e d_no||'<'||to_c har(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
    "@pubdb.wor ld" 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

    Comment

    Working...