db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta Satoor" <msat...@gmail.com>
Subject Re: some comments on collation wiki page
Date Tue, 03 Apr 2007 18:13:48 GMT
Army, riding on the CAST wagon a little bit more, a user can rewrite the
query as follows and then it won't matter in what schema the query is
getting run.
   PreparedStatement ps = conn.prepareStatement(
       "select tablename, tabletype from sys.systables where " +
       "CAST (tablename as varchar(128)) = CAST(? as varchar(128))");

So, we can define the ? to take the character set of the schema where the
statement is getting prepared. And user can use CAST to make the collation
work the way they desire.

Does that sound good?
Mamta


On 4/3/07, Mamta Satoor <msatoor@gmail.com> wrote:
>
> I was leaning towards using the current schema at the prepared time
> because I am hoping to do all the collation validation at the compile phase
> rather than the execute phase. Picking up the schema at the prepared time
> will help me enable that.
>
> Let me look at your following mail a little bit more to see if I need to
> change my mind :)
>
> Mamta
>
>
> On 4/3/07, Army <qozinx@gmail.com> wrote:
> >
> > Army wrote:
> > >
> > > Since a parameter maker does not have a "defined" schema, does
> > "current
> > > schema" mean the schema when the statement is prepared, or the schema
> > > when it is executed?
> > >
> > > For example I can do the following in JDBC:
> > >
> > > // Default schema ("APP").
> > >
> > > PreparedStatement ps = conn.prepareStatement(
> > >   "select tablename, tabletype from sys.systables where tablename =
> > ?");
> >
> > <snip>
> >
> > > If "current schema" means the "schema when the statement is
> > *prepared*"
> > > then both of the above statements would fail (because there's no CAST
> > on
> > > the syscol). That consistency would probably be a good thing (less
> > > confusing for users).
> >
> > On the other hand, if the statement is changed to:
> >
> >    // Default schema APP.
> >
> >    PreparedStatement ps = conn.prepareStatement(
> >        "select tablename, tabletype from sys.systables where " +
> >        "CAST (tablename as varchar(128)) = ?");
> >
> > then it might be better to take "current schema" to mean the time of
> > *execution.*  That way the the above statement will run correctly
> > regardless of
> > the current schema.  If "current schema" was determined at compile time,
> > the
> > above statement would only work if "current schema" was a non-system
> > schema.
> >
> > Since I think we are going to encourage users to CAST system columns
> > when doing
> > comparisons (at least that's what I gathered from the various discussion
> >
> > threads), maybe it would be better to take the "current schema" for a
> > parameter
> > marker at execution time, after all...?
> >
> > Army
> >
> >
>

Mime
View raw message