Army 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

I think that all bind-time decisions need to be resolved the same way. Otherwise the behavior of our sql interpreter will be very hard to explain. A similar issue comes up with the following statement:

 PreparedStatement ps = conn.prepareStatement( "select * from T" );

T could resolve to a different table depending on what your current schema is. What happens if this statement is prepared in one schema, then the user changes schema, then the user executes the prepared statement?

Regards,
-Rick

Reply via email to