Cursors.. - Mailing list pgsql-sql
From | David Calle |
---|---|
Subject | Cursors.. |
Date | |
Msg-id | a354e4430808181419k38a95c09gdcad026d69d4546e@mail.gmail.com Whole thread Raw |
Responses |
Re: Cursors..
|
List | pgsql-sql |
<div dir="ltr">Hi List, <br /><br />I need to convert this cursor of Oracle to Postgres...<br />I wait for your help!!<br/><br /></div><b><span lang="EN-US" style="font-size: 12pt; font-family: "Times New Roman","serif"; color: black;">declare</span></b><bstyle=""><span lang="EN-US" style="font-size: 12pt; font-family: "Times New Roman","serif"; color:black;"><br /><span style=""> </span>v_num_dep <span style="">integer</span> := &v_num_dep;<br /><span style=""> </span>v_cont <span style="">integer</span>:=</span><span lang="EN-US" style="font-size: 12pt; font-family: "TimesNew Roman","serif"; color: rgb(0, 0, 240);">0</span><span lang="EN-US" style="font-size: 12pt; font-family: "TimesNew Roman","serif"; color: black;">;<br /><span style=""> </span><br /><span style=""> </span><span style="">cursor</span>cursor_dep <span style="">is</span><br /><span style=""> </span><span style="">select</span> *<br/><span style=""> </span><span style="">from</span> hr.employees<br /><span style=""> </span><span style="">where</span>hr.employees.department_id = v_num_dep;<br /><span style=""> </span>reg_dep cursor_dep%<span style="">rowtype</span>;<br/><span style=""> </span><br /><span style="">begin</span><br /><br /><span style=""> </span><spanstyle="">for</span> reg_dep <span style="">in</span> cursor_dep <br /><span style=""> </span><spanstyle="">loop</span><br /><span style=""> </span>v_cont := v_cont + </span><span lang="EN-US" style="font-size:12pt; font-family: "Times New Roman","serif"; color: rgb(0, 0, 240);">1</span><span lang="EN-US" style="font-size:12pt; font-family: "Times New Roman","serif"; color: black;">;<br /><span style=""> </span>dbms_output.put_line(to_char(reg_dep.last_name)||</span><span lang="EN-US" style="font-size: 12pt; font-family: "TimesNew Roman","serif"; color: rgb(0, 0, 240);">'<span style=""> </span>'</span><span lang="EN-US" style="font-size: 12pt;font-family: "Times New Roman","serif"; color: black;">|| to_char(reg_dep.salary)||</span><span lang="EN-US" style="font-size:12pt; font-family: "Times New Roman","serif"; color: rgb(0, 0, 240);">'<span style=""> </span>'</span><spanlang="EN-US" style="font-size: 12pt; font-family: "Times New Roman","serif"; color: black;">|| to_char(reg_dep.manager_id));<br/><span style=""> </span><span style="">exit</span> <span style="">when</span> v_cont=v_num_dep;<br/><span style=""> </span><span style="">end</span> <span style="">loop</span>;<br /><br /><span style="">end</span>;<brstyle="" /><br /></span></b><br /><br />