views:

33

answers:

1

Hello all,

I am trying to create a sequence in oracle sql, using the "minvalue" as the result of a select query.

The select query I'm trying to run is:

SELECT
      MAX(customer_id) + 1
FROM
      customer

I know it's easy with an anonymous pl/sql, but I'd like to find a way which doesn't use pl/sql. Some ideas I've had include the COLUMN command to set a substitution variable, but I'm a little lost as to how to do that.

Thanks in advance!

+3  A: 

Like this:

column startval new_value v_startval

SELECT
      MAX(customer_id) + 1
FROM
      customer;

create sequence customer_seq start with &v_startval.;
Tony Andrews
Similar to what I'd been trying, and after some playing about with syntax it suddenly worked where it didn't before. Thanks.
Nellius