110 questions
1
vote
2
answers
746
views
Spring Boot with Oracle Sequence - 2 different applications get colliding SEQUENCE.NEXTVAL causing ORA-0001 unique constraint violation on primary key
I have 2 applications (one is SpringBoot app and another is a C++ app) calling the same Oracle sequence SEQUENCE_A responsible for generating PK on the same table TABLE-A.
The sequence DDL is as:
...
1
vote
0
answers
29
views
Inconsistent Hibernate Behavior while using GenerationType.SEQUENCE
I see inconsistent hibernate behavior when using sequence to generate id, I have simple project with one entity Fruit and I'm using spring.jpa.hibernate.ddl-auto=create-drop so hibernate is launching ...
0
votes
3
answers
307
views
Get the next 10 values of the SEQUENCE at once
I want to get the next 10 values of the SEQUENCE at once.
I can get those individually by calling
SELECT setval('myseq', ...); -- Next nextval will return 43
10 times back to back.
On ...
0
votes
0
answers
129
views
Sequence in DB Postgresql
I have a Java system that uses Sequence in PK in database (postgreSQL and PGadmin)
This sequence should take the current month (with two digits) followed by the current year.
It turns out that a ...
0
votes
1
answer
836
views
Why SEQUENCE is used in SQL? [duplicate]
I am brushing up my knowledge about SQL and I am learning more and more. However, I am not understanding the purpose of the Sequence we use. I am using SQL Server.
0
votes
1
answer
1k
views
PostgreSQL ALTER SEQUENCE with SELECT clause
I am trying to alter database sequence and restart it with value returned by complex SELECT statement. This is a simplified example that I prepared to replicate the issue:
ALTER SEQUENCE
abc....
0
votes
1
answer
426
views
Consuming sequence inside a embeddedId in springboot
I have the next issue -> I have a table on my db with a composite id...
Supose (Id1,Id2,Id3,Id4), the Id4 is generated by a sequence on the db...
My question is, in spring boot, I generate the ...
0
votes
1
answer
171
views
Postgres sequence that resets once the id is different
I am trying to make a Postgres sequence that will reset once the id of the item it is linked to changes, e.g:
ID SEQUENCE_VALUE
1 1
2 1
1 2
1 3
...
0
votes
2
answers
1k
views
Spring Boot entity with Pk using Oracle DB Sequence in a trigger
I need a help on persisting an entity in a Oracle DB table that uses trigger and sequence for PK.
By now, I tried these from other stackoverflow questions:
@Id
@GeneratedValue(generator="...
0
votes
1
answer
523
views
Sequence id is not properly inserted
I have created a sequence but its not inserting ids in sequence order.
For Ex:
First I have created one set of record seq number generated as 1, 2, 3, 4
Again I have created another set of records ...
0
votes
2
answers
658
views
2 Applications using different hibernate versions but same oracle database throwing unique constraint error
There are 2 applications : one is using Spring boot - 1.5.18.Release version, which has hibernate version as 5.0.12.Final
:https://search.maven.org/artifact/org.springframework.boot/spring-boot-...
0
votes
0
answers
26
views
Sequence is incremented even if no INSERT occurs [duplicate]
I've a table with following structure:
CREATE TABLE web.cabinet_account_section (
id serial NOT NULL,
section_id text NULL,
account_id int4 NULL,
cabinet_param_id int4 NULL,
...
0
votes
1
answer
98
views
Postgres tech role for sequence only
There is role sequence_owner. This is special tech role for working with sequence only.
create role sequence_owner;
GRANT sequence_owner TO administrator;
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES ...
1
vote
1
answer
158
views
Can't figure out what datatype is incorrect in my SQL table
I am trying to create a SQL table, but I keep getting this error.
Error report -
ORA-00902: invalid datatype
00902. 00000 - "invalid datatype"
Here is my code.
CREATE TABLE viewers
(
...
1
vote
3
answers
4k
views
How to increment id without auto increment?
I have a table with id column as a number which have meanings. Different types of accounts start from different ranges. E.g Organisation 10000 <-> 100000, users 1000000 <-> 1kk. How can i ...
5
votes
3
answers
7k
views
Reset Postgres auto-increment value to 0
I'm having a table where I sometimes enter data in inline editors where I manually add the id value which is usually auto-incremented.
In a case where id 4 was auto generated using scripts and then ...
0
votes
1
answer
170
views
Share sequence from 2 user in Postgres
In database server Postgres 9.x or Postgres 10.x can I share the same sequence from 2 user?
For example in the same database dbTest there are 2 schemas
userA is schema owner schemaA with a sequenceA
...
0
votes
0
answers
281
views
HibernateException: Missing sequence or table and SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into
I am fairly new to hibernate and this is very strange - I am trying to run a Spring-Hibernate rest application on tomcat using eclipse.
I have an entity defined as below -
@Entity
@Table(name = "...
1
vote
0
answers
34
views
Serial id next value not getting sequential after failed insert attempt [duplicate]
I have a id field where id is serial and in the same table i have unique constraints. The problem here is when an unique constraint fails if the current ID value is 5 then after failing the next ID ...
1
vote
1
answer
2k
views
What is the equivalent for NO ORDER of oracle sequence in postgresql?
I have a query
CREATE SEQUENCE "SEQ_ID"
MINVALUE 1
MAXVALUE 99999
INCREMENT BY 1 START WITH 121
CACHE 20
NOORDER
NOCYCLE;
This one is of oracle commands.
Now, I ...
0
votes
2
answers
92
views
I try to insert query alphanumeric sequence in table but it is not working
I am trying to insert an alphanumeric sequence in Oracle but it is not working.
create sequence LIB start with 1 increment by 1;
select 'LIBR'||to_char(seq_no.nextval,'FM0000099') from dual;
...
0
votes
3
answers
838
views
Oracle - How to rollback sequences inside multiple inserts
I have a script (that can fail) with multiple inserts that include nextval as
insert into table a (id, value) (id_seq.nextval, 'value');
...
If script fails and I rollback the inserts, the sequence ...
0
votes
2
answers
451
views
How to use sub-queries correctly inside a Postgresql query
I'm having troubles resetting the sequences as automatically as possible.
I'm trying to use the next query from phpPgAdmin:
SELECT SETVAL('course_subjects_seq', (SELECT MAX(subject_id) FROM ...
0
votes
1
answer
111
views
Cannot insert a number using SQL - whole column is removed / number is null
I'm trying to insert a Number as an ID in a column in my database by a loop which sets the new ID by a Sequence. When I try to insert it, the row hasn't been created or the field where my number ...
0
votes
0
answers
72
views
Update unique id (start with 1)against the foreign key and unique id will again start with 1 the next foreign key
I need to update product_details table with unique ID(CHARGE_NUMBER) againt each batch_ID and for the next batch ID unique ID again will start with 1
I have write a code using sequence.
update ...