ColdFusion ORMExecuteQuery ORM missing mapping - orm

I am trying to use ORMExecuteQuery. To do queries something like this:
ORMExecuteQuery("select count(*) from Customer");
This shows an error. So I have reduced the complexity of statement now to something smaller
// This works
rc.Customers = EntityLoad("Customer");
// This crashes
rc.Customers2 = ORMExecuteQuery("from Customer");

I have seen issues with ORMExecuteQuery() and the case of the object name.
Try using
ORMExecuteQuery("from customer");

Related

Unable to query using 4 conditions with WHERE clause

I am trying to query a database to obtain rows that matches 4 conditions.
The code I'm using is the following:
$result = db_query("SELECT * FROM transportesgeneral WHERE CiudadOrigen LIKE '$origen%' AND DepartamentoOrigen LIKE '$origendep' AND DepartamentoDestino LIKE '$destinodep' AND CiudadDestino LIKE '$destino%'");
But it is not working; Nevertheless, when I try it using only 3 conditions; ie:
$result = db_query("SELECT * FROM transportesgeneral WHERE CiudadOrigen LIKE '$origen%' AND DepartamentoOrigen LIKE '$origendep' AND DepartamentoDestino LIKE '$destinodep'");
It does work. Any idea what I'm doing wrong? Or is it not possible at all?
Thank you so much for your clarification smozgur.
Apparently this was the problem:
I was trying to query the database by using the word that contained a tittle "Petén" so I changed the database info and replaced that word to the same one without the tittle "Peten" and it worked.
Now, im not sure why it does not accept the tittle but that was the problem.
If you have any ideas on how I can use the tittle, I would appreciate that very much.

Using a Join query with ignited datatables trying to get a where with two conditions

I am attempting to pull data from mysql database using codeigniter and ignited datatables. I have no troubles pulling the join query with a single where clause, but when I try to add a WHERE x OR y, I can't seem to get it working. Here is the basic code that works fine:
$table = 'test_base';
$table2 = 'lab';
$this->datatables->select('test_base.idlab');
$this->datatables->from($table);
$this->datatables->join($table2, 'test_base.idlab = lab.idlab');
$this->datatables->where('lab.idaccount',$idaccount);
If I wanted to put multiple conditions in the query, I see from the manual that I can put multiple conditions in an array, but this seems to only do an AND, not an OR statement.
I then see that I may be able to create my own sql query using the following:
$this->datatables->where('column != "string"');
So, I tried this:
$this->datatables->where("`lab`.`idaccount`= $idaccount OR `lab`.`idlab` = 0");
SELECT `test_base`.`idlab`
FROM (`test_base`)
JOIN `lab` ON `test_base`.`idlab` = `lab`.`idlab`
WHERE `lab`.`idaccount`=` 124 OR `lab`.`idlab` = 0
ORDER BY `idtest` asc
The issue is that there is an extra (`) in the WHERE `lab`.`idaccount` = `<-here and I'm not sure how to get rid of it.
As #Ehecatl suggests, I got it working by entering the full query into the (). There were no examples on the CodeIgniter website or anywhere else I could find. Still new to CodeIgniter so maybe this will also help others.
Resolution is to put the query string in the $this->datatables->where(); and removing all the single quotes.
$this->datatables->where("lab.idaccount = $idaccount OR lab.idlab = 0");

Rails 3 Error when using OR with a where clause

I'm having a strange issue when using the Where clause in Rails. I imagine it has something to do with my OR operator syntax. Here is my query:
Cookie.where("ID = ? OR ID = ? OR ID = ? OR ID = ?", chocolate.to_s, sugar.to_s, peanut_butter.to_s, oatmeal.to_s)
When I attempt to execute the query my application just hangs endlessly. However, If I submit a query that looks like this:
Cookie.where("ID = ?", chocolate.to_s)
I get the expected result. Any help with the proper format to this where clause would be greatly appreciated. Thanks.
UPDATE
I went into the rails console and did as you suggested. This was the result:
SELECT \"TBLCookies\".* FROM \"TBLCookies\" WHERE (ID in ('4','3','2','1'))
This seems correct. I opened up SQL Developer, pasted this query in, and ran it. I got the expected result. So everything seems to be fine there. However, when I try to run the query in the rails console I get nothing back. The console just hangs indefinitely. Any insight into what could be going wrong would be great.
Why not do this
Cookie.where("ID in (?)",[chocolate, sugar, peanut_butter, oatmeal].collect(&:to_s))

ReleaseCumulativeFlowData and CardState

I'm trying to run a query against the ReleaseCumulativeFlowData object as follows:
((ReleaseObjectID = 12345) AND CardState="Accepted")
However, running the query results in the following error message:
OperationResultError
Could not read: could not read all instances of class
com.f4tech.slm.domain.reporting.ReleaseCumulativeFlowDataSet
Is this a bug in Rally?
WSAPI is very picky about the structure of the query. You have to include parentheses around chained query filters, so you would need something like the following:
((ReleaseObjectID = 12345) AND (CardState = "Accepted"))

LinqPad Not Returning Results With C# Statements

It's late, so this must be something stupid. I have LinqPad connected up to my database and cannot seem to get results for the simplest of queries.
var q = from app in AppInstances
select new {
AppId = app.AppId
};
When I run that, LinqPad says that it executed successfully (C#Statement mode). Nothing is retured.
I can write the following very simple Lambda (C# expression mode):
AppInstances.Select (p => p.AppId)
And that works. Why? I would prefer to use the non-lambda query building functionality. I am sure that this is something all together silly.
I would expect that in statement mode, you'd have to do something like call q.Dump(); to see the results.
But if you just want to use query expressions, why not do that from expression mode? Just use an expression of:
from app in AppInstances
select new {
AppId = app.AppId
};
Or to make it equivalent to your original lambda:
from app in AppInstances
select app.AppId