BibleGateway.com Verse Of The Day


“ Now Jesus was going up to Jerusalem. On the way, he took the Twelve aside and said to them, “We are going up to Jerusalem, and the Son of Man will be delivered over to the chief priests and the teachers of the law. They will condemn him to death and will hand him over to the Gentiles to be mocked and flogged and crucified. On the third day he will be raised to life!”” (Matthew 20: 17-19)  listen to chapter  (Read by Max McLean. Provided by The Listener's Audio Bible.)

Powered by BibleGateway.com

Friday, February 03, 2006

Re-Synching Oracle Sequence With PL/SQL

Sometimes an Oracle Sequence can get out of sync. For instance, if a sequence gets dropped or wraps around to zero while there is data in the table, or if data is loaded while the sequence is disabled. Here is a quick PL/SQL block to reset the sequence to 1 more than the max id in the data.

Replace column_name, table_name, sequence_name below and then run it.



declare
max_id number;
tmp number;
begin
max_id := 0;
select max(column_name) into max_id from table_name;
if max_id > 0 then
for i in 1..max_id loop
select sequence_name.nextval into tmp from dual;
exit when tmp > max_id;
end loop;
end if;
end;
/

No comments: