RE: temp tables and serial columns
Posted in 2007
Topics: General Discussion
Art said:> I reprimand ANYONE here who writes SELECT * or INSERT INTO tablename VALUES > ... (ie without a column list). Such queries are doomed to blow up when the > schema has to be changed to add or drop a column ...> Point taken. I do list all columns in production code.It makes it clear what you were doing and avoids pitfalls later.For one-shot code that is trying to convert some data, it can take time you don't need to waste.But that does not answer the question: "Is there a practical use for a serial column in a temp table?"Perhaps there are times when you don't want to use a sequence generator and the serial could be useful?
Bill Hamilton wrote: > > > > > ------------------------------------------------------------------------ > Art said: > > I reprimand ANYONE here who writes SELECT * or INSERT INTO tablename > VALUES > > ... (ie without a column list). Such queries are doomed to blow up > when the > > schema has to be changed to add or drop a column ... > > > > Point taken. I do list all columns in production code. > It makes it clear what you were doing and avoids pitfalls later. > For one-shot code that is trying to convert some data, it can take time > you don't need to waste. > > But that does not answer the question: "Is there a practical use for a > serial column in a temp table?" > Perhaps there are times when you don't want to use a sequence generator > and the serial could be useful? My suggestion to use type casts does indeed answer your original question. Towit: Is there any relief for this issue in IDS 10 or IDS 11 ? Yes, use a type cast (or as John suggested, a VIEW with a typecast) to create the temp table with an INT column instead. Art S. Kagel
Bill Hamilton wrote: > But that does not answer the question: "Is there a practical use for a > serial column in a temp table?" > Perhaps there are times when you don't want to use a sequence generator > and the serial could be useful? For a long time, there were no sequences in IDS - just SERIAL columns. Yes, I regard a SERIAL column in a temp table as occasionally useful. It would be more useful if you were permitted to include ORDER BY with the SELECT statement that inserts data into the table - it would give you a simple numeric key that orders the data. I note that an explicit CREATE TEMP TABLE allows you to specify the types of the columns - and thereby avoid the SERIAL and replace it with INTEGER; OTOH, it also requires you to specify all the columns, and there were a number of solutions offered which required that. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/