Question: I can't for the life of me find out to get the behavior I want:

> 
> old:insert into build\_pc
>  values (&&buildA, 35,40,32,29,26,22,22,null,13,11,7,1,999)
>  new:insert into build\_pc
>  values (build\_id\_seq.nextval, 35,40,32,29,26,22,22,null,13,11,7,1,999)
>  1 rows inserted.
> 
> 
> 

As part of an SQL transaction I'm trying to save a variable, moreover an integer ID number, so that it can be entered in a few places across the transaction. The problem is SQLDev is being too clever and converting back to he nextval function each time instead of just storing an int. 

Google says use set, but that throws this:

> 
> SQLPLUS Command Skipped: set buildA = build\_id\_seq.nextval
> 
> 
>

Answer: 
As I understand, you want to use a bind variable in SQL Plus. Please, try this:

```
variable buildA NUMBER;
exec select build_id_seq.nextval into :buildA from dual;
insert into build_pc values (:buildA, 35,40,32,29,26,22,22,null,13,11,7,1,999);

```

If you use 11g you do not need to SELECT the value of sequence, you can use:

```
variable buildA NUMBER;
exec :buildA := build_id_seq.nextval;
insert into build_pc values (:buildA, 35,40,32,29,26,22,22,null,13,11,7,1,999);

```

Hope this helps!
You should be using define rather than set for a substitution variable:

```
define buildA = build_id_seq.nextval

```

... but it will be substituted verbatim wherever you reference `&buildA`, incrementing the sequence each time.

You could use a bind variable or the [new\_value](http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve013.htm#sthref1333) syntax, but you probably just want to refer to `build_id_seq.nextval` the first time you use it, and `build_id_seq.currval` on all the subsequent references, rather than trying to store it yourself.

As [the documentation says](http://docs.oracle.com/cd/E11882_01/server.112/e41084/pseudocolumns002.htm):

> 
> * CURRVAL: Returns the current value of a sequence
> * NEXTVAL: Increments the sequence and returns the next value
> 
> 
> 

So when you call nextval the sequence is incremented, and subsequent calls to currval in the same session get the same value, without incrementing again.

This is useful for creating parent/child records, for example, where you use nextval to create the primary key value and then currval to use the same value as a foreign key in child records.