SQL & PL/SQL :: Select From List Of Literal Values?
Jul 18, 2011
Is there a way to loop through a list of literal values.
For instance
create table car(
name varchar2(11),
passengers int,
price int
);
insert into car values ('fiat',1,1000);
insert into car values ('bmw',2,2500)
insert into car values ('ford',2,1500)
insert into car values ('ferrari',4,5000)
select
max(price)
from car
where passengers=1
How can i in a single query do this for where passengers = 1
then passengers = 2
then passengers = 3 etc
where i have a list of possible values for passengers.
Just to update I realise this can be done with
select
name,
max(price)
from car
where passengers in (1,2,3)
group by name
but in just wanted to know if there is a way of iterating through a literal list in tsql
I have a requirement like getting list of values from one table and inserting them into another table.I have tried with sub querying but didn't worked out because the select query is returning multiple values.
how to proceed further and the ways how can I write this requirement.
I am trying to select multiple values from a parameter form based on a select statement.
I created the parameter and write the select statement under list-of-value property However what I want is to let users choose multiple values from the select statement not only one value.
If i try to find length of the string with more than 4000 char in SQL Developer it throws error "ORA-01704: string literal too long". if anything i need to SET in preference.
select length('string with more than 4000 char) from dual;
I M USING APEX 4.1 AND CREATED SELECT LIST ON PAGE, I WANT TO SHOW MIN VALUE OF THE SELECT LIST FOR THAT I WROTE IN THAT SELECT LIST PROPERTIES UNDER DEFAULT TAG MIN; AND CHOOSE PL/SQL EXPRESSION BUT ITS GIVING ERROR "Error computing item default value for page item P1_PRODUCT."
BUT IF I HARDCORE THE VALUE CONTAINING IN MY DATA LIKE PRODUCT ID = 1, I HARDCODED IN DEFAULT VALUE 1 AND SELECT PL/SQL EXPRESSION IT WORKS.
BUT ITS NOT DONE LIKE THIS I WANT TO SELECT BY DEFAULT MIN VALUE OF THE SELECT LIST, SO THAT THE DATA SHOULD BE DISPLAYED ACCORDING TO THAT.
THE EXACT REQUIREMENT IS TO ENTER THE SELECT LIST DEFAULT VALUE IN SESSION SO THAT DATA IS TO BE DISPLAYED.
I have developed one sample form using oracle Internet developer Suite 10g. It has two fields.
1.all employees(I set as combobox) 2.members (i set as text box)
In runtime all employees column has all the employee name displayed . If i select the employee name one by one it added into the members textbox. How to solve that issue?
I am using PL/SQL Developer.I have two tables: A and BTable A contains serial_from and serial_to values.This is used to define the serial numbers issued to customers (i.e. the start and end range of serial numbers issued).Shown here for a client:
Table B contains the individual numbers, B.serial (within the serial_from and serial_to range) along with other data, and is only created when the serial is used by the client.
I would like to create a list of records for individual clients containing serial numbers issued but not used. i.e. they are in between the serial_from and serial_to values in Table A, but not in Table B.
How can I create a list of numbers issued, but not yet used? Because Table A contains only two values (to and from) no record exists for them, so how do I generate a list and check against it?
I have made one LOV for vendor_names. On form level i want that when the user will enter a particular alphabet in a textbox assigned with LOV, the list should popup with only those elements starting with that particular alphabet. I have written the following code in the query of LOV wizard
query:
select distinct(bpt_ven_nm),bpt_ven_cd from bill_hdr1_tab where bpt_ven_nm like ('enter.vendr_nm'||'%') order by bpt_ven_nm
Wherin 'Enter' is the name of block and 'vendr_nm' is field name.
But its getting unsuccesfull. Any alternate way to get this result.
I have one drop down list box from which i want to do add or copy the values chosen from the list to another text box and then using this copied values ,i will pass them as parameters to run report.This list is getting populated using recordgroup and then what ever user chooses , it will be added to the another text box with space or delimiter.
Is it possible to filter each row in a select statement based upon a list that you loop through. For instance in a where clause having an in statement but rather than selecting any value in the in statement looping the main select through each value in the "in" filter.
Eg:
CREATE TABLE TRANSAC( Item_id number , Transaction_Date DATE, Category_id number )
You could then write
SELECT MAX(Transaction_Date) from TRANSAC where category_id = '141'
and then where category_id = '142' then '143' etc.
I understand i could use an inline view instead of a where clause but the issue is that i already have the list of values I want to compare against.
I am using Apex 4.1 and I have a select list in my page. I know i can access the value of the selected item by :P1_SelectList, but I would like to know how to access the display value of the selected item.
I have 3 tables in the Oracle database( emp, employee, emp1) which has following record values in it.
empidenamejob 7369, 'SMITH', 'CLERK'
I would like to list these 3 tables thru SQL/PLSQL, having the above record values combination. Also, the name of the columns could be different in all the tables i.e. name could be 'ename' in Emp table , and 'name' in Employee table. Is there way to do this in SQL or PLSQL ?
I created list of values like Bar chart,Column Chart,Pie Chart.these list of values added to the text field named as Chat type. In same region i created 3 chart sub regions. My requirement is if i select chart type-pie chart.the page will show only pie chart region only.Same to Bar chart and Column charts also.
I need to get multiple code values and put it into a variable which later need to pass into the where clause of an sql. But i am not getting any results even i pass those values in the variable of an where clause: below is my Procedure:
declare TYPE crMain_record is RECORD ( v_code dummy.v_code%type, n_no dummy.n_no%type,
[Code].....
END;"lv_character" is going to hold the multiple code values which i need to pass into whare clause of the above SQL: the totlal number of these mulitipe codes can be more then 50..
And lv_character values are commung from a setup table lv_character varchar2(32767):= '('||''''||'COMMIS'||''''||' , '||''''||'AGY BUILDING BENS'||''''||')'; --And lv_character values are commung from a setup table.where "lv_character" holdes multipe code values... And lv_character values are commung from a setup table and upper(d.v_code)in lv_characterif the
In my forms(version 9i), list item values showing with ALT + DOWN key combination but I want to change it to only DOWN key.I search this combination in FMRWEB.RES file but there isn't any entry of ALT + DOWN.
I have a 'Select List' widget (P_FILTER) which I have set to return multiple values. In my report region, I have something like this
Select A from B where B.Col_1 IN upper(:P_FILTER)
When user selects only 1 value, the report is correct but if user selects more than 1 value (e.g. 2), the report does not return any rows. How do I get the report to recognize the multiple values returned by the LOV?
I would like to enter input in for a select list. That is, if I have a select list for the common colours (blue, green, red, ... ) that a user could query on, then I would like a user to be able to type in the colour - purple in the box next to the select list. I've looked at the select list options and couldn't see anything obvious?
I have Select list itemS based on Lookup tables. When the form in Edit mode, I want to prevent the end user from changing the value of these Select list items. How can I accomplish this ??? **If I change the type of the item to Display only, then it will show the returned value of the Select list.
We have recently shifted our database from 10G to 11G and after the intial hickups most of the thinghs have stablised. We had changed system by Alter System command so that database does not have case sensevity problem and with that all the reports from the forams have also stabilied However some of the forms are failing with the above error ORACLE ERROR Unable to read list of values
These form are running fine with users having DBA privelege. However other users this is failing.
We have also checked that with users not having DBA privelege we are able to read the data in the table within the form also. The query in the record group is very simple
"SELECT CODE,SHORTDESC FROM GENCODES WHERE CODETYPE='BS' AND CODE <> '00'"
All these forms were fine previously when database was on 10g.
Moreover there are many other fields where list of values are there and allthose are ruing fine.
I have also checked datatype and length in query as well as fields on the form
How can i apply currency format to the select list values queried from database tables. The data is stored in database in number format. The user wants to see 1000 separator commas in the list item values.