Re: Urgent help with dynamic tablenames

From: Roland Schaar <rschaar_at_gosch.com>
Date: Tue, 20 Jul 1999 22:47:23 +0200
Message-ID: <3794E05B.E54E5B83_at_gosch.com>


What is the reason why you want to create a separate table for each user. Can't you add a column like user_id oder session_id to the column and then use the same table for all users?

roland
Gosch Consulting GmbH

shockerman_at_my-deja.com wrote:

> I'm using Oracle 7.3 I'm going to have people using this program
> simultaneously on the web so every time they run the program, I need
> to
> create a unique table for them or unique pseudo-table, whatever. I
> thought of using the userenv('sessionid') from dual and then doing a
> command like this. It ends up making a table name called
> sorted_sessionid. Pro*C won't let me do
> create table sorted_:sessionid which would make my life so much
> easier.
>
> int main(){
> ..
> EXEC SQL select userenv('sessionid') into :sessionid from dual;
> maketable(sessionid);
> ..
> return 0; }
>
> void maketable(long int sessionid, lots of other variables) {
> sprintf(buffer, "create table temp_sorted_%d "
> "(rid number,"
> "pid number,"
> "ddate date);", sessionid);
> sql(buffer);
>
> do {c = fscanf(fp1, "%s %d %s %d %s %s %s %s %s\n", string1, &rid,
> string2, &pid, string3, date, time, ip1, ip2);
>
> sprintf(buffer, "INSERT INTO sorted_%d (rid, pid, ddate)" "VALUES
> (:rid,"
> ":pid,"
> "TO_DATE(:date, 'MM/DD/RR'));",
> sessionid);
> sql(buffer);
> }
> while (c != EOF);
> }
>
> void sql(char *_comm) {
> EXEC SQL BEGIN DECLARE SECTION;
> char *comm = _comm;
> EXEC SQL END DECLARE SECTION;
> EXEC SQL EXECUTE IMMEDIATE :comm;
> EXEC SQL commit work;
> }
>
> The problem is, after this. I have to query it and use variables that
> I
> get from this so I'm getting confused with where I need to declare
> variables and its getting extremely annoying. Does anyone know of an
> easier way that I could accomplish this task?
> Please help.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Tue Jul 20 1999 - 22:47:23 CEST

Original text of this message