Re: Is there a better way to prepare an Insert?
Posted in 1998
I guess this is what I really should do...however I'm embarassed to say how many columns this table has (not that I had anything to do with that, so I'll tell you. 172). Anyway, I also thought this one up after I posted....I could dynamically build my prepare by doing a select count(*) on syscolumns for that table....Still, it almost seems easier to let the thing break and fix it when it does, but that's the wrong thing to do. Thanks Dieter Winkler wrote: > To avoid big problems in the case of adding new column to the table try this > one: > > "INSERT INTO <tablename> (<col1>,<col2,<col3>) VALUES (?,?,?)" > > Daniel Wright schrieb in Nachricht ... > >Unless I'm missing something, you have to include a question mark for > >every field in the table > >(e.g. "INSERT INTO <table_name> VALUES (?, ?, ?, ?, ?)" in order to put > >the SQL statement into a string in order > > to prepare it.). > > > >I would like to avoid this...the big reason for wanting to avoid this is > >that, if we add (or drop one) a column to the table, the > >program with this PREPARE will be broken. (The other, related reason, > >is that it is a pain to have to make the number of > >question marks equal to the number of fields.). > > > >Any help would be greatly appreciated. > > > >Thanks, > >Dan > > > >If replying by e-mail, use "danwright AT bigfoot.com" (yes, you replace > >the " AT ", with "@"...just an attempt to slow the spam.) > >