WKT polygon returns extra records on intersect query
We have spatially enabled table with min/max lat/long with 1 degree cell data on which we perform queries coming from an application using well known text. We need to use WKT because we need to support user defined shapes of point, line, polygon, etc. (My test cases uses a rectangle). Our WKT data is accurate to 4 decimal places.
//WKT version returns 100 records: (this is bad result)
SELECT COUNT(*) from (select * from MAP_TABLE WHERE series='downunder') where sdo_relate(geometry,sdo_util.rectify_geometry(mdsys.sdo_geometry
('POLYGON((117.0627 -31.8451,117.0627 -27.0075,134.5875 -27.0075, 134.5875 -31.8451, 117.0627 -31.8451)))',8307),0.00005),'mask=anyinteract,querytype=window') = 'TRUE'
// array version returns 90 records: (this is expected result)
SELECT COUNT(*) from (select * from MAP_TABLE WHERE series='downunder') where sdo_relate(geometry,mdsys.sdo_geometry(2003,8307,null,mdsys.sdo_elem_info_array(1,1003,3),
mdsys.sdo_ordinate_array(117.0627, -31.8451,134.5875,-27.0007)),'mask=anyinteract,querytype=window') = 'TRUE'
The WKT seems to return extra records as if a .5 rounding error on the spatial query. We checked for tolerance; in USER_SDO_GEOM_METADATA, SDO_TOLERENCE for lon and lat in DIMINFO column are set to .0000005, and SRID of 8307, and the spatial index for the table has been recreated with .0000005 (just in case).
Why is WKT not accurate?
Hi Mike,
Well, I'll be the first to line up and say that the WKT implementation has some issues. You already know them as you are doing that rectify_geometry step to account for some of them (incorrectly rotated rings which is what your example has).
Noel is right that your example is not pushing along your case since an optimized rectangle is not the same as a regular rectangle, particularly in a geodetic cs. And that is one tiny tolerance in the rectify step! Is all your data at that tolerance? That's 0.0019685 inches! Wikipedia says the width of a human hair is 0.003937 inches so your tolerance is 1/3 of the width of a human hair. :)
Anyhow, the second link Noel posted has the blurb we want: "When Spatial constructs the MBR internally for the query, lines along latitude lines are densified by adding points at one-degree intervals. This might affect results for objects within a few meters of the edge of the MBR (especially objects in the middle latitudes in both hemispheres)." So your optimized rectangle when its used internally by Oracle spatial looks like the results from this query:
SELECT
SDO_CS.TRANSFORM(
MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),MDSYS.SDO_ORDINATE_ARRAY(117.0627, -31.8451,134.5875,-27.0007)),
8307
FROM
dualSo you can probably expect some differences in query results in comparison to the four point rectangle that your WKT input creates. And certainly will happen at the follicle scale!
Could you post a different example that does not use an optimized rectangle where the SDO and WKT produce different outputs?
If your data is stored as WKT, how did an optimized rectangle get into this story in the first place? If you need to store an optimized rectangle as WKT - well you can't do that. You could do the above transform trick on any optimized rectangles in your data and then put all the resulting points into your WKT. Then things should match on the output query side. But that would mean chucking out the whole concept of optimized triangles from your dataset.
Cheers,
Paul
Similar Messages
-
Returning no records when changing query setFirstResult value
On 1st pass through I can get the number of results based on setFirstResult and max number of records is set to 2 for testing. As a note setFirstResult() seems to be zero-based in that I have to set 1st result to 0 to get the 1st 2 records.
I remove the query from session since I read we could not re-use the query if setting the first result. Then I always create a new query and set the 1st result to the 1st row of next page which would be 2. I have 4 records that match in the database, but never get any results back.
Any help would be really appreciated !
Here's my code:
if (_databaseSession.getQuery(HOGLConstants.NAMED_QUERY_BY_PHONE) != null){_databaseSession.removeQuery(HOGLConstants.NAMED_QUERY_BY_PHONE);
createSearchByPhoneQuery(_databaseSession, searchByPhoneDTO, requestedPage, _maxRowsPerScreen);
Vector supplements = (Vector)databaseSession.executeQuery(HOGLConstants.NAMED_QUERY_BY_PHONE,_searchByPhoneDTO.getAreaCode(),_searchByPhoneDTO.getPhoneNo());
private void createSearchByPhoneQuery(DatabaseSession databaseSession, SearchByPhoneDTO searchByPhoneDTO, int requestedPage, int maxRowsPerScreen) {
int firstRecordRow = (requestedPage - 1) * _maxRowsPerScreen;// setFirstRecord(int) is zero-based even though API does not mentionit.
ReadAllQuery _query = new ReadAllQuery(SuppReq.class);
ExpressionBuilder builder = query.getExpressionBuilder();
// Define two expressions that map to the applicant's area code and phone number
Expression areaCodeExpression = builder.get(HOGLConstants.PERSISTAPPLICANT_AREA_CODE).equal(_searchByPhoneDTO.getAreaCode());
Expression phoneNoExpression = builder.get(HOGLConstants.PERSISTAPPLICANT_PHONE_NO).equal(_searchByPhoneDTO.getPhoneNo());
_query.setSelectionCriteria(areaCodeExpression.and(phoneNoExpression));
query.setMaxRows(HOGLConstants.SEARCHRESULTS_ROWS_PER_SCREEN);
query.addAscendingOrdering (HOGLConstants.PERSISTSUPP_REQ_ID);
// Specify the required arguments for the query
query.addArgument(HOGLConstants.PERSISTAPPLICANT_AREA_CODE);
query.addArgument(HOGLConstants.PERSISTAPPLICANT_PHONE_NO);
query.setFirstResult(firstRecordRow);
query.setQueryTimeout(HOGLConstants.QUERYTIMEOUT);
databaseSession.addQuery(HOGLConstants.NAMEDQUERY_BY_PHONE, _query);
}Hello,
The max rows operation is applied independently from the firstResults opperation, and is applied first. So in setting max rows to 2, you are getting rows 1 and 2, and then by applying firstResults=2, you are skipping past the second row, hence getting 0 back. This is because Max rows is applied to the statement before execution, where as firstResult is applied to the returned resultset. You will need to use firstresults=2 and maxrows=4 to get rows 3+4.
Also, you can change the query parameters on a named query. It is not recommended though only because named queries are stored on the session, and so in a multi-threaded app can cause problems when two threads try to execute the same query with, for example, different max results set. In a multithreaded environment you might want to get the named query and clone it before changing first/max rows, but for single threaded app there shouldn't be any problems.
Best Regards,
Chris -
Returning all records for a query
Hi,
still working on this library. I have the majority of it working (not pretty but it works). One problem I have run into is that when I query an authors name I would like all records for that author to be shown. However, it is only showing the final record.
public void Search_a()throws Exception{
String S_author1 = JOptionPane.showInputDialog(null,"Please enter the authors name");
String query = ("select * from library where Author=('"+S_author1+"')");
ResultSet rs = db_statement.executeQuery(query);
while (rs.next()) {
String s = rs.getString("Author");
output.setText(rs.getString("ISBN")+"\t"+rs.getString("Title")+"\t"+ s +"\t"+ rs.getString("Publisher")+"\t"+rs.getString("Genre")+"\t"+rs.getString("Details")+"\n");
}//end while
}// end search_aI cannot see where the error is. I think maybe I am overwriting the previous records but thought that the inclusion of +"\n" would force each result to a new line.
Any ideas?Thanks for that. Not really sure how I would implement that (new to programming) but I have managed to solve it using output.setText(output.getText()+rs.getString("ISBN")+"\t"+rs.getString("Title")+"\t"+ s +"\t"+ rs.getString("Publisher")+"\t"+rs.getString("Genre")+"\t"+rs.getString("Details")+"\n");Thanks for the reply though.
-
Sql to return second record in a query first
I have a query that simply retruns records ordered by date
most recent. What
I need is to show the second record in the set only, or
first. How would I
do that?Make the inner join a LEFT JOIN
SELECT (ct.amount)
FROM dbo.card AS c WITH (NOLOCK) LEFT JOIN
dbo.card_transaction_log AS ct WITH (NOLOCK) ON ct.card_id = c.card_id AND ct.transaction_response_cd = '00' AND
ct.transaction_type_cd = 'REDEMPTION' AND ct.lastupdated <= '2013-12-09 11:02:00'
where c.card_id IN
1767811,
1767812,
1767813 )
Tom
P.S. Using WITH (NOLOCK) is usually a bad idea. It amounts to saying you don't care if you might get bad data, duplicate data, missing data or unexpected errors. If you are not having blocking problems, you don't need WITH(NOLOCK) and if
you are having blocking problems it is usually better to look for other solutions, like improving your indexing strategy or using the SNAPSHOT transaction isolation level.
Tom -
Problem with return table(adding extra record)
Hi,gurus,
I am facing a probelm with return table, i.e it is adding body record and workarea record also to the data target. so, it is adding the actual record to data target including the workarea record to with the key figure and year values as zeros and spaces. It's quite strange.
Please help me out, thanks a lot.Hi,
I have an ODS with the keys fields(ZPS_TXMID,ZPS_NODE,ZPS_NODE) and data fields(ZAU_C108,ZAU_C109,0PROJECT). I have to split one record from datasource to 6 records into my ODS. I'm updating ZAU_C109 with a routine with return table. Here is the code, please check it for me:
<i> data: prj like /BIC/PZPS_TXMID-PROJECT.
data: ls_icube_value like ICUBE_VALUES.
clear ls_icube_value.
select single PROJECT into prj from /BIC/PZPS_TXMID
where /BIC/ZPS_TXMID = COMM_STRUCTURE-/BIC/ZPS_TXMID.
ls_icube_value-/BIC/ZPS_TXMID = COMM_STRUCTURE-/BIC/ZPS_TXMID.
ls_icube_value-/BIC/ZAU_C108 = COMM_STRUCTURE-/BIC/ZAU_C108.
ls_icube_value-/BIC/ZPS_NODE = '1'.
ls_icube_value-/BIC/ZPS_SNODE = '0'.
ls_icube_value-PROJECT = prj.
ls_icube_value-/BIC/ZAU_C109 = COMM_STRUCTURE-/BIC/ZPS_HJHSJ.
APPEND ls_icube_value TO RESULT_TABLE.
ls_icube_value-/BIC/ZPS_NODE = '1'.
ls_icube_value-/BIC/ZPS_SNODE = '1'.
ls_icube_value-PROJECT = prj.
ls_icube_value-/BIC/ZAU_C109 = COMM_STRUCTURE-/BIC/ZPS_HPSJ.
APPEND ls_icube_value TO RESULT_TABLE.
ls_icube_value-/BIC/ZPS_NODE = '1'.
ls_icube_value-/BIC/ZPS_SNODE = '2'.
ls_icube_value-PROJECT = prj.
ls_icube_value-/BIC/ZAU_C109 = COMM_STRUCTURE-/BIC/ZAU_C101.
APPEND ls_icube_value TO RESULT_TABLE.
ls_icube_value-/BIC/ZPS_NODE = '2'.
ls_icube_value-/BIC/ZPS_SNODE = '0'.
ls_icube_value-PROJECT = prj.
ls_icube_value-/BIC/ZAU_C109 = COMM_STRUCTURE-/BIC/ZPS_TJHSJ.
APPEND ls_icube_value TO RESULT_TABLE.
ls_icube_value-/BIC/ZPS_NODE = '2'.
ls_icube_value-/BIC/ZPS_SNODE = '1'.
ls_icube_value-PROJECT = prj.
ls_icube_value-/BIC/ZAU_C109 = COMM_STRUCTURE-/BIC/ZPS_TDSJ.
APPEND ls_icube_value TO RESULT_TABLE.
ls_icube_value-/BIC/ZPS_NODE = '2'.
ls_icube_value-/BIC/ZPS_SNODE = '2'.
ls_icube_value-PROJECT = prj.
ls_icube_value-/BIC/ZAU_C109 = COMM_STRUCTURE-/BIC/ZAU_C102.
APPEND ls_icube_value TO RESULT_TABLE.
ABORT = 0.</i>
After loading, I checked the contents of ODS, there are 6 records(0project, ZAU_C108 are blank, other fields are correct) + 1 more record(ZPS_TXMID,0project, ZAU_C108 are correct, other fields are blank), what I expect is only 6 records with all fields being filled properly, no blanks, no extra records. Is it strange? or am I doing sth. wrong?
Your help is appreciated. -
Query returns zero records in coldfusion context, but works fine in Navicat
I've got a query that's returning zero records when I load a page. If I copy and paste that same query (from the debug output) into navicat, I get rows returned (as I expect). Has anyone seen this? It happens locally (CF9) AND remotely on our staging server (CF10). Even weirder, it's a query that was previously working fine - I simply added an if statement to the where clause, and all of a sudden...
Here's the query:
<CFQUERY name="LOCAL.getEncounterServices" datasource="#REQUEST.dsn#">
SELECT
a.EncounterProductID,
a.DateTime AS ServiceDate,
aa.CartItemID,
aaa.CartID,
aaaaa.CartStatus,
b.ProductID,
b.ProductName,
b.CPTCode,
b.Price,
c.EncounterID,
c.DateTimeClosed AS EncounterClosedDate,
d.FirstName,
d.LastName
FROM
EncounterProducts a
LEFT JOIN CartItemProduct aa ON (a.EncounterProductID = aa.EncounterProductID AND aa.Active = 1)
LEFT JOIN CartItem aaa ON (aa.CartItemID = aaa.CartItemID)
LEFT JOIN Cart aaaa ON (aaa.CartID = aaaa.CartID)
LEFT JOIN CartStatus aaaaa ON (aaaa.CartStatusID = aaaaa.CartStatusID),
Product b,
Encounters c,
Contacts d,
EncounterStatuses e
WHERE
1 = 1
AND (aa.CartItemID IS NULL OR aaaaa.CartStatus = 'Deleted')
AND a.Active = 1
AND a.ProductID = b.ProductID
AND a.EncounterID = c.EncounterID
AND c.PatientID = d.ContactID
AND c.EncounterStatusID = e.EncounterStatusID
AND e.EncounterStatus = 'Closed'
<CFIF IsDefined("ARGUMENTS.encounter") AND IsObject(ARGUMENTS.encounter)>
AND c.EncounterID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.encounter.getID()#">
<CFELSE>
AND c.DateTimeClosed >= <CFQUERYPARAM cfsqltype="cf_sql_date" value="#ARGUMENTS.startDate#">
AND c.DateTimeClosed < <CFQUERYPARAM cfsqltype="cf_sql_date" value="#DateFormat(DateAdd('d', 1, ARGUMENTS.endDate), 'yyyy-mm-dd')# 00:00:00">
</CFIF>
AND c.LocationID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.locationID#">
AND c.CustomerID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.customerID#">
</CFQUERY>
All of this worked just fine before I added the lines:
<CFIF IsDefined("ARGUMENTS.encounter") AND IsObject(ARGUMENTS.encounter)>
AND c.EncounterID = <CFQUERYPARAM cfsqltype="cf_sql_integer" value="#ARGUMENTS.encounter.getID()#">
<CFELSE>
AND c.DateTimeClosed >= <CFQUERYPARAM cfsqltype="cf_sql_date" value="#ARGUMENTS.startDate#">
AND c.DateTimeClosed < <CFQUERYPARAM cfsqltype="cf_sql_date" value="#DateFormat(DateAdd('d', 1, ARGUMENTS.endDate), 'yyyy-mm-dd')# 00:00:00">
</CFIF>
Previously, it had just been:
AND c.DateTimeClosed >= <CFQUERYPARAM cfsqltype="cf_sql_date" value="#ARGUMENTS.startDate#">
AND c.DateTimeClosed < <CFQUERYPARAM cfsqltype="cf_sql_date" value="#DateFormat(DateAdd('d', 1, ARGUMENTS.endDate), 'yyyy-mm-dd')# 00:00:00">
With no IF/ELSE statement.
Anyone seen anything like this before? Any ideas?
Thanks.Right, I'll start disabusing myself of the DateFormat!
I'm sorry, I should've posted the actual query too. It's inserting the first part - "AND c.EncounterID = ....."
Here's the full query:
LOCAL.getEncounterServices (Datasource=xmddevdb, Time=9ms, Records=0) in /Applications/ColdFusion9/wwwroot/XMD_NEW/xmd_dev/cfc/ShoppingGateway.cfc @ 16:56:28.028
SELECT
a.EncounterProductID,
a.DateTime AS ServiceDate,
aa.CartItemID,
aaa.CartID,
aaaaa.CartStatus,
b.ProductID,
b.ProductName,
b.CPTCode,
b.Price,
c.EncounterID,
c.DateTimeClosed AS EncounterClosedDate,
d.FirstName,
d.LastName
FROM
EncounterProducts a
LEFT JOIN CartItemProduct aa ON (a.EncounterProductID = aa.EncounterProductID AND aa.Active = 1)
LEFT JOIN CartItem aaa ON (aa.CartItemID = aaa.CartItemID)
LEFT JOIN Cart aaaa ON (aaa.CartID = aaaa.CartID)
LEFT JOIN CartStatus aaaaa ON (aaaa.CartStatusID = aaaaa.CartStatusID),
Product b,
Encounters c,
Contacts d,
EncounterStatuses e
WHERE
1 = 1
AND (aa.CartItemID IS NULL OR aaaaa.CartStatus = 'Deleted')
AND a.Active = 1
AND a.ProductID = b.ProductID
AND a.EncounterID = c.EncounterID
AND c.PatientID = d.ContactID
AND c.EncounterStatusID = e.EncounterStatusID
AND e.EncounterStatus = 'Closed'
AND c.EncounterID = ?
AND c.LocationID = ?
AND c.CustomerID = ?
Query Parameter Value(s) -
Parameter #1(cf_sql_integer) = 28
Parameter #2(cf_sql_integer) = 16
Parameter #3(cf_sql_integer) = 6
Thansk again for the help! -
Using index in a query return few records than full table access
Today we have an issue with a query, when it use the ok index the returned are not all records that apply to where clause condition.
See bellow
explain plan for
select * from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 136999
SELECT * FROM TABLE(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1882720105
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | TABLE ACCESS BY INDEX ROWID| ZAN_M03 |
|* 2 | INDEX RANGE SCAN | PK_ZAN_M03 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
2 - access("M00AF"=TO_DATE('11/01/28','YY/MM/DD') AND "M00ZA"=10 AND
"M00AC"=50 AND "M00AD">=136906 AND "M00AD"<=137141)
filter("M00AD"<=137141 AND "M00AD">=136906)
Note
- rule based optimizer used (consider using cbo)
20 rows selected.
The query above return only one row insted 1579 record that apply to this conditions.
When forcing a full table acess with a hint, the query return all records that apply, the 1579 record.
select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 137141
Can you help me to identify what's happening?
I am with Oracle 10g R2 10.2.0.4 standard edition
the statistics are up to date
the opitimizer_mode are rule, but altering in session level to all_rows happens the same issue.
Nothing about corruption in the alert log.
Thanks in advance
Regards
CristianoYes the query are the same and correct restriction for where clause are M00AD between 136906 and 137141.
I've pasted, by mistake, another test query
The corrects are:
select M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 137141
This use pk index and return one row
select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 137141
This does a full table access and return 1579 records
I´ve been searching for wrong results bugs on my oracle support, but not found one that mentions something like our issue.
I checked the dba_tables and dba indexes and the number of rows are different, and I think this would be the same because it's is a pk.
Look this
SQL> select NUM_ROWS from dba_tables where table_name = 'ZAN_M03'
2 /
NUM_ROWS
228527878
select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
SQL> select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
NUM_ROWS
217510185
Is normal a index for pk having much fewer rows than table? I think not, but not sure.
Again
Thanks in advance
Regards
Cristiano -
Need help writing a MySQL query that will return only records with matching counter-parts
Since I don't know how to explain this easily, I'm using the
table below as an example.
I want to create a MySQL query that will return only records
that have matching counter-parts where 'col1' = 'ABC'.
Notice the 'ABC / GHI' record does not have a
counter-matching 'GHI / ABC' record. This record should not be
returned because there is no matching counter-part. With this
table, the 'ABC / GHI' record should be the only one returned in
the query.
How can I create a query that will do this?
id | col1 | col2
1 | ABC | DEF
2 | DEF | ABC
3 | ABC | GHI
4 | DEF | GHI
5 | GHI | DEF
*Please let me know if you have no idea what I'm trying to
explain.AngryCloud wrote:
> Since I don't know how to explain this easily, I'm using
the table below as an
> example.
>
> I want to create a MySQL query that will return only
records that have
> matching counter-parts where 'col1' = 'ABC'.
>
> Notice the 'ABC / GHI' record does not have a
counter-matching 'GHI / ABC'
> record. This record should not be returned because there
is no matching
> counter-part. With this table, the 'ABC / GHI' record
should be the only one
> returned in the query.
>
> How can I create a query that will do this?
>
>
> id | col1 | col2
> --------------------
> 1 | ABC | DEF
> 2 | DEF | ABC
> 3 | ABC | GHI
> 4 | DEF | GHI
> 5 | GHI | DEF
>
>
> *Please let me know if you have no idea what I'm trying
to explain.
>
Please be more clear. You say that 'ABC / GHI' should not be
returned,
and then you say that 'ABC / GHI' should be the only one
returned. Can't
have both... -
Query is returning multiple records for a bank account id and party id
Hi All,
I am not getting why this query is returning multiple records for a particular bank account id and party id:
SELECT instrument_payment_use_id
,instrument_type
,instrument_id
,start_date
,ext_pmt_party_id
FROM iby_pmt_instr_uses_all
WHERE instrument_id =:lv_num_ext_bank_account_id
and exists (select 1 from iby_external_payees_all b where PAYEE_PARTY_ID= :lv_num_party_id and b.ext_payee_id = ext_pmt_party_id)
I want above values to be used in api iby_disbursement_setup_pub.set_payee_instr_assignment in R12.
Please help asap.
ThanksO/P of query run for
SELECT rowid, instrument_payment_use_id
FROM iby_pmt_instr_uses_all
WHERE instrument_id =6642
AND EXISTS (
SELECT 1
FROM iby_external_payees_all b
WHERE payee_party_id= 85470
AND b.ext_payee_id = ext_pmt_party_id);
is below:
Rowid INSTRUMENT_PAYMENT_USE_ID
AABiDXAGIAABhiKAAS 236586
AABiDXAGRAABSjtAAz 148437
The version is R12 -
Search query returning ALL records
DW CS3 - MS Access - ASP/VBScript
I have a search form for records to display on the same page with keywords highlighted. The search is returning ALL records and highlighting keywords throughout rather than returning specific records with the searched word. What am I missing? I'm sure it's something terribly simple.....
<input name="search" type="text" id="search" value="<%= Request.QueryString("search") %>" />
SELECT item, item, item, item
FROM tbl_name
WHERE item OR item OR item LIKE %MMColParam%
ORDER BY sql_orderby, Date DESC
Name: MMColParam
Type: Text
Value: Request.Querystring("search")
Default Value: %I was using the word "item" as an example for multiple columns without actually naming them - they are not the same. I should've used this example:
SELECT shoes, socks, hats, gloves
FROM tbl_apparel
WHERE shoes OR socks OR hats LIKE %MMColParam%
ORDER BY sql_orderby, Date DESC
In the past, I had four duplicate query parameters for four columns which worked fine. But since I only have one search term, I thought I could eliminate three of the duplicate parameters and use just one with the OR statement.
In the past, you questioned me on this. You stated, "You only have one search term and so all of the parameters have the same value, but DW still wants to creates 4 parameters. If you were coding this by hand you wouldn't do it that way, but DW's one-size-fits-all code generates four seperate parms. It's nothing to worry about." -
How to avoid:Query returns extra trailing spaces in oracle 10g
I want to use cursor sharing FORCE, SIMILAR for performance tuning. but i am having some problems like query process will give extra trailing spaces this will throw errors from the java application while reading literals.
do we have any option in oracle 10g to avoid extra trailing spaces during query processing ?
alter session set cursor_sharing ='EXACT'
select 1 from dual;
'1'
1
alter session set curson_sharing='FORCE'
select 2 from dual;
'2'
2
alter session set curson_sharing='SIMILAR'
select 3 from dual;
'3'
3You are right, But we already wrote millions of queries during that time we used cursor sharing is EXACT. so i don't want to take risk in modifying all the existing queries by adding TRIM.
do we have any option in oracle to trim after/ during processing the query.
Now we are facing performance issues and suggested us to use SIMILAR as cursor_sharing. but all the selected rows are giving extra tralining spaces.
I think i am clear now. -
Returned records different in query to workbook
We are using Bex Analyser version 7.
I have a pending invoices query embedded in a workbook. If I refresh the query within the workbook, I get 3 fewer records than if I run the same query on its own.
When I identified the 3 invoices concerned I could see that they have a zero key figure values. I haven't suppressed zero records in the query but they appear to be suppressed in the workbook.
Has anybody got any suggestions for amending my workbook so that I get all the records?
Many thanks,
Positive ParrotHi,
Can you check in this way.
Right click on a particular record in workbook-> properties> calculation---> calculate single value as.
Thanks,
Ashok -
How to return the record count of a query to a number variable
How would I get the record count from a query without using a cursor to step through the query and count the records individually?
query: select * from table1 where column1 = column2
How would I get the record count of the query above?
thanks,
michelleI figured it out
select count(*) into theCount
from ( select * from table1 where column1=column2 );
thanks,
michelle -
JDBC Call returns no results, SQL*Plus returns 1 record, Please help!
Any help would be greatly appreciated.
Running 9.2.0.5.0, and using latest 9.2 JDBC 1.4_g drivers in thin mode.
Execute the following query from SQL*Plus and it returns one row, from JDBC using a PreparedStatement, I get no results. Here's the query, table def, record, etc.:
Query:
SELECT
ID_WEB_FRM,ID_WEB_SIT,CDE_LVL_1_FUNC,
CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID
FROM
WEB_FRM
WHERE
ID_WEB_FRM = ' '
OR
(ID_WEB_SIT = 'test' AND CDE_LVL_1_FUNC = ' '
AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1
AND NUM_WEB_PG_ID = 0)
Record returned from SQL*Plus:
ID_WEB_FRM ID_WEB_SIT CDE CDE NUM_WEB_FUNC_PG NUM_WEB_PG_ID
NfRRmc5XZu test u2T 1 0
Both in the data returned and the query, there are no blanks, but they are a single space instead (hard to see in message here).
Java code:
int count = 1;
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++,form.getSiteID());
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++, form.getFunctionID());
findDBNameStatement.setInt(count++,form.getPageNumber());
findDBNameStatement.setInt(count++,form.getSectionNumber());
ResultSet resultSet = findDBNameStatement.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();
resultSet.next() returns false
DB table:
CREATE TABLE web_frm (
ID_WEB_FRM varchar2(10) NOT NULL,
ID_WEB_SIT varchar2(20) NOT NULL,
NAM_WEB_FRM varchar2(40),
TXT_EMAIL_SUBJ varchar2(50),
CDE_LVL_1_FUNC char(3),
CDE_LVL_2_FUNC char(3) NOT NULL,
NUM_WEB_FUNC_PG int NOT NULL,
NUM_WEB_PG_ID smallint NOT NULL,
DTE_WEB_FRM_EFF date NOT NULL,
DTE_WEB_FRM_TRM date,
CDE_VLDT_RUL char(3),
DTE_LAST_EXPRT date,
TXT_CNFRMN_MSG varchar2(4000),
IND_UPDT_ALWD char(1) NOT NULL,
TXT_RECAP_HDR varchar2(4000),
TXT_RECAP_FTR varchar2(4000),
CDE_WEB_OBJ char(3),
NUM_MAX_FRM_WIDTH number(4,0),
IND_RECAP_PG char(1) NOT NULL,
IND_CNFRM_PG char(1) NOT NULL,
IND_DSPL_CNFRM_NUM char(1) NOT NULL,
CNT_SUBM_MAX int,
TXT_CHCE_ADD_MSG varchar2(255),
TXT_CHCE_MOD_MSG varchar2(255),
TXT_WEB_HDR varchar2(4000),
TXT_WEB_FTR varchar2(4000),
TXT_WAIT_LIST_MSG varchar2(255),
FORMOBJECTHEIGHT int NOT NULL,
FORMOBJECTWIDTH int NOT NULL
ALTER TABLE web_frm ADD ( CONSTRAINT PK_web_frm PRIMARY KEY (ID_WEB_FRM));
ALTER TABLE web_frm ADD ( CONSTRAINT UK_web_frm UNIQUE (ID_WEB_SIT,CDE_LVL_1_FUNC,CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID)) ;
Thanks,
MattI have verified the parameters and such, and if I run as a Statement instead of a PreparedStatement, the query works fine. After some more troubleshooting, I narrowed the problem down, but not sure of the fix.
If I eliminate teh extra parameters and simplify things to:
SELECT ID_WEB_FRM FROM WEB_FRM WHERE ID_WEB_SIT = 'test' AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1 AND NUM_WEB_PG_ID = 0
The code works. But if I add the additional WHERE clause of CDE_LVL_1_FUNC = ' ' (has single space), it returns no data (record in the DB has single space in this new column. Query that does not work:
SELECT ID_WEB_FRM FROM WEB_FRM WHERE ID_WEB_SIT = 'test' AND CDE_LVL_1_FUNC = ' ' AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1 AND NUM_WEB_PG_ID = 0
It appears the JDBC Driver is trimming the parameter when it is a space when set through a PreparedStatement.setString(2," ") -
Oracle:JDBC Call returns no results, SQL*Plus returns 1 record, Please help
Any help would be greatly appreciated.
Running 9.2.0.5.0, and using latest 9.2 JDBC 1.4_g drivers in thin mode.
Execute the following query from SQL*Plus and it returns one row, from JDBC using a PreparedStatement, I get no results. Here's the query, table def, record, etc.:
Query:
SELECT
ID_WEB_FRM,ID_WEB_SIT,CDE_LVL_1_FUNC,
CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID
FROM
WEB_FRM
WHERE
ID_WEB_FRM = ' '
OR
(ID_WEB_SIT = 'test' AND CDE_LVL_1_FUNC = ' '
AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1
AND NUM_WEB_PG_ID = 0)
Record returned from SQL*Plus:
ID_WEB_FRM ID_WEB_SIT CDE CDE NUM_WEB_FUNC_PG NUM_WEB_PG_ID
NfRRmc5XZu test u2T 1 0
Both in the data returned and the query, there are no blanks, but they are a single space instead (hard to see in message here).
Java code:
int count = 1;
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++,form.getSiteID());
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++, form.getFunctionID());
findDBNameStatement.setInt(count++,form.getPageNumber());
findDBNameStatement.setInt(count++,form.getSectionNumber());
ResultSet resultSet = findDBNameStatement.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();
resultSet.next() returns false
DB table:
CREATE TABLE web_frm (
ID_WEB_FRM varchar2(10) NOT NULL,
ID_WEB_SIT varchar2(20) NOT NULL,
NAM_WEB_FRM varchar2(40),
TXT_EMAIL_SUBJ varchar2(50),
CDE_LVL_1_FUNC char(3),
CDE_LVL_2_FUNC char(3) NOT NULL,
NUM_WEB_FUNC_PG int NOT NULL,
NUM_WEB_PG_ID smallint NOT NULL,
DTE_WEB_FRM_EFF date NOT NULL,
DTE_WEB_FRM_TRM date,
CDE_VLDT_RUL char(3),
DTE_LAST_EXPRT date,
TXT_CNFRMN_MSG varchar2(4000),
IND_UPDT_ALWD char(1) NOT NULL,
TXT_RECAP_HDR varchar2(4000),
TXT_RECAP_FTR varchar2(4000),
CDE_WEB_OBJ char(3),
NUM_MAX_FRM_WIDTH number(4,0),
IND_RECAP_PG char(1) NOT NULL,
IND_CNFRM_PG char(1) NOT NULL,
IND_DSPL_CNFRM_NUM char(1) NOT NULL,
CNT_SUBM_MAX int,
TXT_CHCE_ADD_MSG varchar2(255),
TXT_CHCE_MOD_MSG varchar2(255),
TXT_WEB_HDR varchar2(4000),
TXT_WEB_FTR varchar2(4000),
TXT_WAIT_LIST_MSG varchar2(255),
FORMOBJECTHEIGHT int NOT NULL,
FORMOBJECTWIDTH int NOT NULL
ALTER TABLE web_frm ADD ( CONSTRAINT PK_web_frm PRIMARY KEY (ID_WEB_FRM));
ALTER TABLE web_frm ADD ( CONSTRAINT UK_web_frm UNIQUE (ID_WEB_SIT,CDE_LVL_1_FUNC,CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID)) ;
Thanks,
MattThat's not quite right. From the javadocs:
next
public boolean next()
throws SQLException
Moves the cursor down one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on.
If an input stream is open for the current row, a call to the method next will implicitly close it. A ResultSet object's warning chain is cleared when a new row is read.
Returns:
true if the new current row is valid; false if there are no more rows
Throws:
SQLException - if a database access error occurs
Maybe you are looking for
-
!!!Very Urgent-Production Issue -Please help
Hello IDMers, We are facing an issue in production, we updated the AD Process form yesterday. Two fields- Employee Type and Employee ID field in AD User Process form got refreshed for all existing users. Those two fields are empty now for all users.
-
How to HIde rows based on User Selection
I have a requirement where in I have to hide some rows based on Plant Name selected by USer at the time of opening the report. Here is the screen shot:- Here I am seeing two Tag Types MACT and Average when User selects Luling Plant. But When User s
-
ISE 1.3 bugs in Guest Types?
Hi, I've created a guest type that looks like this: Maximum account duration: 90 days Allow 15 simultaneous logins Removes the oldes connection Maximum device guest can register: 1 When I log in to the sponsor portal and select the created guest typ
-
Is it possible to join two video files?
Is there any way i can use mac os to join two AVI files together, and then create a new copy of the combined video to show on my iPad. if i can avoid using iMovie that would be great. thanks
-
Playing quicktime files on an HDTV
I created keynote slides on my macbook AIR, exported them to quicktime and recorded them onto a DVD to play as a continual loop; but TVs say they won't support or read the file. Is there anyway around needing a laptop attached to the TV?