Difference between revisions of "CURRVAL"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
=CURRVAL=
 
 
 
==Class==
 
Pseudo Columns
 
 
 
 
==Purpose==
 
==Purpose==
 
Return the current sequence number from the specified table
 
Return the current sequence number from the specified table
Line 26: Line 19:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
// config.db
+
CREATE TABLE cust (acc_num INT , acc_name char(20))
set sql to recital
+
INSERT INTO cust (acc_num, acc_name) VALUES (NEXTVAL, "Smith")
set sql on
+
INSERT INTO cust (acc_name) VALUES ("Brown")
// end of config.db
+
INSERT INTO cust (acc_num, acc_name) VALUES (CURRVAL+2, "Jones")
 
+
SELECT * from cust
CREATE TABLE cust (acc_num INT , acc_name char(20));
+
INSERT INTO cust (acc_num, acc_name) VALUES (NEXTVAL, "Smith");
+
INSERT INTO cust (acc_name) VALUES ("Brown");
+
INSERT INTO cust (acc_num, acc_name) VALUES (CURRVAL+2, "Jones");
+
SELECT * from cust;
+
 
</code>
 
</code>
  
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital, Recital Server
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL]]
 
[[Category:SQL]]
 
[[Category:Pseudo Columns]]
 
[[Category:Pseudo Columns]]

Latest revision as of 14:58, 4 July 2011

Purpose

Return the current sequence number from the specified table


Syntax

CURRVAL


See Also

PSEUDO COLUMNS, INSERT, SELECT, UPDATE


Description

A Pseudo Column behaves like a table column, but is not actually stored in the table. You can select from Pseudo Columns, but they cannot be updated. Pseudo Columns provide extra information about a SELECT row set.

The CURRVAL Pseudo Column will return the current sequence number from the specified table. Sequence numbers can be used for primary and unique index keys.


Example

CREATE TABLE cust (acc_num INT , acc_name char(20))
INSERT INTO cust (acc_num, acc_name) VALUES (NEXTVAL, "Smith")
INSERT INTO cust (acc_name) VALUES ("Brown")
INSERT INTO cust (acc_num, acc_name) VALUES (CURRVAL+2, "Jones")
SELECT * from cust


Products

Recital, Recital Server