Re: ** Another Challenge **
Posted in 1995
} } This one definitely got me for a second. } } Run this through your debugger and print 'c' in each case. Tell me } you would expect the second count(*) to print '2'. Wrong!! } } E-Mail if you want the answer. } } ---------------------------------------------------------------------------- } database fred } } define c smallint } } main } } begin work } } call create_temp_table() } insert into t_fred } values(1) } } select count(*) into c from t_fred } } call create_temp_table() } insert into t_fred } values(1) } insert into t_fred } values(1) } } select count(*) into c from t_fred } } commit work } } end main } ---------------------------------------------------------------------------- } function create_temp_table() } } whenever error continue } drop table t_audit ^^^^^^^^^^^^^^^^^^ ?????? } create temp table t_fred } ( } fred smallint } ) } whenever error stop } } end function # create_temp_table() } ---------------------------------------------------------------------------- } Looking at your program, it is quite obvious it will behave exactly as it is supposed to. The reason being, the function: create_temp_table contains "whenever error continue" which ignores the error message of table being recreated without dropping the existing table. As the prior table already exists, program will just keep inserting rows into it returning number of rows inserted, which is 3 rows in your case. -- Rgds, Chetan Anand -------------------------------------------------------------------------- DHL INTERNATIONAL (Singapore) Pte Ltd Singapore e-mail : anand@sin-co.sin-ro.dhl.com Thought:To climb steep hills requires slow pace at first - Shakespeare --------------------------------------------------------------------------