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

  Рет қаралды 51,403

Kishan Mashru

Kishan Mashru

Күн бұрын

Пікірлер: 66
@ipseetasahu9328
@ipseetasahu9328 8 жыл бұрын
Nice explanation with Nice example 👌
@KishanMashru
@KishanMashru 8 жыл бұрын
Thanks, I hope you have given a "like" to the video!!! Please let me know if you are looking for any specific topic, would be happy to help :)
@ipseetasahu9328
@ipseetasahu9328 8 жыл бұрын
It will help me, if you will make a video about Ref Cursor and Dynamic sql.
@KishanMashru
@KishanMashru 8 жыл бұрын
Sure, We have a video on Dynamic Sql, here's the link kzbin.info/www/bejne/e6mtdnyJebibndk please do like the video if you enjoy watching it, and we will shortly come up with Ref Cursors in Oracle PL/SQL. Please subscribe so that you will get a notification when we upload the video :)
@ipseetasahu9328
@ipseetasahu9328 8 жыл бұрын
Kishan Mashru, Thank you :)
@KishanMashru
@KishanMashru 8 жыл бұрын
here is the video on ref cursor kzbin.info/www/bejne/oGKcn5mBid2AipY hope you enjoy it!!!
@vayunandu
@vayunandu 7 жыл бұрын
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);
@KishanMashru
@KishanMashru 7 жыл бұрын
Good work!!! :)
@Bendiksen4
@Bendiksen4 3 жыл бұрын
Thank you! This saved me for a final submission. Could not find a source that better clarified the topic than this
@nileshpatil4068
@nileshpatil4068 2 жыл бұрын
Thanks!
@chandraneeldwaraki672
@chandraneeldwaraki672 7 жыл бұрын
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.
@KishanMashru
@KishanMashru 7 жыл бұрын
Ya if you are new to Nested Tables and Bulk Collect this video will be a bit complicated to understand, I will make a Video series on Oracle Collections and before that will make few videos on performance tuning !!!
@chandraneeldwaraki672
@chandraneeldwaraki672 7 жыл бұрын
Thanks Kishan.. Will be looking forward to your videos..
@akashjain135
@akashjain135 6 жыл бұрын
Watch Steven Feurenstein's video series on PLSQL Collections.
@nileshpatil4068
@nileshpatil4068 2 жыл бұрын
Thanks Kishan, video is very informative.
@rameshch6903
@rameshch6903 4 жыл бұрын
Supper brother , explanation supper love it please make more videos we can learn easily 😊
@TheDMTLover
@TheDMTLover 2 жыл бұрын
Well done. Very nice.
@sateeshbabu5792
@sateeshbabu5792 7 жыл бұрын
Nice explanation, i am expecting more videos on plsql collections Thanks kishan
@shyamkollimarla1384
@shyamkollimarla1384 7 жыл бұрын
Really Good help and for fresher really good help & Inputs
@KishanMashru
@KishanMashru 7 жыл бұрын
Thanks Shyam, I am glad you enjoyed it :) Hope you have liked the video and subscribed to our channel!!!
@chandraneeldwaraki672
@chandraneeldwaraki672 7 жыл бұрын
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.
@akashjain135
@akashjain135 6 жыл бұрын
The collection in which you are fetching the 3 attributes is EMP_DETAILS. Now, EMP_DETAILS is of table type EMP_TBL_TYPE. Each row of EMP_TBL_TYPE consists of the object type EMP_OBJ_TYPE. So while populating the table type , you need to write something like below:- EMP_DETAILS(1) := EMP_OBJ_TYPE(attribute1,attribute2,attribute3); Similarly while bulk collecting into the EMP_DETAILS you need to use EMP_OBJ_TYPE(attribute1,attribute2,attribute3).
@SujitKumar-wg7sz
@SujitKumar-wg7sz 7 жыл бұрын
Kindly share always queries whatever you use so that we could replicate same for better understanding...Great Explanations
@KishanMashru
@KishanMashru 7 жыл бұрын
Ya, will be posting them on my blog soon :) thanks for the comment, hope you have subscribed to our channel and given the video a "thumbs up" !!!
@SujitKumar-wg7sz
@SujitKumar-wg7sz 7 жыл бұрын
Thanks..
@patinoricardo
@patinoricardo 4 жыл бұрын
muy bueno, excelente Kishan, gracias por compartir
@ravishettiyar3262
@ravishettiyar3262 4 жыл бұрын
Thank you so much this video is help me lot and very god example
@Mahvendren
@Mahvendren 5 жыл бұрын
Is this the same when you do with create or replace type body with member function?
@rishinigam8773
@rishinigam8773 6 жыл бұрын
I need to do the same thing but in a procedure, is there anyway to pass my function into a procedure to display.
@KishanMashru
@KishanMashru 6 жыл бұрын
A better option would be to use sys_refcursors. kzbin.info/www/bejne/oGKcn5mBid2AipY
@milindbidve446
@milindbidve446 6 жыл бұрын
Nice video. Can you please create a video on pipelined functions having pipe row? Thanks.
@TheSoulamimukherjee
@TheSoulamimukherjee 7 жыл бұрын
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?
@KishanMashru
@KishanMashru 7 жыл бұрын
good question, you are kind of right. See its all abt the requirement if you have a single records but multiple values to be returned from a function like id, name for a SINGLE employee you can simply do it with multiple out parameters, but when you need to return MULTIPLE rows containing id and name for a bunch of employee you would need the object based shown in d video. Hope this helps.
@TheSoulamimukherjee
@TheSoulamimukherjee 7 жыл бұрын
Kishan Mashru yes that was helpful. So in order to return multiple values I can use multiple out parameters. So If i need to return empid ename n salary. Write it in the same way like a procedure
@KishanMashru
@KishanMashru 7 жыл бұрын
yup, you will get the values in your out params, make sure you handle/sync them properly with the return statement of the function.
@TheSoulamimukherjee
@TheSoulamimukherjee 7 жыл бұрын
Kishan Mashru okay krishna. So it will be e.g emp id , ename n address Then return varchar2 is V_empid varchar2(100), V_ename varchar2(20), V_addr varchar2 (30) Like this?
@KishanMashru
@KishanMashru 7 жыл бұрын
CASE STUDY -- DROP THE TABLE, IF EXISTS DROP TABLE TEST_EMP; -- CREAT ETABLE CREATE TABLE TEST_EMP ( EMP_ID NUMBER, EMP_NAME VARCHAR2(30), DEPT NUMBER ); -- INSERT DATA INSERT INTO TEST_EMP VALUES (1, 'KISHAN',10); INSERT INTO TEST_EMP VALUES (2, 'MASHRU',20); -- COMMIT DATA COMMIT; -- FUNCTION CREATE OR REPLACE FUNCTION GET_NAME_DEPT (F_ID NUMBER, F_NAME OUT VARCHAR2, F_DEPT OUT VARCHAR2) RETURN NUMBER IS BEGIN SELECT EMP_NAME, DEPT INTO F_NAME, F_DEPT FROM TEST_EMP WHERE EMP_ID = F_ID; RETURN F_ID; END; / --EXEC TEST DECLARE FUNC_OUTPUT NUMBER; FUNC_NAME VARCHAR2(50); FUNC_DEPT VARCHAR2(50); BEGIN FUNC_OUTPUT := GET_NAME_DEPT(1,FUNC_NAME,FUNC_DEPT); DBMS_OUTPUT.PUT_LINE('FUNCTION OUTPUT : '||FUNC_OUTPUT||' NAME : '||FUNC_NAME||' DEPT : '||FUNC_DEPT); END; / -- OUTPUT -- FUNCTION OUTPUT : 1 NAME : KISHAN DEPT : 10
@bowser9775
@bowser9775 5 жыл бұрын
Thank you very much. Really good explanations
@abderrahimhaddadi4023
@abderrahimhaddadi4023 4 жыл бұрын
Good content.. Do you have an idea how can i work with the same function in java ??
@KishanMashru
@KishanMashru 4 жыл бұрын
Create a connection to the database and invoke the function!!!
@abderrahimhaddadi4023
@abderrahimhaddadi4023 4 жыл бұрын
@@KishanMashru Yes, about invoking the function, what should be the return type ? there's a trick (types.ARRAY, ''nestedtableType') , but I still dont know how to retrieve the data. I would be very grateful if you help me with this Kishan !!
@parthparth8680
@parthparth8680 3 жыл бұрын
very nice video but where can we use objects
@poornimas620
@poornimas620 4 жыл бұрын
Does it work for insert and update also
@tejujagadale7458
@tejujagadale7458 6 жыл бұрын
its too nice explanation.....
@KishanMashru
@KishanMashru 6 жыл бұрын
Thanks Teju!!! Hope you have liked the video and subscribed to our channel!!!
@rajvizag6757
@rajvizag6757 7 жыл бұрын
Explantion is very good. Please take care of Video Quality:)
@KishanMashru
@KishanMashru 7 жыл бұрын
Thanks Raj :) Hope you have subscribed to the channel and liked the video!!!
@rajvizag6757
@rajvizag6757 7 жыл бұрын
Yess!!! Keep Going ! Good luck.
@parthparth8680
@parthparth8680 3 жыл бұрын
WHICH WAY TO DELETE RECORD STORED IN NESTED TABLE
@mahendrababu5516
@mahendrababu5516 6 жыл бұрын
Why can’t we use a sys_ref cursor?
@shrikantpatil2094
@shrikantpatil2094 7 жыл бұрын
it's pretty good. pls also explain through blog.
@ramramaraju2221
@ramramaraju2221 5 жыл бұрын
Thanks Kishan :)
@KishanMashru
@KishanMashru 5 жыл бұрын
Welcome!!!
@NewZenContent
@NewZenContent 5 жыл бұрын
Thank you Kishan :D
@aruljebin
@aruljebin 6 жыл бұрын
No need for nested table. As you are returning only one record you can declare as record is enough.
@visakviz4690
@visakviz4690 6 жыл бұрын
well explained..
@akankshawakhure9402
@akankshawakhure9402 Жыл бұрын
It's giving me empty table
@paladugulasudha2016
@paladugulasudha2016 7 жыл бұрын
Nice explanation but maintain screen quality while explain the program
@KishanMashru
@KishanMashru 7 жыл бұрын
sure!!! Thank you :)
@ramyalakshmi5594
@ramyalakshmi5594 4 жыл бұрын
Write a function to return the name of the student whose mark is maximum
@aravindmadurai9743
@aravindmadurai9743 8 жыл бұрын
confusing brother :(
@KishanMashru
@KishanMashru 8 жыл бұрын
which part? try this one out kzbin.info/www/bejne/sIfWapmBiMhgba8
HOW TO REPLACE NULL VALUE IN ORACLE SQL | NVL function explained
6:25
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Collections in Oracle PLSQL
13:29
yrrhelp
Рет қаралды 63 М.
How to Be a Part-Time Expat and LIVE Abroad
13:28
travellingwests
Рет қаралды 78
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 222 М.
Oracle interview Question : what is trigger in oracle
10:56
Siva Academy
Рет қаралды 153 М.
1 PLSQL Performance Tuning   Introduction to DBMS PROFILER
23:33
Siva Academy
Рет қаралды 118 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН