Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting FETCH LAST (informix) to postgres

Status
Not open for further replies.

thegritche

Programmer
Jul 10, 2001
1
0
0
FR
I am currently working on queries convertion from Informix to Postgres. I have to convert tons of lines of esql/c scripts (informix) into ecpg scripts (postgres). Hence i use AWK scripts to acheve this job.

My problem is about the $FETCH LAST <cursor_name> INTO ... request. The LAST keyword means that the fetch instruction will put the &quot;last&quot; cursor line. I couldn't find an equivalent in the postgres documentation without faking the request.(with FETCH NEXT/PRIOR/ALL ...)

Can someone tell me if he/she has a solution ?

My constraints are :
- make the least changes to the original source code.
- use an iterative converting process (do not add instructions anywhere in the source code).
- do NOT modify the value of &quot;sqlca.sqlcode&quot; (it is generaly tested just after the FETCH for succes/failure)

All the statements i work on look like this :

> declare <name> cursor for select (...)
> ...
> open <name>
> ...
> fetch &quot;last&quot; <name> into <variable>
> test &quot;sqlca.sqlcode&quot; for errors
> ...
> close <name>

Note : there are no other FETCH in the statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top