Help on passing multiselect list as in values to function in database
I am having problemn passing multiselect list as in values to function in database
I have a static multiselect list :P1_SELECT_LIST
10
11
12
13
14
15
I am passing to another item :P2_SELECTED_LIST
('10','11','12','13')
I have to send :P2_SELECTED_LIST to a DATABASE PACKAGE(P_DATABASE).FUNCTION(PASS_LIST)
P_DATABASE.PASS_LIST(P2_SELECTED_LIST)
IN MY PASS_LIST(FUNCTION)
function PASS_LIST(P_STRING IN VARCHAR2) IS
type T_EMPNO is table of VARCHAR2(10) index by binary_integer;
type T_ENAME is table of VARCHAR2(6) index by binary_integer;
v_EMPNO T_EMPNO;
v_ENAME T_ENAME;
CURSOR C1 IS SELECT EMPNO,ENAME FROM EMP
WHERE DEPTNO IN P_STRING/* ('10','11','12','13')*/;
BEGIN
OPEN c1(P_STRING);
FETCH c1_axl bulk collect
into v_EMPNO, v_ENAME limit 40000;
CLOSE c1;
FOR I IN 1 .. V_EMPNO.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('V_EMPNO.COUNT :'||V_EMPNO.COUNT);
END LOOP;
END;
any help
This link may help:
Re: Date Time field
Denes Kubicek
Similar Messages
-
Pass a list of number values to a pl/sql function
I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause. Ideally I would like to do the following:
CREATE OR REPLACE FUNCTION ( dept_list in varchar2) is
begin
select ... where dept in (dept_list) ;
usage: process_list ( '7730,7735,7740,7745') ;
I can not find an example of doing this in pl/sql function but it seems feasible.
Is there a way to do this?user12088323 wrote:
I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause.
usage: process_list ( '7730,7735,7740,7745') ;The first thing is you need an appropriate data type to store a list of numbers. A single character value that looks to you like a list of numbers, is not in fact a list of numbers but a single character value.
This example uses the built in data type odcinumberlist in a procedure, you can do the same in function
Re: Passing an array to an Oracle stored procedure
If you have an old version of the database you may need to create your own type with the same definition of odcinumberlist. -
How to pass multiselect list values to javascript?...
Hi, guys...
(continuation...)
Here is a Q. I have two multiselect lists item on the page. I need to use the values of these items in ODP. The button calls javascript, and javascript envoke ODP. Everything is working fine if i submit the page and then call javascript, But this is extra step and it's not kind of cool...
So i am looking for the way to pass the value of multiselect lists to javascript without submitting the page first...
Thnks...
Mike
Edited by: mishkar on Oct 1, 2009 10:59 AMMike:
Try using v('page_item') instead of :page_item in the ODP code
varad -
Repopulating a multiselect list with saved values
Hi,
I am new to using HTML DB and have been searching the Internet on information I could find about it.
I found some useful information about multiselect boxes and can get the inserts to work but I am having problems with the repopulating of the multiselect from the underlying table.
I am using the following code to get the information from the table and the process point is On Load - After Header.
DECLARE
l_selected HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
BEGIN
SELECT risk_owner_id BULK COLLECT
INTO l_selected
FROM rmd_risk_risk_owners
WHERE risk_id = :P34_RISK_ID;
:P34_RISK_OWNER_ID := HTMLDB_UTIL.TABLE_TO_STRING( l_selected );
END;
but the multiselect list doesn't seem to repopulate with the values.
Does anyone have an idea I what I could be doing wrong from their previous experience. Any suggestions would be appreciated.
Regards,
Scott.Lets break the problem statement in multiple steps
1. We need a way to know the selection on all rows.
2. We need the association of the checkBox with the data
The solution is to use a arrayCollection/array that holds all the instances created for checkbox.This collection should be a property of component containing the datagrid. We need to use a custom component implementation or inline ItemRenderer. The way you have used is called dropinItemRenderer. Preferaly use custom component implementation and add the instance to the arrayCollection at CreationComplete. Make sure you use addItemAt so that you add the instance in the same row as the data. To get rowIndex the custom Checkbox should implement IDropInListItemRenderer. You could iterate this collection to check all the instances that are checked.
Note: This is the approach considering your dataprovider doesnt have a selection field.
Nishant -
Passing dynamic list / array of values to Droplet
I want to know what's the best way to pass list of values as array or list to a droplet.
Any examples here?u can refer to the following droplet , it uses both list and array
<droplet bean="/atg/commerce/pricing/PriceEachItem">
<param name="items" value="param:product.childSKUs">
<!-- the product param is already defined in this scope so we do not need to set it -->
<oparam name="output">
<!-- Now iterate over each of the CommerceItems to display the prices -->
<droplet bean="/atg/dynamo/droplet/ForEach">
<param name="array" value="param:element">
<param name="elementName" value="pricedItem">
<oparam name="output">
<valueof param="pricedItem.auxiliaryData.catalogRef.displayName"></valueof> -
<!-- Toggle a different display depending if the item is on sale or not -->
<droplet bean="Switch">
<param name="value" value="param:pricedItem.priceInfo.onSale">
<oparam name="false">
<valueof param="pricedItem.priceInfo.amount" currency>no price</valueof>
</oparam>
<oparam name="true">
List price for <valueof param="pricedItem.priceInfo.listPrice" currency>no price</valueof>
on sale for <valueof param="pricedItem.priceInfo.salePrice" currency></valueof>!
</oparam>
</droplet><BR>
</oparam>
</droplet>
</oparam>
</droplet> -
Hi,
1. I understand that multiselect list problem has discussed here multiple times but I could not find any answer for my situation. May be someone can give me an advise.
I have a page that has 8 multiselect lists. A user makes his selection, presses button “Report” and gets redirected to the report page (say page A) that displays records according to the user selection. Report source on page A is PL/SQL function body returning SQL query.
I created the button “Report” with wizard (selected option Submit Page & Redirect to URL). Everything was working fine till report was created in the same browser window. But a customer wanted to have a report displayed as a new page. So I changed ”Optional URL Redirect” target from “No Target” as it was before to URL and inserted a call to the JavaScript as URL Target ( I use this approach on several other pages).
Now when a user presses “Report” button he is redirected to the page A but that page displays completely different set of records. It looks like multiselect lists values are not passed to the report on page A any more. What am I missing?
2. As I mentioned before a main page has 8 multiselect lists so SQL statement is very long and I will need to create a lot of different reports based on the selections in those multiselect lists .
Is it possible to create an Application Level Variable, pass “WHERE” part of the SQL statement into it when button “Report” is pressed ( button has setting Submit Page & Redirect to URL!) and then use it in the SQL report source to generate reports?
Thank you in advance.
ValScott,
Thank you for your reply.
At the moment I switched to the URL it stopped passing multiselect list parameters( I have javascript function in the HTML Header section and call this function from the button).
If I understand the problem correctly I do not submit page as it was before. Session window does not show any parameters.
The only reason I need this switch - create a report in a new window.
Val -
How to get the selected values from multiselected list
Hi,
I have a multiselect list displaying all the years from 2003 to 2008 (used dynamic LOV). The user can choose one or more years as per his needs, and then when user clicks on the link the selected values of the list are to be captured and a pop up page of a Discoveror report needs to be opened where these years get passed as a parameter. I tried several methods to capture the value, but either one or all are getting passed but not exactly what the user has chosen.
This is how it looks:
P2_FISCAL_YEAR is a multiselect list containing values from 2003,2004... 2008
If user chooses 2004 and 2007
then I want the url to capture these values and pass as parameters for my discoveror reports. as '&qp_fiscal_year=2004,2007'
Any help is appreciated!
Thanks in advance,
Sapna.Hi,
I have a multiselect list displaying all the years from 2003 to 2008 (used dynamic LOV). The user can choose one or more years as per his needs, and then when user clicks on the link the selected values of the list are to be captured and a pop up page of a Discoveror report needs to be opened where these years get passed as a parameter. I tried several methods to capture the value, but either one or all are getting passed but not exactly what the user has chosen.
This is how it looks:
P2_FISCAL_YEAR is a multiselect list containing values from 2003,2004... 2008
If user chooses 2004 and 2007
then I want the url to capture these values and pass as parameters for my discoveror reports. as '&qp_fiscal_year=2004,2007'
Any help is appreciated!
Thanks in advance,
Sapna. -
I created a Multiselect list for item :P5_REGIONS(USING DYNAMIC )
DYNAMIC QUERY IS
SELECT DISTINCT DEPTNO FROM DEPT;
Mutiselect list
10
20
30
40
50
I have another item name :P5_SELECTED_REGIONS
So what I want to do is
When user select multi values from Multiselect list
10,20,30,40
I want to display in :P5_SELECTED_REGIONS as string '10,20,30,40'
I have another Submit button which will take the :P5_SELECTED_REGIONS values and pass to database package
Any help is appreciatedHi,
Add the following into the regions "Region Header" setting:
<script type="text/javascript">
function showSelected(item, field)
var sel = new Array();
var index = 0;
for (var intLoop = 0; intLoop < item.options.length; intLoop++)
if (item.options(intLoop).selected)
index = sel.length;
sel[index] = item.options(intLoop).text;
$f_SetValue(field, sel.join());
</script>
add the following into the HTML Form Element Attributes for the select list:
onchange="showSelected(this, 'P5_SELECTED_REGIONS');"
That should do it.
Regards
Andy -
ApEx newbie here,
I'm trying to get the output of a multi select list into an in list of a sql query for a report. The error message I'm getting is report error:
ORA-01722: invalid number. (The inlist is a list of id numbers, and the data type for this column in the database is NUMBER)
I've got a page item called P3_x which is populated from a MultiSelect list. I learned that these come out as colon delimited strings. (found a reference to hidden items in a blog that helped me figure this out)
So I created a hidden item called P3_x_in_list which does this:
Select '('|| regexp(:p3_x,':',',')||')' from dual which turns this into a comma separated list, like so: (1,2,3,4)
I put this hidden item, P3_X_IN_LIST into the sql in my report region
So in the report my sql looks like:
select a, b, c
from t1
where id in: P3_x_in_list
and some_date between :P1_X and :P2_X
For some reason it throws an invalid number error when it runs. I haven't been able to find anything in the documentation or on the web that sheds any light on this. I'm hoping that there is a benevolent, experienced developer that can point me in the right direction. The debuging information from the page is below:
Here is the debugging information
0.24: ...Session State: Save "P3_X" - saving same value: "1:2:3:4:5"
0.24: ...Session State: Save "P1_X" - saving same value: "01-DEC-2008"
0.24: ...Session State: Save "P2_X" - saving same value: "04-DEC-2008"
0.30: ...Session State: Save Item "P3_X_IN_LIST" newValue="(1,2,3,4,5)" "escape_on_input="N"
0.30: Processing point: ON_SUBMIT_BEFORE_COMPUTATION
0.46: show report
0.46: determine column headings
0.46: parse query as: my_schema
1.76: binding: ":P3_X_IN_LIST"="P3_X_IN_LIST" value="(1,2,3,4,5)"
2.64: binding: ":P2_X"="P2_X" value="04-DEC-2008"
report error:
ORA-01722: invalid number
ORA-02063: preceding line from my_schema
3.23: Computation point: AFTER_BOX_BODY
3.23: Processing point: AFTER_BOX_BODY
3.23: Computation point: BEFORE_FOOTER
3.23: Processing point: BEFORE_FOOTER
3.23: Show page tempate footerWell, let's say you had a SQL statement like
select * from obj where object_id in 12345
where object_id is defined to be a number type.
Now, if you replace the literal '12345' with a bind variable and then bind "(1,2,3,4,5)" to this bind variable it will be clear why the SQL fails.
As for using pipeline functions it is pretty straightforwad
Here's an example
CREATE OR REPLACE TYPE vc_array_1 AS TABLE OF VARCHAR2 (50);
CREATE OR REPLACE FUNCTION get_list (
p_string IN VARCHAR2,
p_delimiter IN VARCHAR2 DEFAULT ':'
RETURN vc_array_1 PIPELINED
IS
l_string varchar2(32000);
l_array wwv_flow_global.vc_arr2;
BEGIN
l_array := apex_util.STRING_TO_TABLE(p_string,p_delimiter);
for i in l_array.first..l_array.last loop
pipe row (trim(l_array(i)));
end loop;
return;
end;
select column_value from table (get_list('1:2:3:4:5'));Your query can now be
select a, b, c
from t1
where id in (select column_value from table get_list(: P3_x_in_list)) )
and some_date between :P1_X and :P2_XVarad -
Delete in database based on multiselect list values
Hi,
I have a selectlist in Apex and a function in the database to do some delete based on the selected value from the select list.
FUNCTION delete_batch (v_batch VARCHAR2) RETURN VARCHAR2
IS
BEGIN
IF v_batch like 'M%'
THEN
RETURN ('A monthrun cannot be deleted');
ELSE
DELETE FROM so_disco_pa
WHERE batch = v_batch
DELETE FROM so_batch_pa
WHERE batch = v_batch
COMMIT;
RETURN ('Batch '||v_batch||' has been deleted');
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN ('Batch could not be deleted');
END delete_batch;The package function is called when the delete button is clicked with following process:
BEGIN
DECLARE
x varchar2(100);
BEGIN
x := pa_control.delete_batch (:P3_BATCH);
:F105_MESSAGE := x;
END;
END;Now I want to change the selectlist to a multiselect list so that multiple batches can be deleted.
How do I change my procedure and process to delete batches based on the selected values?
Thanks,
DianaI got this so far, but only the first batch selected in the list is being deleted. The other selected batch values are not deleted.
Some help please.
FUNCTION delete_batch (v_batch VARCHAR2) RETURN varchar2
IS
T Apex_application_global.vc_arr2;
BEGIN
T := apex_util.string_to_table(v_batch);
For I in 1..t.count loop
IF t(i) like 'M%'
THEN
RETURN ('A monthrun cannot be deleted');
ELSE
DELETE FROM so_disco_pa
WHERE batch = t(i)
DELETE FROM so_batch_pa
WHERE batch = t(i)
COMMIT;
RETURN ('Batch '||v_batch||' has been deleted');
END IF;
end loop;
EXCEPTION
WHEN OTHERS THEN
RETURN ('Batch could not be deleted');
END delete_batch; -
Help with Multiselect List Item
Assuming one employee can work for multiple departments, I want to display the departments employee 7844 works for preselected in a multiselect list.
I am using the following query statement in a report region.
select htmldb_item.select_list_from_query_xl(1, deptno ,'select DEPTNO,DNAME from scott.dept ','MULTIPLE HEIGHT=25', 'Y',null,null,null,'Department',null) a from scott.emp where empno = 7844
The result I am seeing is a multiple multiselect lists with one department selected in each list.
How should I modify the query to get what I want?
Thanks
MinaHi Carlos,
I set up a test case in exactly the same way and it worked fine for me. I created a page item called P1_DA_DEMO and added some static select list values then added some help text. The settings I used are below, I suggest you try again but also make sure you have no other Javascript errors on the page. Use a tool like firebug to check.
Name : Dynamic Action Demo
Sequence: 10
Even: Click
Selection type: Item(s)
Item(s): P1_DA_DEMO <- a selection list item
Condtion: - No Condition -
True Actions
Sequence: 10
Action : Execute JavaScript Code
Fire when event result is :True
Fire on page load: Not Ticked
Code: javascript:popupFieldHelp('277938589795252851','1545903379570909')
Event Scope set a s Bind.
Thanks
Paul -
Hi,
I have a procedure which accepts in parameter
email_list. this is of type merge_email.
Now merge_email is a record type:
TYPE merge_email_value IS RECORD (
contact_type_id number,
contact_email_id varchar2,
email_address varchar2,
email_priority varchar2
type merge_email is table of merge_email_value ;
i want to test this procedure. how will i pass multiple values to this parameter?
eg:
1'st set of email:
1,2,[email protected],3
2'st set of email:
1,2,[email protected],2
i want to pass these two sets of values at a time to this IN parameter email_list. How can i achieve this?
Thanks for your help
Edited by: user13294597 on Jun 17, 2010 4:53 AMHi blueforg,
It is not an SQL type...but a PL type... and karthik had put another proc in the pkg to assign the values...but i suppose it is not possible to assign values from outside the pkg....smthng like you have done...
i tried karthiks approach by defining a similar type outside
eg:
declare
type t1_temp is record(contact_type_id number,
contact_email_id varchar2(20),
email_address varchar2(20),
email_priority varchar2(10));--same record as defined in PKG.
t1_temp1 t1_temp:=t1_temp();
begin
t1_temp1.extend();
t1_temp1(1).id1:=1;
t1_temp1(1).id2:=1;
t1_temp1.extend();
t1_temp1(1).id1:=2;
t1_temp1(1).id2:=2;
p_test_pkg.p_test(t1_temp1);
end;--this does not seem to work... -
Build Dynamic Query based on values of multiselect list
I am trying to implement the same functionality as shown in this app.
http://htmldb.oracle.com/pls/otn/f?p=9741:6:13406902443304236283:::::
I have hit a brick wall when I try to set the value of my text area/select statement, even after viewing the detail section in above app.
Does anybody know exactly how I can set the value of a text area from multiselect list values??Hi Sam,
check out How to use multi select in a query report
See also Denes sample application which has and example where you can still do an index access if a index is defined for the column. http://htmldb.oracle.com/pls/otn/f?p=31517:138
Patrick
My APEX Blog: http://inside-apex.blogspot.com
The ApexLib Framework: http://apexlib.sourceforge.net
The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/ -
How to get multiselect list values
I have a multiselect list set up called :P_Staff_ID which uses a LOV (select staff_name, staff_id from staff)
to display staff names to the screen.
What function can i use to get all the selected names in the list for my submit process?
Thanks
RayRay,
The selected values will be returned as a colon delimited list, e.g.: 20:30:40:50
You can use the htmldb_util.string_to_table function to convert it to something a more suitable for inserting. This is the spec of the function from the documentation:
HTMLDB_UTIL.STRING_TO_TABLE (
p_string IN VARCHAR2,
p_separator IN VARCHAR2 DEFAULT ':')
RETURN HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
and a sample that loops over the values:
DECLARE
l_vc_arr2 HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
BEGIN
l_vc_arr2 := HTMLDB_UTIL.STRING_TO_TABLE('One:Two:Three');
FOR z IN 1..l_vc_arr2.count LOOP
htp.p(l_vc_arr2(z));
END LOOP;
END;
Sergio -
Help in passing value to next .asp page
Hi all, i need help on this problem. i want to pass the value of tag_num and platform to the detail.asp, somehow it give me error. below are my code and screenshot.
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td height="50" bgcolor="#FFFFFF"><span class="style2"><%=(Recordset1.Fields.Item("tag_num").Value)%></span></td>
<td height="50" bgcolor="#FFFFFF"><span class="style2"><%=(Recordset1.Fields.Item("platform").Value)%></span></td>
<td width="205" bgcolor="#FFFFFF"><span class="style2"><%=(Recordset1.Fields.Item("system").Value)%></span></td>
<td width="41" bgcolor="#FFFFFF"><a HREF="detail.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "tag_num=" & Recordset1.Fields.Item("tag_num").Value & "platform=" & Recordset1.Fields.Item("platform").Value %>">VIEW</a></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
"part of detail.asp code to receive the value"
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("tag_num") <> "") Then
Recordset1__MMColParam = Request.QueryString("tag_num")
End If
%>
<%
Dim Recordset1__MMColParam2
Recordset1__MMColParam2 = "1"
If (Request.QueryString("platform") <> "") Then
Recordset1__MMColParam2 = Request.QueryString("platform")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_InstrumentDB_STRING
Recordset1_cmd.CommandText = "SELECT * FROM Instrument_baram WHERE tag_num = ? AND platform = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 255, Recordset1__MMColParam) ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param2", 200, 1, 255, Recordset1__MMColParam2)
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
to display the dable, this is my code
<table width="450" border="1" cellspacing="0" bordercolor="#FF6600" bgcolor="#1941A5">
<tr>
<th style="background-color:#CEC49D" height="35" scope="row"><span class="style2">TAG NUMBER</span></th>
<td bgcolor="#FFFFFF"><span class="style2"><%=(Recordset1.Fields.Item("tag_num").Value)%></span></td>
</tr>
<tr>
<th style="background-color:#CEC49D" width="200" height="35" scope="row"><span class="style2">PLATFORM</span></th>
<td width="356" bgcolor="#FFFFFF"><span class="style2"><%=(Recordset1.Fields.Item("platform").Value)%></span></td>
</tr>
<tr>
<th style="background-color:#CEC49D" height="35" scope="row"><span class="style2">TYPE OF SYSTEM</span></th>
<td bgcolor="#FFFFFF"><span class="style2"><%=(Recordset1.Fields.Item("system").Value)%></span></td>
</tr>
it give me this error
Please somebody help me. Thanks in advance.
Regards,
Zuma.yup. my page connected to the server. if i pass "tag_num" value only, it will give me no error. the output is there. but the things is i need to pass "platform" value.
sample of my database structure is
Instrument_baram
tag_num platform field system
AGSC_503
BNP-C
BARONIA
PMCS
AGSC_503
BNP-B
BARONIA
PMCS
TAG NUMBER
TYPE OF INSTRUMENT
SYSTEM
PLATFORM
AGSC_503
Limit switch
PMCS
BNP-C
View
AGSC_503
Limit switch
PMCS
BNP-B
View
if i pass "tag_num" value only, it will select AGSC_503 platform BNP-C only eventhough i click on AGSC_503 platform BNP-B "View".
that why i need to pass the "platform" value
Maybe you are looking for
-
Dear All, We have a issue like this: Say, there is a Customer who has given an order of ABC product 10 packs to the sales employee. And the order is placed on say 15.09.2011 and as we could not produce the product the next two days also, the product
-
Need Help on How to Change The Encryption Key and or Change security settings
Hello, i just installed the wireless router and i would like to know how i can change the encryption key or change the security settings (i want it so you do not have to answer it with a password). Thank you in advance. Message Edited by DARK_MARIO o
-
When I open a PDF file the only options I have under Tools are: 1. Export PDF Files 2. Create PDF Files 3. Send Files While watching a tutoral video on how to create a form from a scanned document I see the following options under Tools: 1. Pages
-
ListCellRenderer and JList... cannot set the selected background?
The following code: public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus ) setText( "test" ); setBackground( isSelected ? list.getSelectionBackground() :
-
Logic is only snapping tempo to some beats in 3/4 time.
I'm using Logic Pro 8. When I automate the tempo in 3/4 time, the new tempo will only snap to every 4 beats. I can't change it on the bars and beats I want. Any ideas? Many thanks