If your results set is in a DataTable, you can use it's properties, such as Rows, to get data from the row you want. Alternatively, you can do a linq to DataTable to query your recordset.
If your results set is in a DataTable, you can use it's properties, such as Rows, to get data from the row you want. Alternatively, you can do a linq to DataTable to query your recordset.
my pl/sql is as belows now:
open xx_list for
select id,name from customer where name='WONG';
but i don't know your method, how i can select top 1 from the resultset, would you provide reference code for me?
in package i have one output list. so after running the stored procedure,it returns a output list.
in my stored procedure as belows:
select phone from customer where name='WONG';
--at this moment i extract 2 records from the table , but i just expect output list contain one record so that i need to extract the top 1 record of the selected select (select phone from customer where name='WONG').
i have tried the following sql wrong output returns
"select phone from customer where name='WONG' and rownum=1"
-_-
Member
375 Points
1033 Posts
top 1 record from selected record (PL/SQL)
Jan 03, 2013 02:18 PM|LINK
i have selected some data from the database, but i need to ensure that i have extract one record and put it into output list.
how can i do that as i can't select the top 1 record from the selected record.
how can i ensure 1 record extract into output list in PL/SQL (Oracle)
select name,ID, gender from customer where customer_name ='Mary';
-------------
result list:
name ID gender
'mary' 01 F
'mary' 02 F
how can i select top 1 from result list (ID=01) and put it to output list?
anantDD2007
Member
122 Points
21 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 03, 2013 03:19 PM|LINK
Hi,
You can use the Top clause in your select statement.
For e.g.
Select Top 1 Name,ID from Customer where customer_name = 'ABC'
Please mark this as answer if this helps.
Thanks,
Anant
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 03, 2013 03:25 PM|LINK
A google search on "oracle top 10" will lead you to the proper syntax.
-_-
Member
375 Points
1033 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 03, 2013 03:30 PM|LINK
but it just returns the top 1 from the database table, not my resultset.
i want to selected top 1 from resultset.
for example:
my database have id=1,2,3,4
and selected recored=2,3,4
if i select * from customer where rownum=1, it returns id=1
actually, i want to select 2 always at the top 1 from selected record list.
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 03, 2013 04:05 PM|LINK
If your results set is in a DataTable, you can use it's properties, such as Rows, to get data from the row you want. Alternatively, you can do a linq to DataTable to query your recordset.
-_-
Member
375 Points
1033 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 04, 2013 01:56 AM|LINK
my pl/sql is as belows now:
open xx_list for
select id,name from customer where name='WONG';
but i don't know your method, how i can select top 1 from the resultset, would you provide reference code for me?
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 04, 2013 02:02 AM|LINK
This being a .net forum, I was giving you a .net answer. I gave you an Oracle answer earlier but you didn't like it.
-_-
Member
375 Points
1033 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 04, 2013 02:31 AM|LINK
sorry, i am beginner of using oracle. would you provide code for my reference.
my resultset is a set of data, how can i select top 1 from resultset in PL/SQL
-_-
Member
375 Points
1033 Posts
Re: top 1 record from selected record (PL/SQL)
Jan 05, 2013 03:13 PM|LINK
anyone knows how to select top 1 from result set?
example:
my table contain many record as belows:
customer table
ID Name phone
1 CHAN 99900000
2 WONG 11223344
3 WONG 22334455
in package i have one output list. so after running the stored procedure,it returns a output list.
in my stored procedure as belows:
select phone from customer where name='WONG';
--at this moment i extract 2 records from the table , but i just expect output list contain one record so that i need to extract the top 1 record of the selected select (select phone from customer where name='WONG').
i have tried the following sql wrong output returns
"select phone from customer where name='WONG' and rownum=1"
it return record where id=1.