UniData Concatinate in SELECT - universe

I need to search on the concatenated data in UniData using UniQuery. what are my options?
Something like below:
SELECT CUSTOMER.DETAILS WITH (FIRSTNAME:LASTNAME) = "????"
Basically below is search criteria:
FIRSTNAME + LASTNAME = ?
Cheers

Try using EVAL to run a temporary expression in your query:
SELECT CUSTOMER.DETAILS WITH EVAL "FIRSTNAME : LASTNAME" = "????"
I found this blog post with other examples of EVAL as well

Related

Create RelNode of a select query with concat

I went through the documentation of Apache Calcite. Is the relNode correct for the following query in BigQuery?
SELECT CONCAT('a or b',' ', '\n', first_name)
FROM foo.schema.employee
WHERE first_name = 'name';
relNode = builder
.scan("schema.employee")
.filter(builder.call(SqlStdOperatorTable.EQUALS,
builder.field("first_name"),
builder.literal("name"))
.project(builder.call(SqlStdOperatorTable.CONCAT,
builder.literal("a or b"),
builder.literal(" "),
builder.literal("\\n"),
builder.field(first_name)))
.build()
That looks correct at a glance. I would suggest you confirm by looking at the query results and also by converting your RelNode to SQL.

Doctrine query + LIKE expression

I have problems to create a Doctrine Query with LIKE Expression:
QUERY:
$dql = "SELECT u FROM Users u JOIN u.group g WHERE g.name LIKE lower('ADMIN')";
$query = $em->createQuery($dql);
$result = $query->getResult();
ERROR:
QueryException: [Syntax Error] line 0, col 147: Error: Expected Doctrine\ORM\Query\Lexer::T_STRING, got 'lower'
LOWER was just an example, I need to use other functions in LIKE
EXPRESSION, for example, unnacent...
How can I change Like Expression to support function on both sides?
Example: LOWER(unaccent(u.login)) LIKE LOWER(unaccent('ADMIN'))
The like string needs to have % signs. If you want something that starts with ADMIN then you would write ADMIN% if you want something that ends with ADMIN you would write %ADMIN and finally if you want it to contain ADMIN then it would be %ADMIN%.
Maybe to return a string you can use the CONCAT function of doctrine or you can do it via PHP.
I tested this with QueryBuilder and there doesn't seem to be a solution. The second parameter will not take a function, so I would suggest switching the parameters around:
$dql = "SELECT u FROM Users u JOIN u.group g WHERE UPPER(g.name) LIKE 'ADMIN'";

Regexp :: find in files mysql queries which hasn't mysql_real_escape_string

ex:
$sql = "INSERT INTO".$table_name."SET firstname = '".$firstname."',lastname= '".$lastname."',created_on = now()";
with that i found all queries.
My problem is that i need queries which isn't there mysql_real_escape_string.
Any idea?

How do you concatenate two variables for the text of a select.genericlist

in this select.generic list I am wanting to concatenate two variables/fields for the "text" of this list. It is a functioning list.
<?php echo JHtml::_('select.genericlist', $this->assets, 'id', 'class="inputbox" onchange="document.location.href = this.value"', 'link', 'serialnumber' , $this->asset->link);?>
Where 'serialnumber' is the field used for the text of the list, I am trying to get 'model' AND 'serialnumber' so that it displays "Model: serialnumber" in the select list.
Everything i have found for concatenation does not work, and seems to just make a string 'model:serialnumber' which is a non-existant field.
using $model . $serialnumber is a no go as well, though using just one variable works fine.
Thanks for the help!
Simplest thing would be you do a concat at the db level.
So when generating $this->assets you put something like this in the query:
SELECT bla1, bla2, CONCAT('Model: ', bla3) AS text ...
or
SELECT bla1, bla2, CONCAT(model, ': ', serialnumber) AS text ...
if model is a db field.
Taking what Mike said I found where I needed to make the change to the query in the category model of my component. I wasted a lot of time thinking it had to be in the asset model:
$query->select($this->getState('list.select', 'a.id, a.name, CONCAT(a.model,\': \', a.serialnumber)AS modelserialnumber, ...
$query->from('`#__asset_details` AS a');
Thanks Mike for your help!

Escaping queries in Django

I have the following method:
def select_query(self):
sql = "SELECT * FROM {t} WHERE 1".format(t=self._meta.db_table)
for column_name in self.distinguishing_column_names():
sql = sql + " AND {c} = {v}".format(c=column_name, v=getattr(self, column_name))
return sql
This will give me a query like this:
SELECT * FROM customer WHERE 1 AND name = JOHN SMITH AND customer_number = 11423 AND social_security_number = 1234567890 AND phone = 2323523353
Obviously, that's not going to work. Is there a way to get Django to quote this for me?
Note: I'm not asking for a prepared statement. That's something different.
Do you need to return a query this way? The proper way would be to call cursor with the query and the params as argument:
Does Python support MySQL prepared statements?
The correct way to format a query seems to be:
query = query % db.literal(args)
Where db is a mysql.Connection (or presumably any connection)
Apparently the answer is "no."