There is a ascending default index on column “wimindex”.
I want to retrieve just recent one using oracle hint like below.
But it seems that Oracle query hint doesn’t work.
Of course this query is working well on Oracle sql/plus.
Just QT QSqlQuery doesn’t work.
Would you help me ? or any hint?
Below is my code.
thanks…
QString lastWimIdxQuery = “SELECT **/*+ index_rs_desc(VIOLATE, VIOLATE) */** WIMINDEX FROMVIOLATE WHERE wimindex > 0 and rownum =1”;
query.exec(lastWimIdxQuery);
int fieldNo = query.record().indexOf(“WIMINDEX”);
if(query.next()) {
this->m_lastWimIdx = query.value(fieldNo).toInt();
qDebug()<<this->m_thread_name << “ : “ << this->m_lastWimIdx;
}else { return; }
Seems that QT is perhaps eating the comment/hint and not passing it to the database? Create a view in the database using your query and select from that to confirm this hypothesis:
CREATE OR REPLACE VIEW LastWMIdxView as
SELECT **/*+ index_rs_desc(VIOLATE, VIOLATE) */** WIMINDEX
FROM VIOLATE
WHERE wimindex > 0 and rownum =1;
Then use that view in your code:
QString lastWimIdxQuery = "SELECT wmindex FROM LastWMIdxView";
Alternatively, you could run your query as is and check the v$sql view to see what was parsed:
SELECT sql_text
FROm v$sql
WHERE UPPER(sql_text) LIKE '%VIOLATE%';
If it turns out that the comments are being eaten, unless there's a way to control that in QT I think you'll probably have to use the view as outlined above.
Related
I am trying to execute a Cassandra query in Java8.
My query is
SELECT * FROM customer where aor='north'
and I execute it with
session.execute(query)
and got correct answer.
But then I changed my query to SELECT * FROM customer where aor=?
PreparedStatement statement = session.prepare(query);
BoundStatement boundStatement = statement.bind("'north'");
ResultSet results = session.execute(boundStatement);
for (Row row : results) {
System.out.println(row.toString());
}
This is not working. No errors showing but I am not getting any result.
Can someone please help
When you are using statement.bind("'north'"); it means that you want literally find 'north'.
Just change your string to north and it will work as you wanted
I would like to add a dynamic parameter in addition to parameters from Maximo inside SQL query.
Something like that :
select *
from workorder a
where params["where"] or a.parent = :Param
with params["where"] with wonum='1234' and :Param = '1234'
Is it possible with Birt to get wonum value and put it also to :Param ?
Or maybe another way ?
Thanks
open is like that (query is more complicated so I simplify it):
maximoDataSet = MXReportDataSetProvider.create(this.getDataSource().getName(), this.getName());
maximoDataSet.open();
var sqlText = new String();
sqlText = "select column1, column2 as woParent, etc... from workorder where " + params["where"] + " or woParent=:param";
maximoDataSet.setQuery(sqlText);
beforeopen is like that(just to see the query) :
importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/birteaump.log", true ) );
out.println( "\nMy Query: " + this.queryText);
out.close();
I had some code to manipulate :param to replace it with wonum but this.queryText is null.
I'm a newbie to birt report maybe I have to think differently to solve my problem.
Thanks
I used Birt 3.7.1. I saw in a video that we can add a query in a dataset's dialog box. But with my report I only have "scripted data set" when I use the "new data set" button.
Is it possible that my query is null in "beforeopen" is in relation with that ?
If I create another sort of datasource, I will have acces to another sort of dataset ?
thanks
ok I solved my problem.
I created a JDBC data source and I have access to a new sort of data set.
I can put my query in this data set and I have access to "beforeopen" and my query is not null.
Thanks
I cannot understand what is wrong with following query:
var tmp = dbset.AsEnumerable<mytable>().Where(
c=>c.Barcode.Contains("11") && c.Description.Contains("EW") );
return tmp;
Should this be same as:
select * from mytable
where Barcode like '%11%' and Description like '%EW%';
If I run this in sql server i get four rows as it should be, but not when I run the linq query
i get 0 rows.
Can please someone help me. It is rather a simple query and it is giving me such a headache. Thank you very much
You forget fetch data, do this:
var tmp = dbset.AsEnumerable<mytable>().Where(
c=>c.Barcode.Contains("11") && c.Description.Contains("EW") );
return tmp.ToList();
Also do not call AsEnumerable soon, use it as below:
var tmp = ctx.mytable.Where(
c=>c.Barcode.Contains("11") && c.Description.Contains("EW") );
return tmp.ToList();
dbset.AsEnumerable<mytable>()...
Don't do that!
You are causing all your data to get pulled from the database before checking the Where condition.
Other than that, it's not really clear why your query isn't working. Your syntax is correct. I'm guessing the data doesn't actually look like you think it does. Either that, or you're expecting like %EW% to match something in a case-insensitive manner and since the Where clause is being evaluated by LINQ to Objects you're not getting that behavior.
Run a query with only one condition? " c.Barcode.Contains("11") ".
That code should run fine.
everyone! ))
Here is code.
var existingEntities = (from record in globalOne.serviceContext.records_out
where record.timestamp.Date == DateTime.Now.Date
select record ).ToList();
It doesn't work.
Another code:
var existingEntities = (from record in globalOne.serviceContext.records_out
where record.timestamp.Day == DateTime.Now.Day
select record ).ToList();
It does work.
So, problem id in next string:
where record.timestamp.**Date** == DateTime.Now.Date
also won't do
where record.timestamp.Date.Equals(DateTime.Now.Date)
But why? I have no clue. "Timestamp" field is dateTime field in MS SQL SERVER.
And - there is NO records in table.
And I almost forgot - what does it mean - "doesn't work".
App just will not reach the breakpoint after that query(first), without any error, without anything.
Thanks.
You can call record.timestamp.Date because EF can't convert it to required expression tree (then convert it to sql command). In fact EF supports limited number of functions and properties, But for DateTime, EF has some good Canonical functions. You can use them in your case, e.g you can use Day(),Month(),Year() functions to solve your problem (see the link).
I've got a LINQ query that looks like this (at the end):
var query = from myTable0 ...
where myTable1.attributeId == 123 && (bunchaStrings.Contains(myTable1.attributeName)) && myTable2.yesNoValue == 'Y'
When I see the query it turns into this
SELECT ... FROM ... INNER JOIN ... WHERE ... AND (UNICODE([t3].[yesNoValue]) = #p3
So what's happening here is that the value of 'Y' is getting turned into '89' via the UNICODE function. That's all fine, but I'd really like to just be able to see the value of #p3 directly and I can't figure out how to see that value via any methods available from my var.
I would recommend piping the generated SQL out to the output window. There you will be able to see the whole SQL and your parameters values. Then it can also be logged.
Code for it can be found here ->
http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11
Or an easier method (if you've got a handy console around):
MyDataContext context = new MyDataContext()
context.Log = Console.Out
You may also be interested in the LINQ to SQL Visualizer : http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx