How to display cursor in procedure?Insert results of a stored procedure into a temporary tablehow to write a pl/sql code block that prints out contents of cursor that is out parameter from stored procFunction vs. Stored Procedure in SQL ServerOracle - select a specific column from a ref cursorhow to fetch cursor value into varchar2 in pl/sqlCursor in procedure returning more values than queryNot understanding cursorHow to get data in grid view from procedure returning multiple rows in ref cursorSpringboot java oracle procedure calling with cursorloop is not running for Cursor in the stored procedure

If I have the War Caster feat, can I use the Thorn Whip cantrip to stop an enemy caster from escaping using the Dimension Door spell?

Why can't you move another user's directory when you can move their file?

A quine of sorts

How can I know if a PDF file was created via LaTeX or XeLaTeX?

Quantum jump/leap, exist or not, and instantaneous or not (for electrons)?

I just started should I accept a farewell lunch for a coworker I don't know?

Checkmate in 1 on a Tangled Board

Why wasn't EBCDIC designed with contiguous alphanumeric characters?

Sharing referee/AE report online to point out a grievous error in refereeing

Fully submerged water bath for stove top baking?

Converting Geographic Coordinates into Lambert2008 coordinates

Translation of the Sator Square

Put my student loan in parents’ second mortgage - help?

What happens if a caster is surprised while casting a spell with a long casting time?

Cooking a nice pan seared steak for picky eaters

Adjective for 'made of pus' or 'corrupted by pus' or something of something of pus

Losing the queen and then winning the game

Why were the first airplanes "backwards"?

What is the Japanese name for the conventional shoelace knot?

How can I deal with extreme temperatures in a hotel room?

If I were to build a J3 cub twice the size of the original using the same CG would it fly?

Bin Packing with Relational Penalization

Why does my air conditioning feel weak during the day, but strong in the evening?

Journal standards vs. personal standards



How to display cursor in procedure?


Insert results of a stored procedure into a temporary tablehow to write a pl/sql code block that prints out contents of cursor that is out parameter from stored procFunction vs. Stored Procedure in SQL ServerOracle - select a specific column from a ref cursorhow to fetch cursor value into varchar2 in pl/sqlCursor in procedure returning more values than queryNot understanding cursorHow to get data in grid view from procedure returning multiple rows in ref cursorSpringboot java oracle procedure calling with cursorloop is not running for Cursor in the stored procedure






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have to display name and surname of everyone from team that have the same manager(his name and surname taken from parameter).



I tried 'IN' before VARCHAR2. I did use set serveroutput on.
Furthermore select from cursor separately is working.



CREATE OR REPLACE PROCEDURE ex_2h(nazw VARCHAR2, imi VARCHAR2)
IS
CURSOR team IS SELECT * FROM people p WHERE p.id_manager=
(SELECT id_ppl FROM people WHERE name= imi AND surname=nazw);
tmp people%ROWTYPE;
BEGIN
OPEN team;
LOOP
FETCH team INTO tmp;
EXIT WHEN team%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(NVL(tmp.name, '?'));
END LOOP;
CLOSE team;
END;


I don't know why without parameters it is working but if I add these the cursor is empty and it does not show anything.










share|improve this question
























  • Tested, except this zespol/team issue it works. Maybe you called it as ex_2h('Franciszek', 'Smuda') instead of ex_2h('Smuda', 'Franciszek')?;

    – Ponder Stibbons
    Mar 25 at 15:37











  • Problem solved, thank you for advice, but it was some problem with sql developer. Explenation below.

    – Beata Kozieł
    Mar 25 at 21:45

















0















I have to display name and surname of everyone from team that have the same manager(his name and surname taken from parameter).



I tried 'IN' before VARCHAR2. I did use set serveroutput on.
Furthermore select from cursor separately is working.



CREATE OR REPLACE PROCEDURE ex_2h(nazw VARCHAR2, imi VARCHAR2)
IS
CURSOR team IS SELECT * FROM people p WHERE p.id_manager=
(SELECT id_ppl FROM people WHERE name= imi AND surname=nazw);
tmp people%ROWTYPE;
BEGIN
OPEN team;
LOOP
FETCH team INTO tmp;
EXIT WHEN team%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(NVL(tmp.name, '?'));
END LOOP;
CLOSE team;
END;


