开发者

DB2: Details: 42S22:[IBM][CLI Driver][DB2] SQL0206N {colname} is not valid in the context where it is used

I have a DB2 SQL query which I need to make part of a Crystal Reports file through an Add Command from within the Database Expert. My query goes as follows:

select "V_SIA_HIST_UTIL"."ID_HISTQ_UTILT_GIA"
        , "V_SIA_HIST_UTIL"."PRENM_UTILT_GIA"
        , "V_SIA_HIST_UTIL"."NM_UTILT_GIA"
        , "V_SIA_HIST_UTIL"."CD_UTILT_GIA"
        , "V_SIA_HIST_UTIL"."DH_DERNI_MODIF_UTILT_GIA"
        , "V_SIA_HIST_UTIL"."ID_HIST_UTILT_GIA_PAREN"
        , "pag"."nom_type"
        , "pag"."nom"
        , "pag"."description"
        , "pag"."nom_affiche"
        , "pag"."tri"
        , "pag"."id_utilisateur"
from "TEST"."V_SIA_HIST_UTIL"
    full outer join (
        select  "p"."nom_type"
                    , "p"."nom"
                    , "p"."description"
                    , "p"."nom_affiche"
                    , "p"."tri"
                    ,  "p"."id_utilisateur"
            from (
                select 'p' as "nom_type" 
                            , "V_SIA_HST_ROL_SECU"."NM_ROLE_SECUR_GIA" as "nom"
                            , CAST(NULL AS VARCHAR(128)) as "description"
                            , CAST(NULL AS VARCHAR(128)) as "nom_affiche"
                            , 0 as "tri"
                            , "V_SIA_JC_ROLS_UTIL"."ID_HISTQ_UTILT_GIA" as "id_utilisateur"
                    from "TEST"."V_SIA_HST_ROL_SECU"
                       inner join "TEST"."V_SIA_JC_ROLS_UTIL" on "V_SIA_JC_ROLS_UTIL"."ID_HISTQ_ROLE_SECUR_GIA" = "V_SIA_HST_ROL_SECU"."ID_HISTQ_ROLE_SECUR_GIA"
                union
                select 'a' as "nom_type"
                            , "V_SIA_HST_ASG_RESS"."NM_ASSGN_RESRC_GIA" as "nom"
                            , "V_SIA_HST_ASG_RESS"."DESCN_ASSGN_RESRC_GIA" as "description"
                            , "V_SIA_HST_ASG_RESS"."NM_AFFIC_ASSGN_GIA" as "nom_affiche"
                            , 1 as "tri"
                            , "V_SIA_JC_ASSG_UTIL"."ID_HISTQ_UTILT_GIA" as "id_utilisateur"
                    from "TEST"."V_SIA_HST_ASG_RESS"
                        inner join "TEST"."V_SIA_JC_ASSG_UTIL" on "V_SIA_JC_ASSG_UTIL"."ID_HIST_ASSGN_RESRC_GIA" = "V_SIA_HST_ASG_RESS"."ID_HIST_ASSGN_RESRC_GIA"
                union
                select 'g' as "nom_type"
                            , "V_SIA_HST_GRP_SECU"."NM_GROUP_SECUR_GIA" as "nom"
                            , CAST(NULL AS VARCHAR(128)) as "description"
                            , CAST(NULL AS VARCHAR(128)) as "nom_affiche"
                            , 2 as "tri"
                            , "V_SIA_JC_GRPS_UTIL"."ID_HISTQ_UTILT_GIA" as "id_utilisateur"
                    from "TEST"."V_SIA_HST_GRP_SECU"
                        inner join "TEST"."V_SIA_JC_GRPS_UTIL" on  "V_SIA_JC_GRPS_UTIL"."ID_HISTQ_GROUP_SECUR_GIA" = "V_SIA_HST_GRP_SECU"."ID_HISTQ_GROUP_SECUR_GIA"
            ) "p"
    ) "pag" on "pag"."id_utilisateur" = "V_SIA_HIST_UTIL"."ID_HISTQ_开发者_C百科UTILT_GIA"

Herewith the Crystal Reports error message I get from the Database Expert when it tries to verify the query against the underlying DB2 Data Center:

Failed to retrieve data from the database.

Details: 42S22:[IBM][CLI Driver][DB2] SQL0206N

"V_SIA_HST_ROL_SECU.NM_ROLE_SECUR_GIA" is not valid in the

context where it is used. SQLSTATE=42703

[Database Vendor Code: -206 ]

I forgot to mention that any of these suggested causes seems not to apply to my query.

DB2 SQL-Error: -206 SQLState: 42703

The same query runs just fine against SQL Server 2005.

Any clue as to how to solve this issue? This is my first experience with DB2, I even just installed the DB2 Data Center Client (DB2 Connect) this morning!

Thanks in advance to you all! =)


Prove the queries are identical on both platforms. 'diff' is your friend.

If they're identical, is that column actually in the table "TEST"."V_SIA_HST_ROL_SECU"? If it's not, that would cause the error.

The fact that the query works fine on another platform (or even just in another database) probably just means that there's something different between the two databases. The error here suggests it might be a difference in structure.

Then I'd try removing that column and the other "nom" columns. See what the query does without that column named in the error message. The idea is to simplify (shorten) the query one piece at a time until it works. (Or start with almost nothing and build up the query one piece at a time until it breaks.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