Note that there are some explanatory texts on larger screens.

plurals
  1. POThe riddle of the working broken query
    text
    copied!<p>I was going through some old code that was written in years past by another developer at my organization. Whilst trying to improve this code, I discovered that the query it uses had a very bad problem. </p> <pre><code> OdbcDataAdapter financialAidDocsQuery = new OdbcDataAdapter( @"SELECT a.RRRAREQ_TREQ_CODE, b.RTVTREQ_SHORT_DESC, a.RRRAREQ_TRST_DESC, RRRAREQ_STAT_DATE, RRRAREQ_EST_DATE, a.RRRAREQ_SAT_IND, a.RRRAREQ_SBGI_CODE, b.RTVTREQ_PERK_MPN_FLAG, b.RTVTREQ_PCKG_IND, a.RRRAREQ_MEMO_IND, a.RRRAREQ_TRK_LTR_IND, a.RRRAREQ_DISB_IND, a.RRRAREQ_FUND_CODE, a.RRRAREQ_SYS_IND FROM FAISMGR.RRRAREQ a, FAISMGR.RTVTREQ b WHERE a.RRRAREQ_TREQ_CODE = b.RTVTREQ_CODE and a.RRRAREQ_PIDM = :PIDM AND a.RRRAREQ_AIDY_CODE = :AidYear ", this.bannerOracle); financialAidDocsQuery.SelectCommand.Parameters.Add(":PIDM", OdbcType.Int, 32).Value = this.pidm; financialAidDocsQuery.SelectCommand.Parameters.Add(":AidYear", OdbcType.Int, 32).Value = this.aidYear; DataTable financialAidDocsResults = new DataTable(); financialAidDocsQuery.Fill(financialAidDocsResults); FADocsGridView.DataSource = financialAidDocsResults; FADocsGridView.DataBind(); </code></pre> <p>The problem is that the column <code>a.RRRAREQ_TRST_DESC</code> does not exist. A fact you learn very quickly when running it in Oracle SQL Developer. </p> <p>The strange thing? </p> <p>This code works. </p> <p>The gridview binds successfully. (It doesn't try to bind to that field.) And it's been in production for years. </p> <p>So, my question is...why? I've never seen a bad query work. I've never seen Oracle allow it or a data provider hack around it. </p> <p>Does anyone have any idea what's going on here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload