How to return multiple values from a function in oracle pl/sql ? (without using out parameter)

How to return multiple values from a function in oracle pl/sql ? (without using out parameter)

Kishan Mashru

7 лет назад

50,966 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ipseetasahu9328
@ipseetasahu9328 - 31.01.2017 07:23

Nice explanation with Nice example 👌

Ответить
@akankshawakhure9402
@akankshawakhure9402 - 19.08.2023 14:52

It's giving me empty table

Ответить
@nileshpatil4068
@nileshpatil4068 - 28.08.2022 10:32

Thanks!

Ответить
@nileshpatil4068
@nileshpatil4068 - 28.08.2022 09:40

Thanks Kishan, video is very informative.

Ответить
@TheDMTLover
@TheDMTLover - 18.08.2022 23:52

Well done. Very nice.

Ответить
@parthparth8680
@parthparth8680 - 28.06.2021 05:01

WHICH WAY TO DELETE RECORD STORED IN NESTED TABLE

Ответить
@parthparth8680
@parthparth8680 - 28.06.2021 04:55

very nice video but where can we use objects

Ответить
@pablobendiksen7727
@pablobendiksen7727 - 20.05.2021 08:13

Thank you! This saved me for a final submission. Could not find a source that better clarified the topic than this

Ответить
@ramyalakshmi5594
@ramyalakshmi5594 - 13.11.2020 10:50

Write a function to return the name of the student whose mark is maximum

Ответить
@poornimas620
@poornimas620 - 31.08.2020 10:12

Does it work for insert and update also

Ответить
@patinoricardo
@patinoricardo - 12.08.2020 21:19

muy bueno, excelente Kishan, gracias por compartir

Ответить
@abderrahimhaddadi4023
@abderrahimhaddadi4023 - 18.06.2020 03:11

Good content.. Do you have an idea how can i work with the same function in java ??

Ответить
@ravishettiyar3262
@ravishettiyar3262 - 28.05.2020 10:30

Thank you so much this video is help me lot and very god example

Ответить
@rameshch6903
@rameshch6903 - 15.05.2020 06:49

Supper brother , explanation supper love it please make more videos we can learn easily 😊

Ответить
@NewZenContent
@NewZenContent - 16.09.2019 17:16

Thank you Kishan :D

Ответить
@Vathananable
@Vathananable - 11.09.2019 09:37

Is this the same when you do with create or replace type body with member function?

Ответить
@udayrajole1356
@udayrajole1356 - 08.08.2019 17:45

Hi Kishan… I used in the same manner but its not returning any records..Here my code is create or replace TYPE EMP_OBJ_TYPE
AS OBJECT

(

ENAME VARCHAR2(10),

JOBD VARCHAR2(9),

SAL NUMBER);



create or replace TYPE EMP_TAB_TYPE

IS TABLE OF EMP_OBJ_TYPE;



create or replace FUNCTION EMP_RET_VAL( P_EMP_ID NUMBER)

RETURN EMP_TAB_TYPE

IS

P_NAME VARCHAR2(10);

P_JOB VARCHAR2(9);

P_SAL NUMBER ;

EMP_DETAILS EMP_TAB_TYPE := EMP_TAB_TYPE();

BEGIN

EMP_DETAILS.EXTEND();

SELECT ENAME,JOB,SAL

INTO P_NAME,P_JOB,P_SAL

FROM EMP

WHERE EMPNO = P_EMP_ID;

EMP_DETAILS(1) := EMP_OBJ_TYPE(P_NAME,P_JOB,P_SAL);

RETURN EMP_DETAILS;

END;



SELECT * FROM TABLE (EMP_RET_VAL(7389)); could you please check this one and suggest me to where I did mistake

Ответить
@ramramaraju2221
@ramramaraju2221 - 05.08.2019 17:20

Thanks Kishan :)

Ответить
@bowser9775
@bowser9775 - 25.04.2019 17:07

Thank you very much. Really good explanations

Ответить
@rishinigam8773
@rishinigam8773 - 18.02.2019 17:52

I need to do the same thing but in a procedure, is there anyway to pass my function into a procedure to display.

Ответить
@milindbidve446
@milindbidve446 - 06.02.2019 14:06

Nice video. Can you please create a video on pipelined functions having pipe row? Thanks.

Ответить
@visakviz4690
@visakviz4690 - 04.01.2019 13:32

well explained..

Ответить
@tejujagadale7458
@tejujagadale7458 - 04.10.2018 18:26

its too nice explanation.....

Ответить
@mahendrababu5516
@mahendrababu5516 - 26.07.2018 20:26

Why can’t we use a sys_ref cursor?

Ответить
@aruljebin
@aruljebin - 22.07.2018 17:39

No need for nested table. As you are returning only one record you can declare as record is enough.

Ответить
@shyamkollimarla1384
@shyamkollimarla1384 - 29.11.2017 14:54

Really Good help and for fresher really good help & Inputs

Ответить
@TheSoulamimukherjee
@TheSoulamimukherjee - 15.10.2017 18:13

So in order to return multiple values from a function. Only to make an object is the only option? Or having multiple out parameters will also do. I mean both the options would work?

Ответить
@shrikantpatil2094
@shrikantpatil2094 - 23.09.2017 17:24

it's pretty good. pls also explain through blog.

Ответить
@vayunandu
@vayunandu - 07.09.2017 20:26

Thank you Kishan. I just followed what you mentioned in the videos step by step. It's very clear.

Just pasting what I created with bulk collect.

CREATE or REPLACE TYPE emp_obj_t AS OBJECT (empno NUMBER,ename VARCHAR2(200),deptno NUMBER);
CREATE OR REPLACE TYPE emp_tab_t AS TABLE OF emp_obj_t;

CREATE OR REPLACE FUNCTION emp_tab RETURN emp_tab_t IS
TYPE emp_rec IS RECORD (empno NUMBER,ename VARCHAR2(200),deptno NUMBER);
TYPE emp_tab IS TABLE OF emp_rec;
emp_blk emp_tab;
emp_recs emp_tab_t;
BEGIN
emp_recs:=emp_tab_t();

SELECT empno,ename,deptno BULK COLLECT INTO emp_blk FROM emp;

FOR i IN 1..emp_blk.count
LOOP
emp_recs.extend();
emp_recs(i):=emp_obj_t(emp_blk(i).empno,emp_blk(i).ename,emp_blk(i).deptno);
END LOOP;

RETURN emp_recs;
EXCEPTION
WHEN no_data_found THEN
raise_application_error(-20001,'Source table is empty');
END;
/

SELECT * FROM TABLE(emp_tab);

Ответить
@sateeshbabu5792
@sateeshbabu5792 - 13.07.2017 13:53

Nice explanation, i am expecting more videos on plsql collections

Thanks kishan

Ответить
@rajvizag6757
@rajvizag6757 - 27.06.2017 17:59

Explantion is very good. Please take care of Video Quality:)

Ответить
@chandraneeldwaraki672
@chandraneeldwaraki672 - 08.06.2017 08:52

Hi Kishan,
Great explanation. Thanks.
I had 1 query regarding BULK COLLECT method you have used
I tried the statement:
SELECT FIRST_NAME,LAST_NAME,DEPARTMENT_NAME BULK COLLECT INTO.......
instead of using EMP_OBJ_TYPE(FIRST_NAME,LAST_NAME,DEPARTMENT_NAME) BULK COLLECT INTO...

The first statement throws compilation error while creating function. Can you please explain why passing it as OBJ_TYPE is mandatory and why oracle throws error for normal SELECT INTO. Thanks.

Ответить
@chandraneeldwaraki672
@chandraneeldwaraki672 - 04.06.2017 21:00

Hi Kishan. Thanks for making video and sharing it for everyone to learn.

I understood returning multiple values from a procedure but I did not understand this particular video because of concepts like OBJECT TYPE, NESTED TABLE TYPE, .EXTEND() and BULK COLLECT.

It is my request to make a separate video first on concepts which you have mentioned in this video like OBJECT TYPE, NESTED TABLE etc.

Also are you planning to make any ORACLE PERFORMANCE TUNING videos where you explain about different concepts like EXPLAIN PLAN, ORACLE HINTS etc. It would be very helpful if you make a series about ORACLE PERFORMANCE TUNING.

Again many thanks for your efforts.

Ответить
@SujitKumar-wg7sz
@SujitKumar-wg7sz - 28.04.2017 05:11

Kindly share always queries whatever you use so that we could replicate same for better understanding...Great Explanations

Ответить
@paladugulasudha2016
@paladugulasudha2016 - 17.04.2017 16:09

Nice explanation but maintain screen quality while explain the program

Ответить
@aravindmadurai9743
@aravindmadurai9743 - 07.03.2017 09:08

confusing brother :(

Ответить