Sorting Query Trouble
Try as I might I cannot get sorting to work on my screen.
I have an child entity "orders" that shows the orders made for the parent entity when a specific parnt name is selected.
On the screen I have several tabs showing the grids for orders but none of my table or screen queries is sorting the grids properties in the order defined by a query.
I am trying to sort by a boolean "Reviewed" check box and put the ones checked in order alphabetically by string "name".
Then the ones that are not checked or null in alphabetical order. Since no query would even function for some unknow reason.
I tried just hitting the sort at the top of the "reviewed" column but it only orders them by True false null and not alphabetically.
Note too Name comes from a related table one "Name" to many "Orders".
Can you think of anything I might be doing wrong?
I think you are on the right track here. I want to edit the child entity manually but I don't know how. I went to the edit query for the child entity on the screen but there is no option to add code to manually sort or filter for a screen query in VS LS
2012. Ideally I would like to sort all instances of the grid control by Monogram or MonogramC(a calculated field) AND by Reviewed(a boolean) OR just filter the specific Grid under one of the tabs the Grid is named MedicationOrderDetails5.
How do I do this I am not sure about even the code to use I have thought of adding the following to the screen code. How would you code something like this?
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
//added to alow OLE DB data set code
using System.Data;
//using System.Data.OleDb;
//added for Process Start statement
using System.Diagnostics;
using System.Linq.Expressions;
namespace LightSwitchApplication
public partial class TimesAndMARs
partial void TimesAndMARs_InitializeDataWorkspace(List<IDataService> saveChangesTo)
// Write your code here.
//MedicationOrderDetails5
partial void Reviewed_Filter(ref Expression<Func<MedicationOrderDetail, bool>> filter)
filter = e => e.Reviewed != true;
partial void OrderedByMonoramCalculatedField_PreprocessQuery
(short? MonogramC, ref IQueryable<MedicationOrderDetail> query)
query = (from myOrder in query
where myOrder.MonogramC.Count() > 0
orderby myOrder.MonogramC ascending
select myOrder);
Similar Messages
-
Hi i am having trouble getting my head around an sql query. The query:
"SELECT t.pub_name, tl.accountno
FROM tenant_login tl, tenants t
WHERE t.pub_name = '"+name+"' AND t.accountno = tl.accountno";
produces a list of pub names and account numbers when an account number exists both in tenant_login and tenants.
How do i create a query that lists the pubname and account numbers where the account number exists in tenants but NOT in tenant_login?
ThanksSELECT t.pub_name, tl.accountno
FROM tenants t
WHERE t.pub_name = '"+name+"' AND t.accountno not in
(select accountno from tenant_login )one small change i think
SELECT t.pub_name, t.accountno
FROM tenants t
WHERE t.pub_name = '"+name+"' AND t.accountno not in
(select accountno from tenant_login ) -
Rownum / sorting / query stops working / friday afternoon nightmate
Greetings,
Let's say I have a perfectly working and very simple sql statement. This little thing turned my friday to nightmare. And I hope one of you can help me. :)
SELECT 1
FROM my_tablel l
WHERE l.first_id = :b1
AND l.open_flag = 'Y'
AND NVL (l.flag_id, 'N') = 'N'
AND l.flag_id IN (SELECT flag2_id
FROM my_second_table
WHERE flag3_id = :b2)
If I add this row:
AND ROWNUM = 1;
stops working.
If I would use some agg, or sorting ie. "SELECT COUNT (*)" instead of "SELECT 1" , query works once again.
This (similar)small problem caused many problems in our system, and began after applying a patch (for years it was fine). Worse enough, I can not change the SQL. I really wonder if anyone can say, what may be the reason.
Thanks a lot.
CHEERS.
Edited by: 855652 on 29.Nis.2011 08:29While I am trying to eat the keyboard (yeah, that feeling many of you know very well), I decide to write down even simpler form of the question.
SELECT 1
FROM my_tablel l
WHERE l.first_id = :b1
AND l.open_flag = 'Y'
AND NVL (l.flag_id, 'N') = 'N'
AND l.flag_id IN (SELECT flag2_id
FROM my_second_table
WHERE flag3_id = :b2)
Works..
SELECT 1
FROM my_tablel l
WHERE l.first_id = :b1
AND l.open_flag = 'Y'
AND NVL (l.flag_id, 'N') = 'N'
AND l.flag_id IN (SELECT flag2_id
FROM my_second_table
WHERE flag3_id = :b2)
AND ROWNUM = 1
Goes into infinite loop
SELECT count(*)
FROM my_tablel l
WHERE l.first_id = :b1
AND l.open_flag = 'Y'
AND NVL (l.flag_id, 'N') = 'N'
AND l.flag_id IN (SELECT flag2_id
FROM my_second_table
WHERE flag3_id = :b2)
AND ROWNUM = 1
Works again. -
Could someone save me an aneurysm and tell me how an artist named "Jackson Browne" ends up showing up in my library in the O's when sorted? I've tried changing the Sorting tags, even completely erasing the Artist Name, then re-typing it in, and yet, it still shows up in in the O's.
Help.
This *****.I think you are on the right track here. I want to edit the child entity manually but I don't know how. I went to the edit query for the child entity on the screen but there is no option to add code to manually sort or filter for a screen query in VS LS
2012. Ideally I would like to sort all instances of the grid control by Monogram or MonogramC(a calculated field) AND by Reviewed(a boolean) OR just filter the specific Grid under one of the tabs the Grid is named MedicationOrderDetails5.
How do I do this I am not sure about even the code to use I have thought of adding the following to the screen code. How would you code something like this?
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
//added to alow OLE DB data set code
using System.Data;
//using System.Data.OleDb;
//added for Process Start statement
using System.Diagnostics;
using System.Linq.Expressions;
namespace LightSwitchApplication
public partial class TimesAndMARs
partial void TimesAndMARs_InitializeDataWorkspace(List<IDataService> saveChangesTo)
// Write your code here.
//MedicationOrderDetails5
partial void Reviewed_Filter(ref Expression<Func<MedicationOrderDetail, bool>> filter)
filter = e => e.Reviewed != true;
partial void OrderedByMonoramCalculatedField_PreprocessQuery
(short? MonogramC, ref IQueryable<MedicationOrderDetail> query)
query = (from myOrder in query
where myOrder.MonogramC.Count() > 0
orderby myOrder.MonogramC ascending
select myOrder); -
What's the best way to sort query results?
Hello All,
I have a standard CRUD UI that now needs the results sorted, based on input from the UI. What's the best way to sort results by entity fields?
I'm familiar with the conventional Java methodology using a TreeSet and comparator. Is this the best route, does BDB JE offer more convenient or performant alternatives?
I looked through the documentation and saw how to change the indexes, but I'm just looking to change the order in the scope of the query.
If my application were an address book, the UI would be sortable, ascending and descending, by date added, first name, last name, etc. based on which column the user clicked on.
Thanks in advance,
Steven
Harvard Children's Hospital Informatics ProgramHi Steven,
Using standard Java collections is probably the best approach.
One thing that may be useful is to get a SortedMap (Primary or SecondaryIndex.sortedMap) for the case where you have an index sorted the way you want, and then copy the primary index into a TreeMap (with a comparator) for other cases. That way, you always have a SortedMap to work with, whether you're copying the index or not.
I haven't tried this myself, just a thought.
--mark -
Hi Expert.
I have a big problem.
When I insert a query in a workbook this not sort by keyfigure.
I insert a condition ( TOP 20 for example ).
If I refresh a query in a workbook this sort correct but if I execute a workbook this is sorted by characteristic.
My problem is like
Sorting by a Key Figure in Query Designer
Anybody find a solution?
Thank,
Marcoadd
I can sort a query using VBA code but the problem is when I have a query with hierarchy. -
Sorting query in MDX query filter in PPS
Hi,
Iam new to the PPS world. Iam using MDX query filter and I need to create a filter field using the [BusinessLine].[Department] dimension. I need to sort the display value of Department in descending order in the filter and Iam using the following
Order([BusinessLine].[Department],[BusinessLine].[Department],DESC) in the query window while creating the filter. But Iam getting 'No value found'! result.
Please let me know Iam doing any mistake in thisHi Umair,
Thanks for the reply
The department here is Attribute and BusinessLine is dimension in my cube.For other requirement(the department has to be sorted based on the creation date attribute) purpose I have kept department as composite key with other attribute called CREATE_DATE
with named column as department
Order (
[BuisnessLine].[Department].[DEPARTMENT],
[BusinessLine].[CREATE_DATE].Properties("Name"),
DESC
Iam just replacing the above query as it is in the Enter MDX formul? page
Is it correct. -
Sorting query based on connect level
Hi. I have a query like this:
SELECT DISTINCT
LOAD_PROF2,
V_TIME,
SUBSTATION_CODE,
CIRCUIT_CODE,
PROFILE_DAY,
DECODE (UPPER (PROFILE_DAY),
'MONDAY', 1,
'TUESDAY', 2,
'WEDNESDAY', 3,
'THURSDAY', 4,
'FRIDAY', 5,
'SATURDAY', 6,
'SUNDAY', 7,
'HOLIDAY', 8,
'H_THURSDAY', 9,
'H_FRIDAY', 10)
ORDERBY
FROM LOAD_PROFILE_TEST
WHERE SUBSTATION_CODE = V_SUBSTATION_CODE
AND CIRCUIT_CODE = V_CIRCUIT_CODE
AND UPPER (PROFILE_DAY) IN ( SELECT UPPER (
TO_CHAR (
V_DATE + (LEVEL - 1),
'fmDAY'))
FROM DUAL
CONNECT BY LEVEL <=
V_DATE_IN - V_DATE + 1)
ORDER BY ORDERBY, V_TIME;
If i use V_DATE as 10/10/2013 and V_DATE_IN as 10/13/2013, I will get an output that is sorted based on ORDERBY (which I created), which will be
Thursday, Friday, Saturday and Sunday. However, when I use 10/19/2013 as my V_DATE_IN, I get an output that is sorted like Monday, Tuesday...Sunday. How do I sort it so that the first day that would appear must be the day of my V_DATE, in this case if I use 10/10/2013 as my V_DATE and 10/19/2013 as V_DATE_IN, i should get an output sorted like Thursday, Friday...Wednesday.
What should I replace my ORDERBY to get this type of sorting? ThanksCan you check if this query is what you wanted and matches your expectations.??
UNTESTED from my side....
SELECT LOAD_PROF2,
V_TIME,
SUBSTATION_CODE,
CIRCUIT_CODE,
PROFILE_DAY
FROM LOAD_PROFILE_TEST a,
( SELECT V_DATE + (LEVEL - 1) dt,UPPER (TO_CHAR (V_DATE + (LEVEL - 1), 'fmDAY')) days
FROM DUAL
CONNECT BY LEVEL <= V_DATE_IN - V_DATE + 1) b
WHERE SUBSTATION_CODE = V_SUBSTATION_CODE
AND CIRCUIT_CODE = V_CIRCUIT_CODE
AND UPPER (a.PROFILE_DAY) = b.days
GROUP BY LOAD_PROF2,
V_TIME,
SUBSTATION_CODE,
CIRCUIT_CODE,
PROFILE_DAY
ORDER BY b.dt, v_time;
Cheers,
Manik. -
Query trouble - EXISTS doesnt work like I thought
EXISTS is not behaving like I had hoped.
Help would be much appreciated
SELECT count(*) from OPPS
WHERE OPP_CODE = "A"
AND
EXISTS (
SELECT * FROM OPP_SUB_TABLE S, OPPS O
WHERE S.ID = O.ID AND
S.DTYPE = "1" AND S.DSUBTYPE = "2"
There are 14000 rows in OPPS where OPP_CODE="A"
There are only 31 rows in OPP_SUB_TABLE that have
both DTYPE = "1" and DSUBTYPE = "2"
I thought exists would work like an IN sort of, bringing me only 31 results.
Instead I get all 14000, what I am missing here?EXISTS is like a boolean operation. It will return the row in your outer query if at least one row exists in your subquery.
Because you haven't coordinated the subquery with your outer query, every row will be returned (apparently because your inner query always returns a row).
I'm guessing you meant something like this:
SELECT count(*)
FROM OPPS O
WHERE O.OPP_CODE = 'A'
AND EXISTS (SELECT 1
FROM OPP_SUB_TABLE S
WHERE S.ID = O.ID
AND S.DTYPE = '1'
AND S.DSUBTYPE = '2'
;(fixed the double quotes per Warren's example)
Message was edited by:
Eric H -
How to do linguistic sort query using Toplink API
Hi,
I want to write a Toplink query using linguistic sort like the following SQL,
SELECT * from emp_name
where ename LIKE 'müller%'
ORDER BY NLSSORT(ename, 'NLS_SORT=german')
I got two questions:
(1) how to implement "ORDER BY NLSSORT(name, 'NLS_SORT=german')" using Toplink API.
(2) I built linguistic index,
CREATE INDEX nls_index ON emp_name (NLSSORT(ename, 'NLS_SORT = german'));
But SQL plan shows that LIKE clause does not use index. I wonder how to enforce query with LIKE clause to use such linguistic index.
Thanks for your help in advance.
-EvanLooks like we can not do an exact word search using Java API.
-
I have a table having single column c1 of varchar2(10) and have stored these values in the table.
A0
A1
A01
A100
A101
A102
B10
B99
B100
B101
B102
100
120
200
I need to sort them in the order as given, can someone help please.
Thanksselect c
from (select c, substr(c,1,1) c1, length(c) len, substr(c,2) c2 from xx)
order by case when ascii(c1) < 65
then ascii(c1)+100
else ascii(c1)
end, len, c2 -
VLV & Server Side Sort Query with ODSEE 11g
Hi
We are trying to integrate Microsoft FIM with ODSEE.. When FIM does a Full Import it with VLVControl and SortControl ON it gets the following error
1100 objects were returned on import, exceeding the configured page size in the Run Profile of 500. Only the first 500 objects were processed. Import aborted.
Now looking at ODSEE Logs it does the following
[27/Mar/2015:08:29:40 +1100] conn=1 op=1 msgId=402743 - SRCH base="<BASENAME>" scope=2 filter="<FILTER NAME>" attrs="<LONG LIST OF ATTRIBUTES>"
[27/Mar/2015:08:29:40 +1100] conn=1 op=1 msgId=402743 - SORT dn
[27/Mar/2015:08:29:40 +1100] conn=1 op=1 msgId=402743 - VLV 0:499:0:0 1:40 (0)
[27/Mar/2015:08:29:40 +1100] conn=1 op=1 msgId=402743 - SORT dn
[27/Mar/2015:08:29:40 +1100] conn=1 op=1 msgId=402743 - VLV 0:499:0:0 1:4 (0)
[27/Mar/2015:08:29:40 +1100] conn=1 op=1 msgId=402743 - SORT dn
[27/Mar/2015:08:29:40 +1100] conn=1 op=1 msgId=402743 - VLV 0:499:0:0 1:6412 (0)
[27/Mar/2015:08:29:41 +1100] conn=1 op=1 msgId=402743 - SORT dn
[27/Mar/2015:08:29:41 +1100] conn=1 op=1 msgId=402743 - VLV 0:499:0:0 1:685 (0)
[27/Mar/2015:08:29:41 +1100] conn=1 op=1 msgId=402743 - SORT dn
[27/Mar/2015:08:29:41 +1100] conn=1 op=1 msgId=402743 - VLV 0:499:0:0 1:232 (0)
[27/Mar/2015:08:29:41 +1100] conn=1 op=1 msgId=402743 - RESULT err=0 tag=101 nentries=1100 etime=1
[27/Mar/2015:08:29:55 +1100] conn=3 op=2 msgId=402744 - UNBIND
Ofcourse as we can see it is returning 1100 but FIM is expecting only 500.. Microsoft suggests that VLV index and server side sort is not correctly configured on our end. What could be going wrong here? We have both the supported controls ON in ODSEE. I have created a vlvindex entry in dse.ldif matching the SORT dn and vlvbase,vlvscope and vlvfilter
Not well versed with VLV and sort index..Hello,
Could you try to perform an equivalent search with the ldapseatch that comes with DSEE and check how many entries are returned ?
See ldapsearch(1) (Sun Java System Directory Server Enterprise Edition 6.2 Man Page Reference) , option -G
If the ldapsearch returns more than 500 entries, I would encourage you to contact the Oracle Support.
-Sylvain
Please mark this response as correct or helpful when appropriate to make it easier for others to find it -
Hi,
Say I have 100 rows retrieved in Forms (6i) block as a result of execute_query from a table of 10 million rows
Is there any way I can re-sort these rows in the Forms result set, without going back to the database with a new 'ORDER BY' clause?
Thanks,
ArpadNot without writing a gazillion lines of code.
That would certainly be a nice enhancement for Oracle to provide in Forms. There are just so many places people could use it. ...but don't hold your breath waiting for it. -
I have a table in my database called message_builder. It is probably badly designed and looks like this
message_builder(message_ID, sent_business_ID1, sent_business_ID2, sent_business_ID3)
Another table business looks like this:
business(business_ID, name)
I want to write a query that returns each row of the message_builder table but instead of returning the business IDs I want it to return the names of the businesses (so do a join with the business table).
Is this possible or do I need to redesign my tables?
So for example if the first row returned the following busiiness IDs - 1, 3, 5
Then the result of the query would read:
business1_name, business3_name, business5_name
Thanks for your help,
WallaceSomething like
SELECT mb.message_ID,
b1.name,
b2.name,
b3.name
FROM message_builder mb,
business b1,
business b2,
business b3
WHERE mb.sent_business_id1 = b1.business_id
AND mb.sent_business_id2 = b2.business_id
AND mb.sent_business_id3 = b3.business_idJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Hello everybody,
I'm trying to execute SQL with DI Server. This is my SOAP-command:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<SessionID>63089993-AC37-4225-845D-D9722A50D5A7</SessionID>
</env:Header>
<env:Body>
<dis:ExecuteSQL xmlns:dis="http://www.sap.com/SBO/DIS">
<DoQuery>SELECT NULL AS Cat1Name, NULL AS Cat2Name, NULL AS Cat3Name, NULL AS Cat4Name,
NULL AS Cat1Code, NULL AS Cat2Code, NULL AS Cat3Code, NULL AS Cat4Code
FROM OITM
WHERE 0 = 1 /* Dummy query to circumvent problems with XML-tag */
UNION
SELECT Cat1Name, Cat2Name, Cat3Name, Cat4Name, Cat1Code, Cat2Code, Cat3Code, Cat4Code
FROM (
SELECT cat1.Name AS Cat1Name, cat2.Name AS Cat2Name, cat3.Name AS Cat3Name, cat4.Name AS Cat4Name,
cat1.Code AS Cat1Code, cat2.Code AS Cat2Code, cat3.Code AS Cat3Code, cat4.Code AS Cat4Code
FROM @CATEGORY_4 cat4
JOIN @CATEGORY_3 cat3 ON cat3.Code = cat4.U_Category_3
JOIN @CATEGORY_2 cat2 ON cat2.Code = cat3.U_Category_2
JOIN @CATEGORY_1 cat1 ON cat1.Code = cat2.U_Category_1
UNION
SELECT cat1.Name AS Cat1Name, cat2.Name AS Cat2Name, cat3.Name AS Cat3Name, NULL AS Cat4Name,
cat1.Code AS Cat1Code, cat2.Code AS Cat2Code, cat3.Code AS Cat3Code, NULL AS Cat4Code
FROM @CATEGORY_3 cat3
JOIN @CATEGORY_2 cat2 ON cat2.Code = cat3.U_Category_2
JOIN @CATEGORY_1 cat1 ON cat1.Code = cat2.U_Category_1
UNION
SELECT cat1.Name AS Cat1Name, cat2.Name AS Cat2Name, NULL AS Cat3Name, NULL AS Cat4Name,
cat1.Code AS Cat1Code, cat2.Code AS Cat2Code, NULL AS Cat3Code, NULL AS Cat4Code
FROM @CATEGORY_2 cat2 JOIN @CATEGORY_1 cat1 ON cat1.Code = cat2.U_Category_1
UNION
SELECT cat1.Name AS Cat1Name, NULL AS Cat2Name, NULL AS Cat3Name, NULL AS Cat4Name,
cat1.Code AS Cat1Code, NULL AS Cat2Code, NULL AS Cat3Code, NULL AS Cat4Code
FROM @CATEGORY_1 cat1
) TMP
WHERE ISNULL(Cat1Code, '') = '101'
OR ISNULL(Cat2Code, '') = '101'
OR ISNULL(Cat3Code, '') = '101'
OR ISNULL(Cat4Code, '') = '101'
OR '101' = ''</DoQuery>
</dis:ExecuteSQL>
</env:Body>
</env:Envelope>
When I run the SQL-bit in SQL Server 2005, all is fine. When I run this with DI Server, I get this response:
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<env:Fault>
<env:Code>
<env:Value>env:Receiver</env:Value>
<env:Subcode>
<env:Value>229</env:Value>
</env:Subcode>
</env:Code>
<env:Reason>
<env:Text xml:lang="en">Failed to execute command</env:Text>
</env:Reason>
<env:Detail>
<Statement>..The Query..</Statement>
<Command>ExecuteSQL</Command>
<SessionID>63089993-AC37-4225-845D-D9722A50D5A7</SessionID>
</env:Detail>
</env:Fault>
</env:Body>
</env:Envelope>
Is this query too complex for the DI server to handle? Is it the subquery? Is it the unions?
Thanks for your time!
VincentI have tried other queries in my application and they all don't seem to work anymore.
I recently upgraded from PL39 to PL42. Has there been a change in the SOAP schema again?
Maybe you are looking for
-
How do i find out what is taking up all of my gb on my iphone 4
I do i find out what is taking up all of my gb on my iphone 4? I have deleated all of my pictures, music, and games. There is nothing left in the usuage column to deleate but it says i have used 3.8. Where is it hiding?
-
Media Encoder CC Has Disappeared and Can't Be found!
My Media Encoder CC is gone and won't return. I tried uninstalling After Effects and Premiere Pro, then reinstalling on the assumption it was part of one of thsoe two packages, but alas ... still no Media Encoder. What do I do?
-
VERIZON WIRELESS, I AM TRYING TO SET UP A PAYMENT OF $529.62 FROM MY CHECKING ACCOUNT (OR LOCKBOX ACCOUNT) ON FRIDAY 12/20/13. PLEASE HELP ME WITH THIS OR GIVE THE PHONE NUMBER OF A CUSTOMER SERVICE AGENT THAT CAN HELP ME. THANK YOU.
-
Limit No of Rows in Table View
Hi All, I have a requirement like in a table view report i need to limit the no of rows to 100. If the no of rows in report exceeds 100 then the end sure should get message like " No of rows exceeded the limit, Please modify the seach criteria". If a
-
FF not responding I have tried everything.
I have tried clean install and disable of addons .I even had AT&T connect tech try to fix the problem.I hope you can help. Thanks