I don't know why without parameters it is working but if I add these the cursor is empty and it does not show anything.










share|improve this question
























  • Tested, except this zespol/team issue it works. Maybe you called it as ex_2h('Franciszek', 'Smuda') instead of ex_2h('Smuda', 'Franciszek')?;

    – Ponder Stibbons
    Mar 25 at 15:37











  • Problem solved, thank you for advice, but it was some problem with sql developer. Explenation below.

    – Beata Kozieł
    Mar 25 at 21:45













0












0








0








I have to display name and surname of everyone from team that have the same manager(his name and surname taken from parameter).



I tried 'IN' before VARCHAR2. I did use set serveroutput on.
Furthermore select from cursor separately is working.



CREATE OR REPLACE PROCEDURE ex_2h(nazw VARCHAR2, imi VARCHAR2)
IS
CURSOR team IS SELECT * FROM people p WHERE p.id_manager=
(SELECT id_ppl FROM people WHERE name= imi AND surname=nazw);
tmp people%ROWTYPE;
BEGIN
OPEN team;
LOOP
FETCH team INTO tmp;
EXIT WHEN team%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(NVL(tmp.name, '?'));
END LOOP;
CLOSE team;
END;


I don't know why without parameters it is working but if I add these the cursor is empty and it does not show anything.










share|improve this question
















I have to display name and surname of everyone from team that have the same manager(his name and surname taken from parameter).



I tried 'IN' before VARCHAR2. I did use set serveroutput on.
Furthermore select from cursor separately is working.



CREATE OR REPLACE PROCEDURE ex_2h(nazw VARCHAR2, imi VARCHAR2)
IS
CURSOR team IS SELECT * FROM people p WHERE p.id_manager=
(SELECT id_ppl FROM people WHERE name= imi AND surname=nazw);
tmp people%ROWTYPE;
BEGIN
OPEN team;
LOOP
FETCH team INTO tmp;
EXIT WHEN team%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(NVL(tmp.name, '?'));
END LOOP;
CLOSE team;
END;


I don't know why without parameters it is working but if I add these the cursor is empty and it does not show anything.







oracle stored-procedures plsql cursor






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 21:44







Beata Kozieł

















asked Mar 25 at 14:54









Beata KoziełBeata Kozieł

12 bronze badges




12 bronze badges












  • Tested, except this zespol/team issue it works. Maybe you called it as ex_2h('Franciszek', 'Smuda') instead of ex_2h('Smuda', 'Franciszek')?;

    – Ponder Stibbons
    Mar 25 at 15:37











  • Problem solved, thank you for advice, but it was some problem with sql developer. Explenation below.

    – Beata Kozieł
    Mar 25 at 21:45

















  • Tested, except this zespol/team issue it works. Maybe you called it as ex_2h('Franciszek', 'Smuda') instead of ex_2h('Smuda', 'Franciszek')?;

    – Ponder Stibbons
    Mar 25 at 15:37











  • Problem solved, thank you for advice, but it was some problem with sql developer. Explenation below.

    – Beata Kozieł
    Mar 25 at 21:45
















Tested, except this zespol/team issue it works. Maybe you called it as ex_2h('Franciszek', 'Smuda') instead of ex_2h('Smuda', 'Franciszek')?;

– Ponder Stibbons
Mar 25 at 15:37





Tested, except this zespol/team issue it works. Maybe you called it as ex_2h('Franciszek', 'Smuda') instead of ex_2h('Smuda', 'Franciszek')?;

– Ponder Stibbons
Mar 25 at 15:37













Problem solved, thank you for advice, but it was some problem with sql developer. Explenation below.

– Beata Kozieł
Mar 25 at 21:45





Problem solved, thank you for advice, but it was some problem with sql developer. Explenation below.

– Beata Kozieł
Mar 25 at 21:45












1 Answer
1






active

oldest

votes


















1














