Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> An easier way to write this SQL

An easier way to write this SQL

From: Juan Carlos <jc_va_at_hotmail.com>
Date: Wed, 28 Jul 1999 20:19:07 -0700
Message-ID: <7no6m7$a31$1@bgtnsc03.worldnet.att.net>


We have a table containing an Employee ID in the format 'E00000001'. It is monotonically incremented. I want to write a SQL statement to get the next available number .e.g 'E00000002'. We can't use a sequence for reasons I won't bore you with. The following works, but is there a more elegant way to write it?

SELECT 'E' || LPAD(MAX(TO_NUMBER(SUBSTR(EXTERNAL_ID,2,9))+1),9,'0') FROM EXTID Received on Wed Jul 28 1999 - 22:19:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US