Questions tagged [currval]

`currval` is used in Sybase SAP SQL Anywhere to get the current value of a database sequence. `CURRVAl` can only be used if `NEXTVAL` is called in the same connection/session.

currval is used in Sybase SAP SQL Anywhere to get the current value of a database sequence. CURRVAl can only be used if NEXTVAL is called in the same connection/session.

For example:

SELECT your_sequence_name.currval for getting the current position/value of the sequence your_sequence_name.

10 questions
3
votes
2 answers

How can I use PostgreSql's CURRVAL / RETURNING from another php file?

I'm running an INSERT query from one php file, but then I need to get the last inserted id from an external php file so as to run another query based on that id. How can I pull this off using CURRVAL or RETURNING? From the external php file, if I do…
Clint_A
  • 518
  • 2
  • 11
  • 35
1
vote
0 answers

How to insert rows with the serial column catching up from the largest value in the table in Postgres

I have a table like the following: create table my_table ( "ID" serial not null, "Name" varchar(500) ); Without changing the property of the table, is there any clean way to insert a new row to this table (already has…
cxc
  • 201
  • 2
  • 10
1
vote
1 answer

PostgreSQL getting new id during insert

I need to create some customer number on record insert, format is 'A' + 4 digits, based on the ID. So record ID 23 -> A0023 and so on. My solution is currently this: -- Table create table t ( id bigserial unique primary key, x text, y…
Flo
  • 421
  • 4
  • 6
0
votes
1 answer

How to get current value of oracle sequence in ctl template

I'm trying to ingest 3 csv into 3 three tables A,B,C respectively. Primary key of A is generated using SCHEMEA.SEQ_TAB_REC_ID.NEXTVAL and B, C has foreign key column which is referring to A's primary key I tried to put the direct sql query select…
0
votes
0 answers

CurrVal function returns null in Postgres embedded db

I am trying to use currVal function in postgres embedded db to get the value I have inserted in an insert statement in the same session. Please find the below code for the same. Student Table Definition: CREATE TABLE student ( id bigserial NOT…
0
votes
2 answers

How to get values of all sequences using currval?

In example: have 3 sequences (seq1, seq2, seq3) and I would like make one query showing their name and their current value value? The basic syntax is select schema.seq_name.currval from dual But how to show value of all of them?
Ron
  • 19
  • 3
0
votes
1 answer

Is there way to add a field in a parent query that will increment as the query goes through all values generated in a subquery?

I think I have a table that lacks a true primary key and I need to make one in the output. I cannot modify the table. I need to run a select query to generate a list of values (list_A), then take those values and query them to show all the records…
0
votes
2 answers

Sequence in create table?

So I failed in exam with score 60% which needed 3% for pass, and I want to know about sequence in create table statement, in question given us that => in the database "exist" sequence for example SEQ_001 and used in for example=> SQL>create table (…
user9135988
0
votes
0 answers

Store counter in an oracle sequence

I need an advice about the counter of incoming requests for Java ejb web service. Application server where a web service is deployed has 4 nodes, so the incoming request can be processed on any of 4, and I decided to store counter value in Oracle…
Buch
  • 97
  • 1
  • 10
0
votes
1 answer

Calculating age with currval in postgreSQL

I have created a database with a People table which contains all the information for people such as their first name, last name, gender,date of birth, and email. Each row in this table has a serial peopleID. I am trying to create a stored procedure…