Is this possible? range query
I have a db with keys/data as the following
Key data
AA data1
AB data2
AA data3
AB data4
AA data5
AB data6
what I expect is
if search by key =AA return data1,3,5,
if searcy by key = A, return all records
when I query using DB_SET_RANGE
query A, only get all records with key ==AA
seems this is correct output based on the API description, while this is not so-called range query.
is it possible to get what I expect above? use a new BTree comparsion function? if so, AA and AB is treated as the same key, and will not be able to differentiate AA and AB.
right?
there are several threads on this, did not the answer. thanks
The DB_SET_RANGE flag is identical to the DB_SET flag, except that in the case of the Btree access method, the key is returned as well as the data item and the returned key/data pair is the smallest key greater than or equal to the specified key (as determined by the Btree comparison function), permitting partial key matches and range searches
Hi,
Let's consider your database:
key data
AA data1
data3
data5
AB data2
data4
data6
If you do a DBC->c_get() with DB_SET_RANGE and as search key "A" than the cursor will be positioned on the first key/data pair AA - data1. This is correct and complies with the documentation. If you than iterate with DB_NEXT on the DBC->c_get() call (as presented in the previous range_query function) you will sequentially retrieve each record within the database (the records are sorted lexically by key, and duplicates are sorted lexically on the data portion - by default). When you iterate with DB_NEXT_DUP on the DBC->c_get() call you will retrieve the records with the "AA" key.
If you do the DBC->c_get() with DB_SET_RANGE and a search key "AA" than the cursor will be positioned, as in the previous case, on the first key/data pair AA - data1. The same applies when iterating with DB_NEXT or DB_NEXT_DUP.
When you do a range search on "AA" and iterate with DB_NEXT you will get all the records because all the records have the key equal or greater (lexically) than "AA".
The same goes for a range search on "A" and iterating with DB_NEXT.
If you expect to get data1, data 2, data3 when searching on "AA" than this is not a range search, it is a simple query (done with DB_SET initially and than iterate with DB_NEXT_DUP).
If you use the function that I posted previously (exactly as it is) and you pass it "A" as searchKey then you will retrieve all the records, just as you expected.
Here is an excerpt from the documentation:
DB_SET
Move the cursor to the specified key/data pair of the database, and return the datum associated with the given key.
The DBcursor->c_get method will return DB_NOTFOUND if DB_SET is set and no matching keys are found. The DBcursor->c_get method will return DB_KEYEMPTY if DB_SET is set and the database is a Queue or Recno database, and the specified key exists, but was never explicitly created by the application or was later deleted. In the presence of duplicate key values, DBcursor->c_get will return the first data item for the given key.
DB_SET_RANGE
The DB_SET_RANGE flag is identical to the DB_SET flag, except that in the case of the Btree access method, the key is returned as well as the data item and the returned key/data pair is the smallest key greater than or equal to the specified key (as determined by the Btree comparison function), permitting partial key matches and range searches.I hope this clarifies the way to deal with a range query, if not then let me know and I will present a program that demystifies this.
Best regards,
Andrei
Similar Messages
-
Is this Possible through a query?
Hi All,
i am calling this function in an update statement.
this function queries a table based on the conditions and will return the latest(max) date from table.
Is it possible to achieve this in a query?
CREATE OR REPLACE Function getmaxdate(pRLK_RK number,
pLN_RK number,pRLK_ACT_FLG varchar) Return date Is
vnum number(3);
pmaxdate date;
Begin
select (Trunc(RLOCK_END_DT) - Trunc(RLOCK_EXT_END_DT)) into vnum from rate_tab
where RLK_RK=pRLK_RK
and LN_RK=pLN_RK
and RLK_ACTIVE_FLG=pRLK_ACT_FLG;
dbms_output.put_line('Value of vnum'||vnum);
If vnum < 0 then
select RLOCK_EXT_END_DT into pmaxdate from rate_tab
where RLK_RK=pRLK_RK
and LN_RK=pLN_RK
and RLK_ACTIVE_FLG=pRLK_ACT_FLG;
elsif vnum > 0 then
select RLOCK_END_DT into pmaxdate from rate_tab
where RLK_RK=pRLK_RK
and LN_RK=pLN_RK
and RLK_ACTIVE_FLG=pRLK_ACT_FLG;
--return pmaxdate;
End If;
return pmaxdate;
dbms_output.put_line('Value of pmaxdate'||pmaxdate);
End;
Any suggestions?
Thanks.may be this
select (case when (Trunc(RLOCK_END_DT) - Trunc(RLOCK_EXT_END_DT)) <0 then
RLOCK_EXT_END_DT
when (Trunc(RLOCK_END_DT) - Trunc(RLOCK_EXT_END_DT))> 0 then
RLOCK_END_DT
end) max_date
from rate_tab
where RLK_RK=pRLK_RK
and LN_RK=pLN_RK
and RLK_ACTIVE_FLG=pRLK_ACT_FLG; -
SQL Query Help - Is this possible or impossible????
Hi guys,
I need help with an SQL query that I'm trying to develop. It's very easy to explain but when trying to implement it, I'm struggling to achieve the results that I want.....
For example,
I have 2 tables
The first table is:
1) COMPANY create table company (manufacturer varchar2(25),
date_established date,
location varchar2(25) );My sample test date is:
insert into company values ('Ford', 1902, 'USA');
insert into company values ('BMW', 1910, 'Germany');
insert into company values ('Tata', 1922, 'India');The second table is:
2) MODELS create table models (manufacturer varchar(25),
model varchar2(25),
price number(10),
year date,
current_production_status varchar2(1) ) ;My sample test data is:
insert into models values ('Ford', 'Mondeo', 10000, 2010, 0);
insert into models values ('Ford', 'Galaxy', 12000, 2008, 0);
insert into models values ('Ford', 'Escort', 10000, 1992, 1);
insert into models values ('BMW', '318', 17500, 2010, 0);
insert into models values ('BMW', '535d', 32000, 2006, 0);
insert into models values ('BMW', 'Z4', 10000, 1992, 0);
insert into models values ('Tata', 'Safari', 4000, 1999, 0);
insert into models values ('Tata', 'Sumo', 5500, 1996, 1);
insert into models values ('Tata', 'Maruti', 3500, 1998, 0);And this is my query:
SELECT
com.manufacturer,
com.date_established,
com.location,
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
mod.current_production_status
FROM
company com,
models mod
WHERE
mod.manufacturer = com.manufacturer
and com.manufacturer IN ('Ford', 'BMW', 'Tata')
and mod.current_production_status IN (1,0)
ORDER BY
mod.current_production_status DESCWhat I want the query to output is this:
com.manufacturer com.date_established com.location mod.model mod.price mod.year mod.current_production_status
Ford 1902 USA Escort 10000 1992 1
BMW 1910 Germany - - - 0
Tata 1922 India Sumo 5500 1998 1If current_production_status is 1 it means this particular model has been discontinued
If current_production_status is 0 it means the manufacturer does not have any discontinued models and all are in procuction.
The rule is only one record per manufacturer is allowed to have a current_production_status of 1 (so only one model from the selection the manufactuer offers is allowed to be discontinued).
So the query should output the one row where current_production_status is 1 for each manufacturer.
If for a given manufacturer there are no discontinued models and all have a current_production_status of 0 then ouput a SINGLE row that only includes the data from the COMPANY table (as above). The rest of the columns from the MODELS table should be populated with a '-' (hyphen).
My query as it is above will output all the records where current status is 1 or 0 like this
com.manufacturer com.date_established com.location mod.model mod.price mod.year mod.current_production_status
Ford 1902 USA Escort 10000 1992 1
Tata 1922 India Sumo 5500 1998 1
Ford 1902 USA - - - 0
Ford 1902 USA - - - 0
BMW 1910 Germany - - - 0
BMW 1910 Germany - - - 0
BMW 1910 Germany - - - 0
Tata 1922 India - - - 0
Tata 1922 India - - - 0However this is not what I want.
Any ideas how I can achieve the result I need?
Thanks!
P.S. Database version is '10.2.0.1.0'Hi Vishnu,
Karthiks query helped...
But this is the problem I am facing...
SELECT
com.manufacturer,
com.date_established,
com.location,
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
mod.current_production_status
FROM
company com,
models mod
WHERE
mod.manufacturer = com.manufacturer
and com.manufacturer = 'Ford'
and mod.current_production_status IN (1,0)
ORDER BY
mod.current_production_status DESCThe value of:
and com.manufacturer = 'Ford'will be dependent on front end user input....
When I run the query above I get all the rows where current_production_status is either 1 or 0.
I only require the rows where current_production_status is 1.
So if I amend it to look like this:
and mod.current_production_status = 1This works....
BUT if a user now passes in more than one manufacturer EG:
and com.manufacturer IN ('Ford', 'BMW')The query will only return the one row for Ford where current_production_status is 1. However because BMW has no models where current_production_status is 1 (all 3 are 0), I still want this to be output - as one row....
So like this:
com.manufacturer com.date_established com.location mod.model mod.price mod.year mod.current_production_status
Ford 1902 USA Escort 10000 1992 1
BMW 1910 Germany - - - 0So (hopefully you understand), I want both cases to be catered for.....whether a user enters one manufacturer or more than one...
Thanks you so much!
This is really driving me insane :-( -
Remome "Manual value entry" possibility in query filter
Hi everybody, i'm currently using Bex ver 7.0 and i have a problem. I need to find a way to dissable the possibility to enter any value manually in a query's filter. For example, when i run a query and i see the filter, let's say "Coste Center" the filter variable gives me the range of values, but also it gives me the values that had been entered before "History" and below it gives me the possibility to enter the values manually. I need to dissable this option, it has to be just the filter with authorixed values to choose from, no "History data" nor this little window for manual antry.
Do you happen to know if this possibility exist?
Thank you very much.
P.D. the points will be awarded for all your ideas!!Hi,
In the variable properties window, uncheck the "Ready for Input".
It will solve the problem.
Assign points if it helps..... -
Is it possible the query in view object is dynamic?
Is it possible the query in view object is dynamic?
Generally, make the column list dynamic.
I think this is related to whether view object can be assembled at runtime based on a dynamic cursor in a procedure?
I ask this because I would like to know how we can use OA framework to simulate crosstab workbook in Discoverer?
Anybody has some clues, please advise.
Thanks.Hi Shay,
Let me tell you briefly... I am sending input as customerId,customerNumber,CustomerName to the web service, if the record is available i am getting the response and i am displaying those records on page as a table. Now when i click a row i need to populate another table with all sale orders of that customer. From webservice datacontrol i have only customer object, I dont have Sales Order Object. For this i need master detail relation. In this case how to proceed. Thats why i am thinking to create a vO and EO object for sales orders table and i want to create view link for this sales order and customers. As i don't have customer VO and EO object to create view link. -
select empno,name,sum(sal) from emptable where year=' ' groub by empno order by empno.
this query getting error because i didn't include empname in group by.
But if i include this name, my sum is not correct.
so i want to empno,name but i don't want to include name in group by. Is this possible?
My oracle verion is 8.
IS any other solution to solve this problem?
Thanks in advance.i want to empno,name but i don't want to include name in group by. Is this possible?<br>
<br>
No. It isn't.
<br>
select empno,name,sum(sal) over (partition by empno) <br>
from emptable
<br>where year=' '
<br>
-- <s>groub by empno</s>
<br>
order by empno; -
HELP! JSP as items in a region - is this possible?
Hi All,
Can someone please tell me how to bring in a JSP code as an item or portlet within a region. Is this possible with Oracle9iAS release 2? I need to generate dynamic html within a particular region based on a query string parameter and I thought this is one way of doing it.
If anyone can help, that would be great!
Thanks in advance,
KimKim,
There are many articles on Portal Center that discuss building portlets from JSPs. You can also post questions on this topic to the PDK forum.
For PL/SQL, there are a number of options. You can build PL/SQL portlets - the dynamic page component is a good start, that is conceptually similar to JSPs.
You can also create PL/SQL items that can be rendered in-place or displayed as a link - make sure that you don't use the "Simple PL/SQL" item type, as you can't control the rendering behaviour. Use the supplied "PL/SQL" item type, or create your own custom item type based on "Simple PL/SQL".
Finally, any item type (except the "simple" ones) can be associated with a procedure that can generate dynamic content. The procedures can be PL/SQL or any function that can be invoked via a URL (e.g. a JSP or servlet).
Note that in your PL/SQL procedures you'll need to use the HTP package to generate HTML.
Regards,
Jerry
Portal PM -
I Need to Return Two values or more from Function, Is this possible?
Below is the offending query, I am trying to pass v_bu and v_po to this function, and after validations then return v_count and v_action is this possible in a function? I am having problem returning two values.
see below code
function po_edi_func(v_bu purchase_order.business_unit_id%type,
v_po purchase_order.purchase_order_number%type)
return number as pragma autonomous_transaction;
v_count number;
v_ctdel number;
v_action varchar2(1);
begin
select count(*)
into v_count
from sewn.purchase_order
where business_unit_id=v_bu
and purchase_order_number =v_po;
if v_count > 0 then
select count(*)
into v_ctdel
from sewn.purchase_order
where business_unit_id=v_bu
and purchase_order_number =v_po
and purc_orde_status = 1;
if v_count <> v_ctdel then -- ALl PO's Cancelled--
v_action := 'U'; -- - NOT ALL PO DELETED --
else
v_action := 'D'; -- DELETED ALL PO--
end if;
else
v_action := 'I';-- New PO INSERT--
end if;
commit;
return v_count;
end;Paul,
This is becoming a nightmare to me, can you look at the below and tell me where I am having a problem
This is the Function below
CREATE OR REPLACE function po_edi_func(v_bu sewn.purchase_order.business_unit_id%type,
v_po sewn.purchase_order.purchase_order_number%type,v_action_out OUT VARCHAR2)
return number as pragma autonomous_transaction;
v_count number;
v_ctdel number;
v_action varchar2(1);
begin
select count(*)
into v_count
from sewn.purchase_order
where business_unit_id=v_bu
and purchase_order_number =v_po;
if v_count > 0 then
select count(*)
into v_ctdel
from sewn.purchase_order
where business_unit_id=v_bu
and purchase_order_number =v_po
and purc_orde_status = 1;
if v_count <> v_ctdel then -- ALl PO's Cancelled--
v_action := 'U'; -- - NOT ALL PO DELETED --
else
v_action := 'D'; -- DELETED ALL PO--
end if;
else
v_action := 'I';-- New PO INSERT--
end if;
commit;
v_action_out := (lpad(v_count,8,'0')||lpad(v_action,1,' '));
return v_action_out;
end;
and this is how I am calling it from my trigger which has to pass the v_bu and v_po values to be used in extracting data and returning the records
see below
if po_edi_func(v_bu,v_po) <> '' then;
v_count:= (substr(v_action,1,8));
v_action := substr(v_actione,9,1);
else
v_count:=0;
v_action := 'I';
end if;
I need the extracted values of v_count and v_action for my app to reset some values -
Creating dynamic datasources. Is this possible?
Can I create a 'subset datasource' from an existing datasource
and then pass this subset datasource to the <jbo:RowsetIterate>
Let's assume I have a datasource containing 100 records.
How is is possible to create a new datasource from the exiting datasource
which will contain 10 records and then this new data source will be passed
to <jbo:RowsetIterate>?
I'd like to write a JSP Tag which reads the datasource and creates a subset datasource
dynamically
public class SubsetDS extends TagSupport
public int doStartTag() throws JspException
ApplicationModule am = dataSource.getApplicationModule();
ViewObject vo = am.findViewObject("V0");
while(vo.hasNext()){
Row r = vo.next();
// Iterate based on a certain condition and put the new records
// in a dynamically created DataSource
Is this possible?I don't know about the custom JSP tag part, there is a <jbo:CreateViewObject> tag and ApplicationModule.createViewObject() methods for defining ViewObjects at runtime. We were not able to locate a mechanism for actually running a query against one VO to select rows for a second VO (whether defined at compile-time or runtime). We created a VO at runtime so we could base it's result set on another VO.
See "Ways to Add a View Object Instance to the Data Model at Runtime" topic in JDev help (we're using 10.1.2, but there's a <jbo:CreateViewObject> tag going back to at least 9.0.3.3); I located using JDev's Help's text search for createviewobject.
In our case, because the two queries were related (subset), we obtained the where clause from the VO that we defined at compile-time and whose where clause is being set at run time by values passed in from an HTML query form. We then applied that where clause to the dynamically created VO to get the desired subset.
Hope that gives you a starting place and helps. -
Is it possible to query Google finance using Flex?
Google Finance has an open API for programmers. Is it possible to query Google Finance using Flex?
Regards,
Pooja GuptaTo hold a servo motor at constant torque, all you need to do is provide a constant voltage. You can accomplish this using the analog output (DAC) of a FlexMotion board. To gain access to the DAC, configure the axis as an open loop stepper, then use the Load DAC.flx VI to output an analog voltage. The downside to this is that you won't have feedback, so you'll have no way to determine your position.
-
Invoke task from another process defnition - Is this possible
Is this possible to invoke task from another process defnition?
PD1 has task1
PD2 has task2
call PD1.task1 from PD2.task2
If possible, then what API method should I use.
Thank you!You would start by using the findObjects API to find all the objects for a specifc user. Then you would want to find the appropriate one from the result set. Then once you find this, you will need to either query the database or use apis to find the task key for the specific task name you want for that process definition. Once you have the process instance key and the task instance key for that user, you can then use the api to insert task into the users process instance.
Not sure all the APIs to use, but in the end you'll use addProcessTaskInstance found in the tcProvisioningOperationsIntf. You can search the forums for that API and examples of it's usage.
-Kevin -
IMPDP |Possible using Query option
HI PPL,
I wanted to Know whether IMPDP is possible using query option, as i have taken full expdp dump of the mentioned table and want to import only select rows.
impdp arup/arup directory=demo_dir dumpfile=employees.dmp
query=employees:\"where salary\>10000\ order by salary" tables=employees
version:10gR2
platform:UNIX
regardsHello,
Yes you can use QUERY parameter with IMPDP.
But the syntax may be a little bit different than with the old IMP utility:
QUERY
Default: There is no default
Purpose
Allows you to specify a query clause that filters the data that gets imported.
Syntax and Description
QUERY=[[schema_name.]table_name:]query_clauseYou may have more examples on the following link:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10701/dp_import.htm#BEHFGIGF
Hope this help.
Best regards,
Jean-Valentin -
I have two separate itune accounts under two different email accounts and would like to combine them under one account. Is this possible and if so, how do I do it?
If you go to Settings > iTunes & AppStore , you can sign out from your account, and sign in with the one you've used to purchase apps.This will not remove any apps you already have on it.
Then you can go to AppStore and download apps you've purchased (either via "Purchased" button in "Updates", or simply search for them and download them.
That way you can have multiple accounts' apps on your iPad. When updating, you will be prompted for the credentials for account you've purchased given App with. -
I work with a child who has physical disability and cannot move his neck. The ipad needs to be eyelevel in order for him to see it, but he also is not able to raise his hand and would need mouse access... is this possible?
I'm sorry but the iPad does not work with a mouse, there is no cursor on the iPad and the iPad was designed as a touch screen device so a mouse will not work.
I really don't know what to suggest other than this new device, and it might be worth a look. I assume that the child can use his hands for a keyboard.
http://www.thinkgeek.com/product/e722/ -
Unfortunately, I lost by an update all the apps on my iPad 2. Now I can not pull the data from the cloud to my iPad. How is this possible?
If you just installed iCloud does that mean you updated the iOS that's running on your iPad? If so, you'll want to restore all the programs you have from the backup you hopefully made.
Refer to these articles for help.
iTunes: Backing up, updating, and restoring iOS software.
If you don't want to use iCloud, simply don't activate it.
You can also download the programs again.
If you live in a country that supports re-downloading apps then you can re-download them. You can refer to this article for more help.
Downloading past purchases from the App Store and iTunes Store
What to know if your country supports downloading past purchases?
iTunes in the Cloud Availability
Maybe you are looking for
-
Changing the LTS and physical source of the presentation fields
I am using 11.1.1.6.2 obiee admin tool, in presentation layer I have 3 different subject areas and multiple folder with different names. I used same field in multiple folder in all the subject areas with same name , in below example I am using same f
-
Operation does not fetch in process order
hi PP-Pi gru, when i am creating process order from planed order , operation ( master recipe) does not fetch in process order..only take default operation 10, kindly suggest me how all operation will fetch in process order another mater is when assig
-
Downloaded Mountain Lion update 10.8.2 last night. All went well until the message after the download – restart your mac to install this update. The screen went white and the machine didn't restart. After waiting for quite a while, I shutdown using t
-
LaserJet 2600n Print Quality problem (with a scan showing the problem)
I'm trying to create areas of solid colour in order to use the toner transfer method of making printed circuits. To do that I need to print really dark solid black blocks - when I try that I see uneven toner in certain areas. This scan of the outpu
-
FTP_COMMAND in order to get files list at FTP address
Hi all. I want to get a list of files exist at a specific FTP address. For that I'm using FTP_CONNECT (OK) and after I want to execute FTP_COMMAND with parameter command = 'ls' in order to recievce the files list in output table data[]. I keep on get