Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Select from a locked row

$
0
0
Given table and functions
PHP Code:

TABLE tbl(
 
i integer,
 
a integer,
 
txt text
);
FUNCTION 
sq(nRETURNS integer AS
$$
  RETURN 
n^2;
$$;
FUNCTION 
I() RETURNS integer AS
$$
  RETURN 
    
SELECT i FROM tbl
    WITH ROWID 
as R
    WHERE r 
CURRENT_TRANSACTION.row(); -- objdescribed in DB engine
$$; 

perform statement
PHP Code:

INSERT INTO tbl VALUES(
2,SQ(N()),SELECT i||a WHERE i N());

 
i   a   txt
-----------
 
2  4   '24' 

I find that most (all?) databases do not allow access to column values of a row under commit. I studied solutions and would like to discuss them if this subject of interest.

Viewing all articles
Browse latest Browse all 13329

Trending Articles