If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > lock row

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-16-03, 09:59
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 283
Wink lock row

Hi.

I am using INFORMIX-IDS 7.31 and need working whit transaction but I how can lock a row, the program when to do a cursor for update show me the followind error.



Date: 10/16/2003 Time: 13:58:19
Program error at "pfgrafoc.4gl", line number 63.
SQL statement error number -255.
Not in transaction.
Date: 10/16/2003 Time: 15:33:28
Program error at "pfgrafoc.4gl", line number 68.
SQL statement error number -290.
Cursor not declared with FOR UPDATE clause.
Date: 10/16/2003 Time: 15:35:24
Program error at "pfgrafoc.4gl", line number 464.
SQL statement error number -400.
Fetch attempted on unopen cursor.
Reply With Quote
  #2 (permalink)  
Old 10-16-03, 12:45
pd12 pd12 is offline
Registered User
 
Join Date: Sep 2003
Posts: 22
hello,

use this syntax to lock the table.

lock table table_name in exclusive mode;

Also, when you prepare a statement or declare a cursor use FOR UPDATE clause at the end. This will lock the row automatically.

Additionally, no error checking is done in your program, check sql error code at every level. sqlca.sqlcode should be zero ( this indicates correct execution)

-PD
Reply With Quote
  #3 (permalink)  
Old 10-16-03, 13:08
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 283
Hi.


Thank you for you answer, but i need lock a row in my program when i find a record.

Thank you.
Reply With Quote
  #4 (permalink)  
Old 10-16-03, 13:12
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 283
send a fucntion where a find a number of docuemnt.

function incrementa_contador(centro,cod_cont,valor_inicio)

define
centro like ffcontad.cen_con,
cod_cont like ffcontad.cod_con,
valor_inicio like ffcontad.con_con

let p_contador.cod_con = cod_cont


if in_transacciones = 1 and not enable_trans then
begin work
let enable_trans = true
end if

set lock mode to wait

let p_contador.con_con = null

if p_contador.emp_con is null then
let p_contador.emp_con = p_empresa.cod_emp
end if
let p_contador.cen_con = centro

declare inc_count cursor for
select * from ffcontad
where
emp_con = p_contador.emp_con and
cen_con = p_contador.cen_con and
cod_con = p_contador.cod_con and
any_con = year(fecha_hoy)
for update

foreach inc_count into p_contador.*
update ffcontad
set con_con = con_con + 1
where
current of inc_count
end foreach

let p_contador.any_con = year(fecha_hoy)

if p_contador.con_con is null then
if p_contador.cod_con = "ngra" then
select max(con_con) into valor_inicio
from ffcontad
where
cod_con = "ngra" and
any_con = p_contador.any_con
if valor_inicio is null then
let valor_inicio = 10000
end if
let valor_inicio = valor_inicio + 100000
end if
let valor_inicio = valor_inicio + 1
insert into ffcontad
values
(p_contador.emp_con,
p_contador.any_con,
p_contador.cod_con,
p_contador.cen_con,
p_contador.des_con,
valor_inicio)
let p_contador.con_con = valor_inicio -
end if


return(p_contador.con_con)

end function
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On