473,498 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Return sequence number from Oracle

People,
someone help me please.

I have a webapplication, and i store the statements in xml
file. Then, when i need then i took at the file.
In one method of mine i have to add a record at the table
and return to my application the number of sequence that
was created. The database is in oracle. I know that if i
do this (in Sql Server) it works:
insert into ....
select @@identity
and execute the command with cmd.executesacalar.
But in oracle don't work.
Any idea? I can't use stored procedures at databse.

Steven Alexander
Brazil
Nov 17 '05 #1
6 3171

"Steven David" <st****@amazoncorp.com.br> wrote in message
news:00****************************@phx.gbl...
People,
someone help me please.

I have a webapplication, and i store the statements in xml
file. Then, when i need then i took at the file.
In one method of mine i have to add a record at the table
and return to my application the number of sequence that
was created. The database is in oracle. I know that if i
do this (in Sql Server) it works:
insert into ....
select @@identity
and execute the command with cmd.executesacalar.
But in oracle don't work.
Any idea?

select some_sequence.curval from dual

Does this in Oracle.
The only difference is that you need to know the name of the sequence.

David
Nov 17 '05 #2

"Steven David" <st****@amazoncorp.com.br> wrote in message
news:00****************************@phx.gbl...
People,
someone help me please.

I have a webapplication, and i store the statements in xml
file. Then, when i need then i took at the file.
In one method of mine i have to add a record at the table
and return to my application the number of sequence that
was created. The database is in oracle. I know that if i
do this (in Sql Server) it works:
insert into ....
select @@identity
and execute the command with cmd.executesacalar.
But in oracle don't work.
Any idea?

select some_sequence.curval from dual

Does this in Oracle.
The only difference is that you need to know the name of the sequence.

David
Nov 17 '05 #3

"Steven Alexander" <st****@amazoncorp.com.br> wrote in message
news:02****************************@phx.gbl...
Correct, i treid this. But the error
ORA-06550: line 10, column 1: PLS-00428: an INTO clause
is expected in this SELECT statement
appears

Here is my block that i execute
declare id number;
BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select SEQ_PERFIL.currval from DUAL;
END;


That's another problem entirely.

A select without INTO is illegal in PL\SQL. (OK in SQL, not OK in PL\SQL).

Change your batch to select it into a variable and retrieve it with a bind
variable, or open a ref cursor on it, or issue
select SEQ_PERFIL.currval from DUAL
in a seperate command.

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select :new_seq := SEQ_PERFIL.currval from DUAL;
END;

or

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
open :rc for select SEQ_PERFIL.currval from DUAL;
END;

or

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
END;

followed by

select SEQ_PERFIL.currval from DUAL;

David
Nov 17 '05 #4

"Steven Alexander" <st****@amazoncorp.com.br> wrote in message
news:02****************************@phx.gbl...
Correct, i treid this. But the error
ORA-06550: line 10, column 1: PLS-00428: an INTO clause
is expected in this SELECT statement
appears

Here is my block that i execute
declare id number;
BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select SEQ_PERFIL.currval from DUAL;
END;


That's another problem entirely.

A select without INTO is illegal in PL\SQL. (OK in SQL, not OK in PL\SQL).

Change your batch to select it into a variable and retrieve it with a bind
variable, or open a ref cursor on it, or issue
select SEQ_PERFIL.currval from DUAL
in a seperate command.

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select :new_seq := SEQ_PERFIL.currval from DUAL;
END;

or

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
open :rc for select SEQ_PERFIL.currval from DUAL;
END;

or

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
END;

followed by

select SEQ_PERFIL.currval from DUAL;

David
Nov 17 '05 #5
oops

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select :new_seq := SEQ_PERFIL.currval from DUAL;
END;

Should be

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select SEQ_PERFIL.currval into :new_seq from DUAL;
END;
David
Nov 17 '05 #6
oops

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select :new_seq := SEQ_PERFIL.currval from DUAL;
END;

Should be

BEGIN
select SEQ_PERFIL.nextval into id from DUAL;
insert into per_perfil
(per_codigo, per_nome, per_descricao,
per_dt_criacao, per_emaillicenca, sft_codigo)
values
(id,:PER_NOME,:PER_DESCRICAO,sysdate,:PER_EMAILLIC ENCA,:SFT
_CODIGO);
select SEQ_PERFIL.currval into :new_seq from DUAL;
END;
David
Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
29493
by: Steve Morrell | last post by:
Hi there, I'm trying to write a piece of sql to set an Oracle sequence's nextval to a number specified my the max value in a set of columns. The sequence is populating these columns, so I want...
0
1518
by: Dan | last post by:
Hello there. I have recently been tasked with creating a mySql database. I am much more used to using Oracle, so I guess my problem is translating Oracle into mySql. My current problem is the...
2
2501
by: Ken | last post by:
I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access could not create the sequence number as soon as the value has...
3
2490
by: DFS | last post by:
FYI, Using DLookup("ResultsField","Pass-thru query") consumes 2 SEQUENCE numbers each time it's called. Anyone know why?
0
317
by: Steven David | last post by:
People, someone help me please. I have a webapplication, and i store the statements in xml file. Then, when i need then i took at the file. In one method of mine i have to add a record at the...
3
6023
by: Eitan M | last post by:
Hello, How can I make sequence for access db ? (the same like Oracle sequence). Thanks :)
14
6379
by: ruediger.michels | last post by:
hi, 1. is there a statement in ms sql, what creates a sequence? cant find anything in web :-( -oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLE CACHE 20; -ms sql: ??? 2....
0
1420
by: saraths007 | last post by:
I am using oracle 10g database...i have two oracle instances(SID)...I want to migrate data from one instance to the other...There is one problem while importing a particular table....say Table 'ABC'...
1
9618
by: chance | last post by:
I need to write some c# code to get the last automatically generated sequence number from an Oracle database. Can anyone provide an example. tia, chance.
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.