In a single query SELECT top row?
Hello
Can someone help me write a query to get the first line after the clause order by using a single query only.
Example:
I can write after query to select the first line
Select * from (select * from t by col1) where rownum = 1;
But here I should not use view inline to get the result. Because my initial requirement must use this query in the selection list and he needs to use a column (of a table in the FROM clause) in which the query clause online. Because there are restrictions we cannot use the column (of a table in the FROM clause) more than one level of application online.
Please help me.
Used version of Oracle's Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
Tags: Database
Similar Questions
-
SQL query - select a row of each group to date
Hello
I have data like this.
Visit_Date Visit_type Consultant
2009-05-09 G name1
2009-05-09 G name2
2009-05-09 G Name3
06/09/2009 I have name4
09/07/2009 G name5
09/07/2009 G name6
How to select data as follows
2009-05-09 G name1
09/06/2009 G name4
09/07/2009 G name5
That is to say a line of each visit_date
Thank you
Nathan MK
Published by: k_murali on October 7, 2009 22:44Hello
k_murali wrote:
I modified your request to meet my requirement of 100%. But it is not work.Select trunc (visit_dt) visit_date, min (visit_type) visit_type, min (consultant)
SD
where visit_type = 'G' and client_id = 21503
Trunc Group (visit_dt)
order of trunc (visit_dt)Union of all the
Select min (visit_dt) visit_date, min (visit_type) visit_type, min (consultant)
SD
where visit_type = 'I '.
Visit_Dt group
order of visit_DtBut if I run separately (b4 & after all), his works very well. But I need the result.
What do you mean by "doesn't quite work" and "working well"? The UNION is too slow?
If so, combine them in a single query, without UNION.
It seems that the main difference between the two stems of the UNION, is that the upper pin (for visit_type = 'G') are grouped by days (TRUNC (visit_date)), but the pane at the bottom (for visit_type = 'I') are grouped by seconds (visit_date, without TRUNC). You can GROUP BY an expression BOX which maps all points in any calendar the same day point only when visit_type = 'G', like this:SELECT CASE WHEN visit_type = 'G' THEN TRUNC (visit_date) WHEN visit_type = 'I' THEN visit_date END AS visit_date , visit_type , MIN (consultant) AS consultant FROM dd WHERE ( visit_type = 'G' AND client_id = 21503 ) OR visit_type = 'I' GROUP BY CASE WHEN visit_type = 'G' THEN TRUNC (visit_date) WHEN visit_type = 'I' THEN visit_date END , visit_type ORDER BY visit_date , visit_type ;
This should be faster, because it makes only one pass through the table dd.
If you do not want to repeat the CASE expression (in the SELECT clause and the GROUP BY clause), then you can calculate it in a subquery.
There is no need to repeat the CASE expression in the ORDER BY clause; We can use the alias column (defined in the SELECT clause) in the ORDER BY clause. -
How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and
I have a table whose columns with values such as
MINNEAŸPOLIS and ¿VV ¿A
Only the characters that are allowed in this column are alphabets, numbers, spaces, points and supports.
Please help to write a SQL SELECT with Regexp_like query or any other option.
Thanks to you all! Under query worked for me. Thank you Frank to explain the concept of hooks inside regexp_like.
SELECT * FROM testspecial, WHERE REGEXP_LIKE (sampletext, "[^] ^ A - Z ^ a - z ^ 0-9 ^ [^.]") ^ {^} ^]') ;
-
Select the top row of ADF Table default
jdev 11.1.1. 6
In my application, I have a fall towards the bass and based on the value, select from the drop-down list on the af: table is filled (using the drop-down list vcl property, I'm populating the VO based on which the table is).
The table has "selectionListener" defined in a method at the bean so that every time a line is selected some operation.
< af:table value = "#{bindings." RoleVO1.collectionModel}.
var = "row" rows = "#{bindings." RoleVO1.rangeSize}"width ="500 ".
"partialTriggers =": soc1: cb1: cb2.
emptyText = "#{bindings." RoleVO1.viewable? "{'No data to display.': 'Access Denied.'}".
fetchSize = "#{bindings." RoleVO1.rangeSize}.
rowBandingInterval = '0 '.
selectedRowKeys = ' #{bindings. " RoleVO1.collectionModel.selectedRow}.
selectionListener = "#{CRoleARoleBean.roleTableSelection} '"
rowSelection = "single" id = "t1".
editingMode = "clickToEdit."
Binding = "#{CRoleARoleBean.roleTable}" >
I have here a certain way, I can make the top row of the selected table and trigger the selectionListener by programming the dropdown each time value is bud?
Please notify
by selecting the default line can be obtained by adding after the vcl in drop-down list:
this.roleTable.setRowIndex (1);
RowKeySet ch = this.roleTable.getSelectedRowKeys ();
PS. Clear();
PS. Add (this.roleTable.getRowKey ());
AdfFacesContext.getCurrentInstance () .addPartialTarget (this.roleTable);
Make sure the displayRow selected = is defined in the table property
-
Can you check data in a table or another, but not both in a single query?
I have a situation where I need to connect the two tables, but the data can be in another table (archive) or different records are in both but I want the last disk in two tables:
ACCOUNT
AccountID name
John Doe 123
Jane 124 Donaldson
125 Harold Douglas
MARKETER_ACCOUNT
AccountID key Marketer StartDate EndDate
1001 123 10526 8/3/2008 9/27/2009
1017 123 10987 9/28 / 2009 12/31/4712 (high date ~ that means currently with this Distributor)
1023 124 10541 03/12/2010 12/31/4712
ARCHIVES
AccountID key Marketer StartDate EndDate
1015 124 10526 8/3/2008 12/02/2010
1033 125 10987 01/01/2011 01/31/2012
If my query should return the following:
123 John Doe 10526 8/3/2008 9/27/2009
Jane Donaldson 10541 12/03/2010 31/12/124 4712 (that is the later of the two folders for this account between tables Archives and marketer_account)
125 Harold Douglas 10987 01/01/2011 01/31/2012 (it is in the archives, so get this recording)
I'm not sure how to do this in a single query. Beware, I am possibly reading several accounts at once and return to a .net collection
Open CURSOR_ACCT
Select the account ID
Of
ACCOUNT A,
MARKETER_ACCOUNT M.
R OF THE ARCHIVES
where A.AccountID = nvl ((select max (M.EndDate) of Marketer_account M2
where M2. AccountID is A.AccountID),
(select max (R.EndDate) in Archive R2
where R2. AccountID = A.AccountID)
and upper (B.SID) as a parameter. '%'
< can you do a NVL like that? probably not... I want to be able to get the MAX registration for this account on the table of MarketerACcount OR recording max for this account to off the table to Archive, but not the two >
(setting could be 'DO', so I return all names beginning with...)
Hello
So, you have a few lines in marketer_account and the other rows in the archives, but you do not want to treat all lines, as if it were a table, is it?
This sounds like a job for the UNION:
WITH union_data AS
(
SELECT StartDate, EndDate, Marketer, AccountID
OF marketer_account
UNION ALL
SELECT StartDate, EndDate, Marketer, AccountID
To archive
)
got_MaxEndDate AS
(
SELECT StartDate, EndDate, Marketer, AccountID
MAX (EndDate) ON (AccountID PARTITION) AS MaxEndDate
Of union_data
)
SELECT a.AccountID, B.SID
m.Marketer, m.StartDate, m.EndDate
One ACCOUNT
JOIN got_MaxEndDate m ON m.AccoutnID = a.AccoundID
WHERE m.EndDate = m.MaxEndDate
;
I hope that answers your question.
If this is not the case, after a CREATE TABLE and INSERT statements for your sample data.
Report when the above query is the production of incorrect results and explain, using specific examples, how to get results in these places.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
.
Starting with version 8, the maximum year in DATEs Oracle is 9999, not 4712.
-
How to find the number of lines executed for a single query in oracle
Hi all
I have a query that will return the details according to certain search criteria.
Here I want to how many lines is performed (as a column) for the given search criteria, including the details of the column table... in a single query.
Thanks in advance
GeraldineI want all the details and number of rows in table...
SQL> select ename, job, count (*) over () total from emp where deptno = 20 / ENAME JOB TOTAL --------------- ------------- --------------- SCOTT ANALYST 5 SMITH CLERK 5 JONES MANAGER 5 ADAMS CLERK 5 FORD ANALYST 5 5 rows selected.
-
12.1.3 JDeveloper and table for selection of rows in Internet Explorer 9
Configuration: Windows 7, Internet Explorer 9 12.1.3, JDeveloper (sorry, the company standard for now)
I have problems of selection of rows in a table when you use IE9 (disabled compatibility view) as my browser. I created a simple application to test. I did the following:
1 created a new web application from merger in JDev 12.1.3.
2 objects of business created for 1 table
3. create a simple page (jspx) for testing
4 dropped the table on the side of Center of a PanelStretchLayout on the page as a table read-only with sorting and single-row selection enabled.
5. changed the property table DisplayRow selected. No other property has changed.
When I run the application, the table appears and is filled as expected. However, after you select at random the rows in the table, the application will lose focus and become hidden behind other applications on my desktop. If I bring the application in the foreground and try again the same thing will happen. After the selections of line 1 X application will disappear from the screen.
I decided to reproduce the JDev 12.1.2 test. In JDev 12.1.2 the application behaves as expected. Never, the application loses focus after several attempts to select a field.
I wonder if something in the hotfix released to correct the 12 c/Internet Explorer 11 questions is the culprit.
Everyone knows about this problem? I hope there is a change of ownership that I do in 12.1.3 to solve the problem.
Thanks in advance!
A solution that seems to work...
Add a clientListener inside the table
Add a javascript method
function handleTableSelection() { window.focus(); }
Just seems to bring the window to the front without changing anything, as far as I can tell.
-
How can I retrieve all the values in a single query in the oracle XML
Hi all
I have xml format below, how do I retrieve all the values in a single query.
< files >
< job > MANAGER < / job >
< details >
< ename > JONES < / ename >
< sal > 2975 < / sal >
< ename > BLAKE < / ename >
< sal > 2850 < / sal >
< ename > CLARK < / ename >
< sal > 2450 < / sal >
< / details >
< / documents >
Thank you
I prefer desgin a little more sophisticated xml and wrap the details in a separate label.
Then you could something like that
1 with testdata until)
2. Select xmltype)
3'
4MANAGER
5
6
7JONES
82975
9
10
11BLAKE
122850
13
14
15CLARK
162450
17
18
19
20 ') in the form x
21 double
22)
23 select
24 j.job
25, d.ename
26, d.sal
27 of testdata
28 join
29 xmltable ("Scriptures" in passing testdata.x)
30 columns
31 job varchar2 (30) path "job."
32, details xmltype path «details»
(33) j
34 (1 = 1)
left outer join 35
36 xmltable (' details/emp' in passing j.details)
37 columns
path of varchar2 (30) 38 'ename' ename
39, path of varchar2 (30) sal "sal".
(40) d
41 * (1 = 1)
>/JOB ENAME SAL
------------------------------ ------------------------------ ----------
JONES MANAGER 2975
BLAKE MANAGER 2850
MANAGER CLARK 2450 -
How can I use a panel of single query with criteria of two view?
Hi all
I have a requirement to allow users to change the "display mode" on a table of tree search results for an advanced search page. What this will do, is change the structure of how the data are arranged. In one case, the picture of the tree is 3 levels deep, otherwise, it's only 2 with different data at the level of the root node.
What I've done so far:
1) I exposed the relationship of data for these two ways to view the data in the data model of the module of the application.
(2) I created a view of criteria in two view objects that are originally relationships, where (for simplicity) I'm comparing only one field.
It is in the object from a point of view:
<ViewCriteria Name="PartsVOCriteria" ViewObjectName="gov.nasa.jpl.ocio.qars.model.views.PartsVO" Conjunction="AND"> <Properties>... </Properties> <ViewCriteriaRow Name="vcrow23" UpperColumns="1"> <ViewCriteriaItem Name="PartDiscrepantItemsWithIRVO" ViewAttribute="PartDiscrepantItemsWithIRVO" Operator="EXISTS" Conjunction="AND" IsNestedCriteria="true" Required="Optional"> <ViewCriteria Name="PartDiscrepantItemsWithIRVONestedCriteria" ViewObjectName="gov.nasa.jpl.ocio.qars.model.views.PartDiscrepantItemsWithIRVO" Conjunction="AND"> <ViewCriteriaRow Name="vcrow26" UpperColumns="1"> <ViewCriteriaItem Name="InspectionRecordNumber" ViewAttribute="InspectionRecordNumber" Operator="=" Conjunction="AND" Value="" Required="Optional"/> </ViewCriteriaRow> </ViewCriteria> </ViewCriteriaItem> </ViewCriteriaRow> </ViewCriteria>
and it is in the other display object:
<ViewCriteria Name="IRSearchCriteria" ViewObjectName="gov.nasa.jpl.ocio.qars.model.views.InspectionRecordVO" Conjunction="AND"> <Properties>... </Properties> <ViewCriteriaRow Name="vcrow7" UpperColumns="1"> <ViewCriteriaItem Name="InspectionRecordNumber" ViewAttribute="InspectionRecordNumber" Operator="=" Conjunction="AND" Required="Optional"/> </ViewCriteriaRow> </ViewCriteria>
(3) I had a query Panel table and automatically generated tree by doing drag control data for ONE of the relationship of view object data that is exposed in the app module. Then, I created a second query Panel table and tree in the same way but using the data control to the other. I am one of the query cache permanently panels and toggling the visibility of the tree based on the user tables selects display mode. Both have separate links and iterators.
It is a part of the definition of the page:
<executables> <variableIterator id="variables"/> <searchRegion Criteria="IRSearchCriteria" Customizer="oracle.jbo.uicli.binding.JUSearchBindingCustomizer" Binds="InspectionRecordVOIterator" id="IRSearchCriteriaQuery"/> <iterator Binds="InspectionRecordVO" RangeSize="25" DataControl="QARS_AppModuleDataControl" id="InspectionRecordVOIterator" ChangeEventPolicy="ppr"/> <iterator Binds="Root.QARS_AppModule.PartsVO1" DataControl="QarsMasterAppModuleDataControl" RangeSize="25" id="PartsVO1Iterator"/> <searchRegion Criteria="PartsVOCriteria" Customizer="oracle.jbo.uicli.binding.JUSearchBindingCustomizer" Binds="PartsVO1Iterator" id="PartsVOCriteriaQuery"/> </executables>
(4) I have created a queryListener custom to delegate the query event.
It's in my jsp to advanced search page:
<af:query id="qryId1" headerText="Search" disclosed="true" value="#{bindings.IRSearchCriteriaQuery.queryDescriptor}" model="#{bindings.IRSearchCriteriaQuery.queryModel}" queryListener="#{pageFlowScope.SearchBean.doSearch}" queryOperationListener="#{bindings.IRSearchCriteriaQuery.processQueryOperation}" resultComponentId="::resId2" maxColumns="1" displayMode="compact" type="stretch"/>
It's in my grain of support:
public void doSearch(QueryEvent queryEvent) { String bindingName = flag ? "#{bindings.IRSearchCriteriaQuery.processQuery}" : "#{bindings.PartsVOCriteriaQuery.processQuery}"; invokeMethodExpression(bindingName, queryEvent); } private void invokeMethodExpression(String expr, QueryEvent queryEvent) { FacesContext fctx = FacesContext.getCurrentInstance(); ELContext elContext = fctx.getELContext(); ExpressionFactory eFactory = fctx.getApplication().getExpressionFactory(); MethodExpression mexpr = eFactory.createMethodExpression(elContext, expr, Object.class, new Class[] { QueryEvent.class }); mexpr.invoke(elContext, new Object[] { queryEvent }); }
When no number inspection (the only field of research so far) is provided in the query Panel, then it behaves properly. Namely, table tree shows all the search results. However, when a record number of inspection is supplied the table from the tree that was created with the query running Board (don't forget there are two query panels, one of them hides) shows a single result (this is correct), while the other table tree (the one with the control panel hidden query that is not used) shows all the results (this is NOT correct).
What I'm trying to accomplish is still doable? If so, what Miss me?
I use JDeveloper 11.1.1.7
Thank you
Bill
I ended up keeping a single query visible panel permanently and the other hidden permanently. When you perform a search using the table that has the hidden query Panel, I have the descriptor of the request for the Panel to request hidden using the descriptor of the request of the Commission in visible motion of the seeds and then delegate the request:
public void doSearch(QueryEvent queryEvent) { String bindingName = null; if(isIrTableRendered()) { bindingName = "#{bindings.IRSearchCriteriaQuery.processQuery}"; } else { seedPartsQueryDescriptor(); bindingName = "#{bindings.PartsVOCriteriaQuery.processQuery}"; queryEvent = new QueryEvent(partsQuery, partsQuery.getValue()); } invokeMethodExpression(bindingName, queryEvent); } private void seedPartsQueryDescriptor() { ConjunctionCriterion criterion = irQuery.getValue().getConjunctionCriterion(); for(Criterion criteria : criterion.getCriterionList()) { AttributeCriterion attributeCriteria = (AttributeCriterion)criteria; List values = attributeCriteria.getValues(); String qualifiedName = attributeCriteria.getAttribute().getName(); int indexOfDot = qualifiedName.lastIndexOf("."); String name = indexOfDot < 0 ? qualifiedName : qualifiedName.substring(indexOfDot + 1); ConjunctionCriterion partsCriterion = partsQuery.getValue().getConjunctionCriterion(); for (Criterion partsCriteria : partsCriterion.getCriterionList()) { AttributeCriterion partsAttributeCriteria = (AttributeCriterion) partsCriteria; String partsQualifiedName = partsAttributeCriteria.getAttribute().getName(); if (partsQualifiedName.endsWith(name)) { partsAttributeCriteria.setOperator(attributeCriteria.getOperator()); List partsValues = partsAttributeCriteria.getValues(); partsValues.clear(); for (int i = 0, count = values.size(); i < count; i++) { partsValues.set(i, values.get(i)); } } } } } private void invokeMethodExpression(String expr, QueryEvent queryEvent) { FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory(); MethodExpression methodExpression = expressionFactory.createMethodExpression(elContext, expr, Object.class, new Class[] { QueryEvent.class }); methodExpression.invoke(elContext, new Object[] { queryEvent }); }
Then when the basis advanced/Panel visible query button, I put the same mode for the control panel hidden query programmatically:
public void handleQueryModeChange(QueryOperationEvent queryOperationEvent) { if(queryOperationEvent.getOperation() == QueryOperationEvent.Operation.MODE_CHANGE) { QueryMode queryMode = (QueryMode) irQuery.getValue().getUIHints().get(QueryDescriptor.UIHINT_MODE); QueryDescriptor queryDescriptor = partsQuery.getValue(); queryDescriptor.changeMode(queryMode); AdfFacesContext.getCurrentInstance().addPartialTarget(partsQuery); } }
-
How to make the query in a single query? No Union only please...
Hello
I have a series of about 18 queries that find charges in many scenarios. I wanted to have a single query to do this. which displays the result in a single line. Is it possible, I heard analytical functions are good options, but I am new to Oracle. Please help me.
Select count (*) total_count emp; -100
Select coun (*) MGR_count emp where job = "MGR" - 10
Select count (*) dept_count emp where deptno in (10,20) - 75
output...
----------
TOTAL_COUNT MGR_COUNT DEPT_COUNT
100 10 75Thank you
Hello
Here's one way:
SELECT COUNT (*) TOTAL
, COUNTY (CASE job WHEN = END "MGR", 1) AS mgr_count
, COUNT (CASE WHEN deptno IN (10, 20) THEN 1 END) AS dept_count
FROM table_x
;
Instead of putting the conditions in a clause WHERE (where they would exclude whole lines), put the conditions in a CASE expression, where they affect only this column.
-
Turn off the ADF parasmo tab based on the selection of rows in table
Hello
We have page ADF, which consists of a table within a collection of panels, which in turn is inside a Panel tab that user can select several rows in this table. There is also a second tab that you want to activate only if the user has selected a single line in the table. This should be disabled if several lines are selected in the table. Please let me know how this can be accomplished. The selection of multiple rows in the table is a must for users.
I use jDeveloper 11.1.2.3.0
Thank you
Ashwin
Published by: 989372 on April 24, 2013 08:22Hello
1. set up the table for selection of rows multi
2. If you initially created the unique selection table, delete the SelectionListener entry added by JDeveloper
3. create a custom pointing to a managed bean selection listener
4. in the selection listener, call getComponent on the selection event (http://myfaces.apache.org/trinidad/trinidad-api/apidocs/org/apache/myfaces/trinidad/event/SelectionEvent.html) and cast to richeTableau
5. on rich table Manager, call getSelectedRowKeys (http://docs.oracle.com/cd/E28389_01/apirefs.1111/e10684/oracle/adf/view/rich/component/rich/data/RichTable.html)
6. If there is more than one key of the selected row, set a property of a managed bean (for example showTab) false and PPR Panel tab
7 use the property "off" from the showDetailItem (http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_showDetailItem.html) to point to the property Boolean managed beanFrank
-
How to find special characters in a single query
Dear Experts,
Your usual help is needed to resolve the query. My query is ' how to find all special characters such as (% $* & @, ' / +-etc. in a single query?).
Thank you.
for example
A_MIR
A % SIM
A * SIM
SIM HAS)Hello
This can work:
select * from your_table where replace(translate(your_column,' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890','x'),'x','') is not null
Above code verifies an ascii and numbers. You can adjust the chain with other characters you want to see (exclude)
Herald tiomela
http://htendam.WordPress.com -
SQL query returns no row vs. multiple lines
Hello
I am trying to get the result of a simple sql query,
If there is no row returned, he would have "No. ROWS" in the result set.
Other wise all the rows containing data is necessary.
Let me know how this could be achieved. Under query works for the latter and not first case as mentioned below
OUTPUT
+ (box 1) when we use B_ID = 123456 +.
IDS
-----
'NO LINE '.
+ (box 2) when we use B_ID = 12345 +.
IDS
-----
1 11112345
2 22212345
create table TEMP_AAA ( A_ID VARCHAR2(10), B_ID VARCHAR2(10) ) INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('111','12345'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('222','12345'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('333','12000'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('444','10000');
WITH MATCH_ROWS AS ( SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID=12345 ), MATCH_ROW_COUNT AS ( SELECT COUNT(1) AS COUNTS FROM MATCH_ROWS ), PROCESSED_ROWS AS ( SELECT CASE WHEN COUNTS = 0 THEN (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID=12345),'NO ROWS') IDS FROM DUAL) ELSE MATCH_ROWS.IDS END IDS FROM MATCH_ROWS,MATCH_ROW_COUNT ) SELECT * FROM PROCESSED_ROWS;
Hello
I think you want to put this on a report or something. I have what would be easier to do this logic there. But if you want that this is possible.
Like thiswith temp_aaa as (select '111' a_id ,'12345' b_id from dual union all select '222' ,'12345' from dual union all select '333' ,'12000' from dual union all select '444' ,'10000' from dual ) , wanted_rows as ( select '123456' B_ID from dual) select temp_aaa.A_ID || temp_aaa.B_ID IDS from temp_aaa ,wanted_rows where temp_aaa.b_id = wanted_rows.b_id union all select 'NO ROWS' FROM DUAL WHERE (SELECT COUNT(*) FROM TEMP_AAA, wanted_rows WHERE TEMP_AAA.B_ID = wanted_rows.B_ID) = 0
In addition, you mix var and number of always use the same type or convert explicitly (to_number or to_char)
WITH MATCH_ROWS AS ( SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID =12345 -- varchar2(10) number ), ...
And again in the
THEN (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID =12345),'NO ROWS') IDS FROM DUAL) -- varchar2(10) number
Kind regards
Peter
-
Oracle Text multi column index based query returns no rows
Hello
I have a MAH_KERESES_MV table with 3 columns OBJEKTUM_NEV, KERESES_SZOVEG_1, KERESES_SZOVEG_2. I create the following Oracle multi column text index:
ctx_ddl.create_preference exec ('MAH_SEARCH', 'MULTI_COLUMN_DATASTORE');
ctx_ddl.set_attribute exec ('MAH_SEARCH', 'COLUMNS', 'OBJEKTUM_NEV, KERESES_SZOVEG_1, KERESES_SZOVEG_2');
create index MAX_KERES_CTX on MAH_KERESES_MV (OBJEKTUM_NEV)
indexType is ctxsys.context
parameters ("DATASTORE MAH_SEARCH");
But the query returns no rows, although if I make the query with the 'like' operator, and then I get the results as expected:
SELECT id, OBJEKTUM_NEV
OF MAH_KERESES_MV
WHERE CONTAINS (OBJEKTUM_NEV, "C") > 0;
Can some body please help? TIA,
TamasYou can do it in Oracle Text, well it is not necessarily desirable.
You can search the
WHERE CONTAINS(OBJEKTUM_NEV, '%C%')>0;
And it will probably work in a simple test. However, using a leader like this wildcard prevents them the index on the table "list of words" used, so such a request can be very slow on a large system.
You can improve this by using SUBSTRING_INDEX, but making your much bigger index. And you could always hit the 'expansions too' problem if %C % expansion is more than about 15,000 words (depending on version and different settings).Also be aware of differences in case - %C % will match 'fact' or 'FACT', as part of a CONTAINS, but not part of a TYPE.
-
Hi all
I have the following trigger
How I can change to create a single query only, no select two (first to see if exist and secondly to get max)SELECT COUNT(*) INTO ESISTE FROM A_PAZIENTI_NPRELIEVO PNP WHERE K_CODE = :new.K_CODE AND ANNO = :new.ANNO AND TIPORD = :new.TIPORD AND DATA_R = TRUNC(:new.DATA_PRENOTATA); IF ESISTE = 0 THEN SELECT NVL(LPAD(TO_CHAR(MAX(to_number(substr(NPRELIEVO,8,3))) + 1),3,'0'),'001') INTO NPRELIEVOC FROM A_PAZIENTI_NPRELIEVO WHERE K_CODE = :new.K_CODE AND ANNO = :new.ANNO AND TIPORD = :new.TIPORD AND DATA_R = TRUNC(:new.DATA_PRENOTATA); -- NPRELIEVOT := TO_CHAR(:new.ANNO)||to_char(TRUNC(:new.DATA_PRENOTATA),'DDD') ||NPRELIEVOC; insert into A_PAZIENTI_NPRELIEVO VALUES (:new.K_CODE,:new.TIPORD,:new.ANNO,TRUNC(:new.DATA_PRENOTATA),NPRELIEVOT); END IF;
a kind of
Insert in of
Select
Thanks for any helpAssuming that I understand your code, I think that should do what you want:
MERGE INTO a_pazienti_nprelievo apn USING (SELECT :new.k_code k_code, :new.anno anno, :new.tipord tipord, TRUNC(:new.data_prenotata) data_prenotata FROM DUAL) d ON (apn.k_code = d.k_code AND apn.anno = d.anno AND apn.tipord = d.tipord AND apn.data_r = d.data_prenotata) WHEN NOT MATCHED THEN INSERT VALUES (d.k_code, d.tipord, d.anno, d.data_prenotata, TO_CHAR(d.anno)|| TO_CHAR(d.data_prenotata,'ddd');
Maybe you are looking for
-
Cannot load or remove programs without administrative rights. Help!
-
Received last week, plugged into my W500 (Windows XP Professional) - seems to work very well, but I'm mystified by the Ethernet port on the back of the replicator - that is it for? I'm sure it's a simple question with a simple answer, but I don't kno
-
BSOD network, related function for Winsock problem driver-related
I'll give as much detail as possible in order to get the right answer. I'm working on HP G70 - 463CL with Vista Home Premium 64 - bit. The problem is that whenever we try to use something that would require a network function, I have a BSOD with the
-
BlackBerry App World Smartphones do not use WiFi
Currently in the United States with the data roaming not selected but connected to WiFi and everything is fine until I have try and connect to App World when it won't let me 'Data Services' not connected. How can I force App World to use the WiFi con
-
Router configuration Cisco for the IPSec VPN with VPN in Windows 7 builtin client
Where can I find an example config for IPSec VPN where Windows 7 native client to connect to the Cisco routers. I use the cisco 881w, in this case. Thomas McLeod