Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to return rows using procedure?

2985493Sep 26 2015 — edited Sep 26 2015

Example: There has 3 areas : A, B ,C , and each area has some persons.

create table Person (name varchar2(2), area varchar2(2));

insert into Person values('A1','A');  --row 1

insert into Person values('A2','A');  --row 2

insert into Person values('A3','A');  --row 3

insert into Person values('A4','A');  --row 4

insert into Person values('B1','B');  --row 5

insert into Person values('C1','C');  --row 6

insert into Person values('C2','C');  --row 7

result as following:

A   B   C

--------------

A1 B1 C1

A2      C2

A3

A4

If we "select * from Person", then we got all rows.

Now want to choose volunteers from every area, the rule is to choose a person from each area orderly, until N persons are chose. If N = 6, the sequence is

A1, B1, C1, A2, C2, A3

and want to return rows 1,5,6,2,7,3 (the rows' order is not important) from Person.

How to create a procedure to do this? And I wish the returned rows just like returned from a select sentence. (can be easily filled into a DataTable and then be used in a program.)

Thank you!!

This post has been answered by Frank Kulash on Sep 26 2015
Jump to Answer

Comments

Isn't the legend in approx_percentile picture incorrect?

Shouldn't it be "Exact | Deterministic | Non-deterministic"?

Dude!

Isn't the legend in approx_percentile picture incorrect?

Shouldn't it be "Exact | Deterministic | Non-deterministic"?

You missed an 'n' in Loooooooooooooooog Names

Hendrik Schmidt

Hello,

for the link: "here's the script" I receive Page Not Found error

Non-deterministic results are around 5x faster than deterministic. And nearly 15x faster than exact results. So if an estimate is all you need, you can save yourself a lot of time using approx_percentile. If you want to check this for yourself, here's the script I used.

Evening,

I'm working on mvc projects using mean stack how can i integrate these projects without using mongodb. take for example using sql server..any tips will be helpful.

Peter Schlaeger

Hallo

I must worn everyone for trusting in Oracle Json Support. I have very very very painfull experiences  with Json in Oracle.

In 12.1 it took more than one year and lots of support calls before I was able to use it without bugs ( including full database crashes ).

And now I test on 12.2 and I am again back at the state  where I was in March 2016. Again the same bugs and the solution still not include in any windows bundle patch.

So I suggest that everyone should carefully test his Oracle Version and Patch level if it is capable of running Json without bugs before you decide to use Json.

blessed DBA

We are going start some project on this JSON So it is more useful for us

martin_olivia

The Oracle Database 12c is a high-performance, enterprise-class database.

1 - 7
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 24 2015
Added on Sep 26 2015
5 comments
371 views