Home » Developer & Programmer » Forms » SELECT Records based on an array of values
SELECT Records based on an array of values [message #259152] Tue, 14 August 2007 09:27 Go to next message
hdogg
Messages: 93
Registered: March 2007
Member
I create the array userid[]

usersid[1] = 1231
usersid[2] = 455
usersid[3] = 1251
usersid[4] = 1291

The array is populated by form check box's submitted.

I want to SELECT items from a database with those userid's

SELECT USER_ID FROM USERS WHERE USERID = "userid"

How do I get that to work?

Re: SELECT Records based on an array of values [message #259157 is a reply to message #259152] Tue, 14 August 2007 09:41 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Something like this should work:
declare

type userid_tab is table of varchar2(10) index by binary_integer;
userids userid_tab;
v_userid marc_user_test.userid%type;

begin
userids(1) := 'USER1';
select userid 
into   v_user_id 
from   marc_user_test 
where userid = userids(1);
end;  

Re: SELECT Records based on an array of values [message #259168 is a reply to message #259152] Tue, 14 August 2007 09:57 Go to previous messageGo to next message
hdogg
Messages: 93
Registered: March 2007
Member
So, are you saying to upload the array into a temporary table then retrieve those for the query?
Re: SELECT Records based on an array of values [message #259177 is a reply to message #259152] Tue, 14 August 2007 10:31 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Ummm Nooo ..

I thought you were looking for syntax on how to query an array element.

I just reread the OP If it is an Oracle Forms checkbox, this might be better served in the FORMS forum

[Updated on: Tue, 14 August 2007 10:32]

Report message to a moderator

Re: SELECT Records based on an array of values [message #259251 is a reply to message #259177] Tue, 14 August 2007 19:32 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
If this is a Forms question then I would assume that you would be using a Forms item as the search variable, that is, :blk.userid.

David
Re: SELECT Records based on an array of values [message #259368 is a reply to message #259251] Wed, 15 August 2007 05:19 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
At a glance, I have understood the question as the following.
1. You are building an array with some user ids.
2. Later you want to select items.
Quote:
I want to SELECT items from a database with those userid's
SELECT USER_ID FROM USERS WHERE USERID = "userid"

But for what purpose the above sql is used.
Anyway if you want to put all the userids in the where clause,
I think you can do that using an execute immediate by generating an userid string.
select item_id
  bulk collect
  into <item_array>
  from items
 where user_id in (1231,.......);
By
Vamsi
Re: SELECT Records based on an array of values [message #259399 is a reply to message #259368] Wed, 15 August 2007 09:17 Go to previous message
hdogg
Messages: 93
Registered: March 2007
Member
The array is populated from a php checkbox form...

Hence the array

$_GET['userid'] 


is populated when a user checks the boxes and hits submit.

So I need to bring the external array and find a way to through it in the sql and select those specific userids that were selected.
Previous Topic: get ROWID
Next Topic: frm-40735:post_query triger rasied unhandled exception ora-06502
Goto Forum:
  


Current Time: Sat Dec 03 13:54:10 CST 2016

Total time taken to generate the page: 0.10197 seconds