Who knows? The procedure itself looks OK (apart from the fact that you opened the TEAM cursor and fetched from ZESPOL (which was never declared).



  • may be the letter case (are those names written in lower/upper/mixed case)?

  • are you confused by parameters' order? Surname first, the first name next? Should it be vice versa (i.e. imi VARCHAR2, nazw VARCHAR2)


  • always use aliases, especially when you use the same table twice (or more times)

Here's a test case which shows that it works if you use it correctly. Note that I've switched to cursor FOR loop which is easier to maintain.



SQL> create table people
2 (id_ppl number,
3 name varchar2(10),
4 surname varchar2(10),
5 id_manager number);

Table created.

SQL> insert all
2 into people values (1, 'Little', 'Foot', 1) --> the same ...
3 into people values (2, 'Big' , 'Foot', 1) --> ... manager
4 into people values (3, 'Stack' , 'Over', 2)
5 select * from dual;

3 rows created.

SQL> set serveroutput on;


The procedure:



SQL> create or replace procedure ex_2h (p_nazw in varchar2, p_imi in varchar2)
2 is
3 begin
4 for tmp in (select p.name from people p
5 where p.id_manager = (select p1.id_ppl
6 from people p1
7 where p1.name = p_imi
8 and p1.surname = p_nazw
9 )
10 )
11 loop
12 dbms_output.put_line(nvl(tmp.name, '?'));
13 end loop;
14 end;
15 /

Procedure created.


Testing:



SQL> exec ex_2h('Foot', 'Little');
Little
Big

PL/SQL procedure successfully completed.

SQL>



I suggest you to try it that way. If it doesn't work, please, post some more info - CREATE TABLE and sample data so that we could see what you really have and how Oracle responded (and why).






share|improve this answer























  • My colleague send me this procedure using for loop and it worked and then I compiled again and it also was ok... I just spent one day on this meh

    – Beata Kozieł
    Mar 25 at 16:21











  • Does it mean that the problem is now solved?

    – Littlefoot
    Mar 25 at 16:23











  • Yes it is working now

    – Beata Kozieł
    Mar 25 at 17:59











  • OK, I'm glad you made it work.

    – Littlefoot
    Mar 25 at 18:22











  • Thanks a lot anyway.

    – Beata Kozieł
    Mar 25 at 21:43










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55340612%2fhow-to-display-cursor-in-procedure%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Who knows? The procedure itself looks OK (apart from the fact that you opened the TEAM cursor and fetched from ZESPOL (which was never declared).



  • may be the letter case (are those names written in lower/upper/mixed case)?

  • are you confused by parameters' order? Surname first, the first name next? Should it be vice versa (i.e. imi VARCHAR2, nazw VARCHAR2)


  • always use aliases, especially when you use the same table twice (or more times)

Here's a test case which shows that it works if you use it correctly. Note that I've switched to cursor FOR loop which is easier to maintain.



SQL> create table people
2 (id_ppl number,
3 name varchar2(10),
4 surname varchar2(10),
5 id_manager number);

Table created.

SQL> insert all
2 into people values (1, 'Little', 'Foot', 1) --> the same ...
3 into people values (2, 'Big' , 'Foot', 1) --> ... manager
4 into people values (3, 'Stack' , 'Over', 2)
5 select * from dual;

3 rows created.

SQL> set serveroutput on;


The procedure:



SQL> create or replace procedure ex_2h (p_nazw in varchar2, p_imi in varchar2)
2 is
3 begin
4 for tmp in (select p.name from people p
5 where p.id_manager = (select p1.id_ppl
6 from people p1
7 where p1.name = p_imi
8 and p1.surname = p_nazw
9 )
10 )
11 loop
12 dbms_output.put_line(nvl(tmp.name, '?'));
13 end loop;
14 end;
15 /

Procedure created.


Testing:



SQL> exec ex_2h('Foot', 'Little');
Little
Big

PL/SQL procedure successfully completed.

SQL>



I suggest you to try it that way. If it doesn't work, please, post some more info - CREATE TABLE and sample data so that we could see what you really have and how Oracle responded (and why).






share|improve this answer























  • My colleague send me this procedure using for loop and it worked and then I compiled again and it also was ok... I just spent one day on this meh

    – Beata Kozieł
    Mar 25 at 16:21











  • Does it mean that the problem is now solved?

    – Littlefoot
    Mar 25 at 16:23











  • Yes it is working now

    – Beata Kozieł
    Mar 25 at 17:59











  • OK, I'm glad you made it work.

    – Littlefoot
    Mar 25 at 18:22











  • Thanks a lot anyway.

    – Beata Kozieł
    Mar 25 at 21:43















1














Who knows? The procedure itself looks OK (apart from the fact that you opened the TEAM cursor and fetched from ZESPOL (which was never declared).



  • may be the letter case (are those names written in lower/upper/mixed case)?

  • are you confused by parameters' order? Surname first, the first name next? Should it be vice versa (i.e. imi VARCHAR2, nazw VARCHAR2)


  • always use aliases, especially when you use the same table twice (or more times)

Here's a test case which shows that it works if you use it correctly. Note that I've switched to cursor FOR loop which is easier to maintain.



SQL> create table people
2 (id_ppl number,
3 name varchar2(10),
4 surname varchar2(10),
5 id_manager number);

Table created.

SQL> insert all
2 into people values (1, 'Little', 'Foot', 1) --> the same ...
3 into people values (2, 'Big' , 'Foot', 1) --> ... manager
4 into people values (3, 'Stack' , 'Over', 2)
5 select * from dual;

3 rows created.

SQL> set serveroutput on;


The procedure:



SQL> create or replace procedure ex_2h (p_nazw in varchar2, p_imi in varchar2)
2 is
3 begin
4 for tmp in (select p.name from people p
5 where p.id_manager = (select p1.id_ppl
6 from people p1
7 where p1.name = p_imi
8 and p1.surname = p_nazw
9 )
10 )
11 loop
12 dbms_output.put_line(nvl(tmp.name, '?'));
13 end loop;
14 end;
15 /

Procedure created.


Testing:



SQL> exec ex_2h('Foot', 'Little');
Little
Big

PL/SQL procedure successfully completed.

SQL>



I suggest you to try it that way. If it doesn't work, please, post some more info - CREATE TABLE and sample data so that we could see what you really have and how Oracle responded (and why).






share|improve this answer























  • My colleague send me this procedure using for loop and it worked and then I compiled again and it also was ok... I just spent one day on this meh

    – Beata Kozieł
    Mar 25 at 16:21











  • Does it mean that the problem is now solved?

    – Littlefoot
    Mar 25 at 16:23











  • Yes it is working now

    – Beata Kozieł
    Mar 25 at 17:59











  • OK, I'm glad you made it work.

    – Littlefoot
    Mar 25 at 18:22











  • Thanks a lot anyway.

    – Beata Kozieł
    Mar 25 at 21:43













1












1








1







Who knows? The procedure itself looks OK (apart from the fact that you opened the TEAM cursor and fetched from ZESPOL (which was never declared).



  • may be the letter case (are those names written in lower/upper/mixed case)?

  • are you confused by parameters' order? Surname first, the first name next? Should it be vice versa (i.e. imi VARCHAR2, nazw VARCHAR2)


  • always use aliases, especially when you use the same table twice (or more times)

Here's a test case which shows that it works if you use it correctly. Note that I've switched to cursor FOR loop which is easier to maintain.



SQL> create table people
2 (id_ppl number,
3 name varchar2(10),
4 surname varchar2(10),
5 id_manager number);

Table created.

SQL> insert all
2 into people values (1, 'Little', 'Foot', 1) --> the same ...
3 into people values (2, 'Big' , 'Foot', 1) --> ... manager
4 into people values (3, 'Stack' , 'Over', 2)
5 select * from dual;

3 rows created.

SQL> set serveroutput on;


The procedure:



SQL> create or replace procedure ex_2h (p_nazw in varchar2, p_imi in varchar2)
2 is
3 begin
4 for tmp in (select p.name from people p
5 where p.id_manager = (select p1.id_ppl
6 from people p1
7 where p1.name = p_imi
8 and p1.surname = p_nazw
9 )
10 )
11 loop
12 dbms_output.put_line(nvl(tmp.name, '?'));
13 end loop;
14 end;
15 /

Procedure created.


Testing:



SQL> exec ex_2h('Foot', 'Little');
Little
Big

PL/SQL procedure successfully completed.

SQL>



I suggest you to try it that way. If it doesn't work, please, post some more info - CREATE TABLE and sample data so that we could see what you really have and how Oracle responded (and why).






share|improve this answer













Who knows? The procedure itself looks OK (apart from the fact that you opened the TEAM cursor and fetched from ZESPOL (which was never declared).



  • may be the letter case (are those names written in lower/upper/mixed case)?

  • are you confused by parameters' order? Surname first, the first name next? Should it be vice versa (i.e. imi VARCHAR2, nazw VARCHAR2)


  • always use aliases, especially when you use the same table twice (or more times)

Here's a test case which shows that it works if you use it correctly. Note that I've switched to cursor FOR loop which is easier to maintain.



SQL> create table people
2 (id_ppl number,
3 name varchar2(10),
4 surname varchar2(10),
5 id_manager number);

Table created.

SQL> insert all
2 into people values (1, 'Little', 'Foot', 1) --> the same ...
3 into people values (2, 'Big' , 'Foot', 1) --> ... manager
4 into people values (3, 'Stack' , 'Over', 2)
5 select * from dual;

3 rows created.

SQL> set serveroutput on;


The procedure:



SQL> create or replace procedure ex_2h (p_nazw in varchar2, p_imi in varchar2)
2 is
3 begin
4 for tmp in (select p.name from people p
5 where p.id_manager = (select p1.id_ppl
6 from people p1
7 where p1.name = p_imi
8 and p1.surname = p_nazw
9 )
10 )
11 loop
12 dbms_output.put_line(nvl(tmp.name, '?'));
13 end loop;
14 end;
15 /

Procedure created.


Testing:



SQL> exec ex_2h('Foot', 'Little');
Little
Big

PL/SQL procedure successfully completed.

SQL>



I suggest you to try it that way. If it doesn't work, please, post some more info - CREATE TABLE and sample data so that we could see what you really have and how Oracle responded (and why).







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 15:21









LittlefootLittlefoot

29.9k7 gold badges17 silver badges34 bronze badges




29.9k7 gold badges17 silver badges34 bronze badges












  • My colleague send me this procedure using for loop and it worked and then I compiled again and it also was ok... I just spent one day on this meh

    – Beata Kozieł
    Mar 25 at 16:21











  • Does it mean that the problem is now solved?

    – Littlefoot
    Mar 25 at 16:23











  • Yes it is working now

    – Beata Kozieł
    Mar 25 at 17:59











  • OK, I'm glad you made it work.

    – Littlefoot
    Mar 25 at 18:22











  • Thanks a lot anyway.

    – Beata Kozieł
    Mar 25 at 21:43

















  • My colleague send me this procedure using for loop and it worked and then I compiled again and it also was ok... I just spent one day on this meh

    – Beata Kozieł
    Mar 25 at 16:21











  • Does it mean that the problem is now solved?

    – Littlefoot
    Mar 25 at 16:23











  • Yes it is working now

    – Beata Kozieł
    Mar 25 at 17:59











  • OK, I'm glad you made it work.

    – Littlefoot
    Mar 25 at 18:22











  • Thanks a lot anyway.

    – Beata Kozieł
    Mar 25 at 21:43
















My colleague send me this procedure using for loop and it worked and then I compiled again and it also was ok... I just spent one day on this meh

– Beata Kozieł
Mar 25 at 16:21





My colleague send me this procedure using for loop and it worked and then I compiled again and it also was ok... I just spent one day on this meh

– Beata Kozieł
Mar 25 at 16:21













Does it mean that the problem is now solved?

– Littlefoot
Mar 25 at 16:23





Does it mean that the problem is now solved?

– Littlefoot
Mar 25 at 16:23













Yes it is working now

– Beata Kozieł
Mar 25 at 17:59





Yes it is working now

– Beata Kozieł
Mar 25 at 17:59













OK, I'm glad you made it work.

– Littlefoot
Mar 25 at 18:22





OK, I'm glad you made it work.

– Littlefoot
Mar 25 at 18:22













Thanks a lot anyway.

– Beata Kozieł
Mar 25 at 21:43





Thanks a lot anyway.

– Beata Kozieł
Mar 25 at 21:43








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55340612%2fhow-to-display-cursor-in-procedure%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현