title: DB2: Details: 42S22:[IBM][CLI Driver][DB2] SQL0206N {colname} is not valid in the context where it is used
body: <p>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:</p>
  
  <pre><code>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_UTILT_GIA"
  </code></pre>
  
  <p>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:</p>
  
  <blockquote>
    <p><strong>Failed to retrieve data from the database.<br>
    Details: 42S22:[IBM][CLI Driver][DB2] SQL0206N<br>
    "V_SIA_HST_ROL_SECU.NM_ROLE_SECUR_GIA" is not valid in the<br>
    context where it is used. SQLSTATE=42703<br>
    [Database Vendor Code: -206 ]</strong></p>
  </blockquote>
  
  <p>I forgot to mention that any of these suggested causes seems not to apply to my query.<br>
  <a href="http://www.sqlerror.de/db2_sql_error_-206_sqlstate_42703.html" rel="nofollow">DB2 SQL-Error: -206 SQLState: 42703</a></p>
  
  <p>The same query runs just fine against SQL Server 2005.</p>
  
  <p><strong>Any clue as to how to solve this issue?</strong> This is my first experience with DB2, I even just installed the DB2 Data Center Client (DB2 Connect) this morning!</p>
  
  <p>Thanks in advance to you all! =)</p>