× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Why, Mark?  The register is getting set properly.  As noted, the value in curSchema is the same as newSchema, suggesting the CURRENT_SCHEMA register is being set correctly.  It's just ignored for the CREATE TABLE.

On 8/20/2019 4:00 PM, Mark Waterbury wrote:
Joe,

This is just a hunch, but try "CURRENT SCHEMA" without the "_" ...  e.g.:

set :curSchema = CURRENT SCHEMA;

at least, according to the latest "Database Db2 for i SQL Reference"  rbafzpdf.pdf  -- in the IBM i 7.4 knowledge center ...?


Mark S. Waterbury

On Tuesday, August 20, 2019, 4:45:20 PM EDT, Joe Pluta <joepluta@xxxxxxxxxxxxxxxxx> wrote:
No, not so much.  SQL naming breaks everything (because it uses some
other default based on my user profile) and doesn't even check the
library list for my files.  So I'm stuck here.

At the end of the day, I can go back and change the current library as
Dave suggested (because that works fine), but I'd really like to
understand why it doesn't work as I expected.



On 8/20/2019 3:27 PM, Joe Pluta wrote:
Betcha it's something to do with system naming vs SQL naming, and
something I have to set on my options statement.  How much ya wanna bet?

On 8/20/2019 3:25 PM, Joe Pluta wrote:
Okay, this one has me scratching my head.

I've always used a prepared statement to create tables, but I wanted
to try using the current schema this time.  Basically I'm creating a
summary table for extract, and I wanted to it like this:

SET SCHEMA = :newSchema;
CREATE TABLE NEWTABLE AS (SELECT ...) WITH DATA;
SET SCHEMA = DEFAULT;

This seems pretty straightforward.  When I do it in STRSQL and
hardcode the library name, everything works fine.  But when I do this
in an embedded SQL program the file is always created in QGPL.

I went so far as to do this:

SET SCHEMA = :newSchema;
SET :curSchema = CURRENT_SCHEMA;
CREATE TABLE NEWTABLE AS (SELECT ...) WITH DATA;
SET SCHEMA = DEFAULT;

I thought maybe the current schema was getting reset somehow, but the
variable curSchema ends up with the same value as newSchema. But the
new table still ends up in QGPL.

Any idea what I'm missing?



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.