Sorry, let me clarify, the INSERT...SELECT statement in this e-mail works
just fine. The $columnlist is built properly, and that is not a problem -
Maybe I confused the issue when I included it. I was just trying to expound
on what I was doing and maybe show to what extent I am trying to make the
scripts reusable.
The reason I need to bind columns is when I need to
scrub/convert/converge/split and/or print to file as intermediate steps. The
code I'm trying to make reusable is the part that selects this, and the
obstacle I run into is in building the bind_columns list without knowing at
the time I write the script how many columns are going to be returned by the
select statement. If I can just get the bind_columns built so that it works,
and this is reusable, then my scripting time is greatly reduced.
Sorry I was nor more clear on the first e-mail.
Steve Howard
-----Original Message-----
From: Steve Howard [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 07, 2001 9:16 PM
To: [EMAIL PROTECTED]
Subject: Reusable code for binding columns.
Does anyone have any ideas on how to make this work:
I write a lot of scripts to do migrations. I try to make as much of my code
reusable as possible. Straight table copies are no problem after I query the
system tables to get the table, and column names, and build something like:
INSERT INTO $ini->{targetdb}..$table ($columnlist) SELECT $columnlist FROM
$ini->{sourcedb}..$table
My problem comes with finding a way to build reusable code for a subroutine
to deal with tables that will not go straight across. The obstacle is in
this statement:
$row = $select->bind_columns(undef, \$column1, \$column2......
Again, I can get the column names by querying the system catalogs. I don't
necessarily have to bind them by anything resembling their column name, I
only need a way to reference them. So once I get the number of columns into
the script, how can I then assign variable, or hash key names so that I can
build a bind_columns statement that can work?
I may be just too close to this to see something obvious - whatever the
case, I would greatly appreciate any ideas that will help with this.
Thanks,
Steve Howard