Re: Dynamic Table Names in Dynamic SQL
From: John Gillespie <jgillespie>
Date: 1995/09/20
Message-ID: <43pfj3$gvl_at_sndsu1.sedalia.sinet.slb.com>#1/1
Date: 1995/09/20
Message-ID: <43pfj3$gvl_at_sndsu1.sedalia.sinet.slb.com>#1/1
On getting table names to be dynamic:
We do this ALL the time:
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR string[2000];
int a;
VARCHAR b[128];
EXEC SQL END DECLARE SECTION;
string.len = sprintf(string.arr,"SELECT ABC FROM %s.DEF where GHI = :x1",
account);
EXEC SQL PREPARE S1 FROM :string;
EXEC SQL DECLARE C1 CURSOR FOR S1;
EXEC SQL OPEN C1 USING :a;
EXEC SQL FETCH C1 INTO :b;
EXEC SQL CLOSE C1;
And, you know what, there is NO difference in performance, since the
precompiler generates (almost) identical calls...
In fact, with a few if statements to prevent unnecessary reparsing, this way can be even faster... Received on Wed Sep 20 1995 - 00:00:00 CEST