Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Mysterious query

Re: Mysterious query

From: Peter Michelson <pete77r_at_hotmail.com>
Date: Tue, 04 Mar 2003 22:36:56 GMT
Message-ID: <cU99a.75439$_J5.23658@nwrddc01.gnilink.net>


Thank you for your helpful reply. Please see my inline comments...

"Billy Verreynne" <vslabs_at_onwe.co.za> wrote in message news:b429us$5m0$1_at_ctb-nnrp2.saix.net...
>
> > -----Original Message-----
> > Peter Michelson [mailto:pete77r_at_hotmail.com]
>
> >
> > Here's a poser: I have a Delphi 6 Enterprise app using the BDE to
> > connect to
> > Oracle 8.1.7.3. I've been getting sporadic "Ambiguous Column Name"
> > errors
> > from Oracle. When I ran SQL Trace it revealed an impossible query:
> > somehow, a query which contains all fields from all of my database
> > tables was being processed. This query even contains fields from tables
> > in the database which aren't being used in the Delphi application.
>
> What Delphi class do you use? TQuery, TTable or something else?
>

I use both TTable and TQuery.

> If TQuery, the problem could be with the SQL property that contains the
SQL
> command. The SQL property is a TStringList or TStrings class (former a
> subclass of the latter). There's a problem with the way that class deals
> with its properties called, LINES (mutltiple lines with controlfeeds) and
> TEXT (a single string containing all lines).
>
> The problem arise when you use the Lines property to add a SQL statement.
> The TQuery class sends the Text property to OCI - which then contains
> linefeed chars.. which in turns messes Oracle around as that linefeed can
> be slap bang in the middle of a table name or column name.

I understand the issue you described regarding the control characters (e.g., linefeeds) getting sent to Oracle in the middle of a query. However, it isn't clear to me why this would result in a megaquery containing all fields from all tables in the database. I would think if a tablename were split, then Oracle would return an error message along the lines of "column unrecognized" or "malformed query".

Also the behavior is sporadic. Most of the time, the TQuery and TTable components work fine. However, if the behavior occurs once, then it seems to continue occurring deterministically.

>
> If TTable, then you will get _all_ the columns for that table. I recommend
> not using it as clients should deal with sub sets of data and not whole
> tables.. i.e. with TQuery and SELECTs.
>

The "mega-query" doesn't just return all columns for one table, but rather it selects all columns in all tables. I am only using TTables to edit tables because that is programmatically easier than building and executing an UPDATE sql string.

> If you like, throw the .pas unit file (plus the associated .dfm file) with
> the offending code my way via direct e-mail and I will take a look at the
> code.
>

Perhaps I will. Thank you for the generous offer. In the meantime, I am interested in your reply to my comments.

Thanks again,
Peter

> --
> Billy
Received on Tue Mar 04 2003 - 16:36:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US