Update query in Progress

Mark123

New Member
Hi, I am new to Progress and I need to convert the following SQL query into progress 4GL language:

update table1
set col1 = 2,
col2 = getdate()
where col1 = 3


Thanks in advance.

 

Cecil

19+ years progress programming and still learning.
Hi, I am new to Progress and I need to convert the following SQL query into progress 4GL language:

update table1
set col1 = 2,
col2 = getdate()
where col1 = 3


Thanks in advance.


Hi there.

Not knowing much about SQL queries, I think I Can answer your question.

Code:
/*Single Find*/
find first table1 exclusive-lock
 where table1.col1 =  3 /* If col1 data type is character then 3 needs to be quoted '3'...*/
 no-error.

if available table1 then 
do:

assign 
 table1.col2 = getdate()
 table1.col1 = 2.

end.
Alternative Code:

Code:
/*Multiple Finds*/
For each table1 exclusive-lock
 where table1.col1 = 3:
 
assign 
 table1.col2 = getdate()
 table1.col1 = 2.

end.
However since I don't know the data types of the fields (.i.e char, int etc) and the structure of your indexes I am not 100% sure if this helps you. Good luck
 

bulklodd

Member
progress supports sql statements in 4gl code (esql) so you can use it as it is. the only thing which might be a problem is getdate function. i suppose it just returns today date in that case you shoud replace it as follows

Code:
update table1
set col1 = 2,
col2 = today
where col1 = 3

there's another thing you have to take into account - you can't use esql with temptables, so make sure that table1 isn't a temptable before trying.

hth
 

joey.jeremiah

ProgressTalk Moderator
Staff member
Hello Guys,

Although, the embedded SQL is SQL89 and is being deprecated.


Mark123,

Familiarize yourself with the FOR EACH statement

it's basically SELECT, INSERT, UPDATE and DELETE all rolled up together, sort of.
 
Top