help!!! replacing nulls with a deafult value on a blob field

  • hi!

    i am trying to use coalesce to return a blob field, and if it is null, it must replace the null with a default value.

    e.g. coalesce(blob1,' '), this should bring the blob field as it is or put blanks in the field, when a null value is returned.

    this is not working, as it seems that i can not use coalesce with blob field.

    i also tried 'ifnull', and it did not help.

    do you know how i can handle this?

    Dineo.

  • sorry i did not make my self clear enough.

    I use embeded sql in an RPG program and RPG can not handle blobs unless i sql.

    I need to insert records from one table to another.

    e.g, assuming C is a blob field with possible null.

    insert into Table1 (a,b,c)

    (select a,b,coalesce(c, ' ') from Table2)

  • Try this.

    insert into Table1 (a,b,c)

    (select a,b,

    CASE c WHEN NULL THEN ' ' ELSE c END

    from Table2)

  • sorry, i had some typo there. but rpg does not recgnise isnull.

    check my code now.

    C/Exec SQL

    c+ insert into ibauthar

    c+ (autable,aurfn1,autype,aucycle,auauthreq,auusrfn,audate,autxtran,

    c+ aucethumb,ausign,auisasig,auusdid,auusfname,auusidno)

    c+ (select

    c+ autable,aurfn1,autype,aucycle,auauthreq,auusrfn,audate,autxtran,

    c+ coalesce(aucethumb,' '), (case ausign

    c+ when isnull then ' ' else ausign end),

    c+ auisasig,auusdid,auusfname,auusidno

    c+ from ibauthpf WHERE AUTABLE = 'KB' and AURFN1 = :KBRFN )

    C/End-Exec

  • it seems RPG does not recognise isnull or null at all. check my code.

    C/Exec SQL

    c+ insert into ibauthar

    c+ (autable,aurfn1,autype,aucycle,auauthreq,auusrfn,audate,autxtran,

    c+ aucethumb,ausign,auisasig,auusdid,auusfname,auusidno)

    c+ (select

    c+ autable,aurfn1,autype,aucycle,auauthreq,auusrfn,audate,autxtran,

    c+ coalesce(aucethumb,' '), (case ausign

    c+ when isnull then ' ' else ausign end),

    c+ auisasig,auusdid,auusfname,auusidno

    c+ from ibauthpf WHERE AUTABLE = 'KB' and AURFN1 = :KBRFN )

    C/End-Exec

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply