I was trying to concatenate 3 columns in SQL from dbvisualizer - mysql

I was trying to concatenate 3 columns in SQL, but I getting error message as
1) [Error Code: -440, SQL State: 42884] DB2 SQL error: SQLCODE:
-440, SQLSTATE: 42884, SQLERRMC: CONCAT;FUNCTION. 2) [Error Code: -727, SQL State: 56098] DB2 SQL error: SQLCODE: -727, SQLSTATE: 56098, SQLERRMC: 2;-440;42884;CONCAT|FUNCTION
This is my query
select concat(number,ID,name) as MemberDetails from Member where number = '123'

This looks like a problem with the schema. Specifically, it involves functions and procedures.
You have two SQL return codes, both of which are errors. The two codes are
-440: Routine &1 in &2 not found with specified parameters. A function or procedure with the specified name and compatible arguments was not found
and
-727: There actually isn't an error code named this. Did you mean -747?
In SQL, a negative number represents an unsuccessful call with an error.
You need a separate alias name. Also you might want to add the alias before the column name just in case there's disambiguation. Here's what it should look like.
select concat(number,ID,name) as M from Member where M.number = '123'
If neither of them worked, it is a problem with the SCHEMA, not with the above query.

Related

How can I fix the error with json_object in postgresql-9.6?

There is Zabbix with PostgreSQL database monitoring. There is one trigger in Zabbix that constantly spam error:
ERROR: function json_object(text[], text[]) does not exist
LINE 11: SELECT json_object(array_agg(name), array_agg(setting)) F...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 190
Found a template in which this trigger is registered. It is standard, I tried to request a line separately in Postgres, as a result the same error.
The request itself:
select json_build_object('extensions',(select array_agg(extname) from (select extname from pg_extension order by extname) as e),'settings', (select json_object(array_agg(name),array_agg(setting)) from (select name,setting from pg_settings where name != 'application_name' order by name) as s));
I ask you to tell what is wrong.
The function json_object(text[], text[]) exists in PostgreSQL (documentation) since version 9.4.
Are you sure you use the version 9.4 or above ? You can check with:
SELECT version();

the query failed to parse.The batch could not be analyzed because of compile errors in ssis

I am getting the following error in SSIS because of that my package is getting failed. I have built the package for Audit purpose for which I am passing both system & user variables. My query is like this.
insert into AuditInfo
(
PackageName
, PackageId
, PacakgeVersion
, StartTime
, WorkflowStatus
, rowcounts
)
values
(
?,?,?,?,?,?
)
Parameter mapping details:
Error of query:
Please help me how to resolve the following issue.
[Execute SQL Task] Error: Executing the query "insert into AuditInfo
(PackageName, PackageId...failed with the following error: "An error
occurred while extracting the result into a variable of type
(DBTYPE_I4)". Possible failure reasons: Problems with the query,
"ResultSet" property not set correctly, parameters not set correctly,
or connection not established correctly.
Ok, your connection type is OLE DB.
This means that on the Parameter Mapping tab, the Parameter Name values are integers, which you used, but they are zero-based. Meaning the first parameter in the query should be named "0", the next parameter should be "1", etc.
You started with the first parameter as "1", so your parameters are not mapping correctly, and you're getting the error.
Here's the documentation

MySQL error "An alias was previously found" when an alias isn't in the query

I have a very odd error while trying to perform an update on a database. This is on an Ubuntu 16.04 server using MySQL 5.7.19-0ubuntu0.16.04.1. The query is:
UPDATE athlet_teamseason SET offkeyreturners = 'test' WHERE athlet_teamseason.id = 29701;
The MySQL error is:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'offkeyreturners = 'test' WHERE athlet_teamseason.id = 29701' at line 1
I am doing this in phpMyAdmin, and it gives a bit more information:
2 errors were found during analysis.
An alias was previously found. (near " " at position 50)
An alias was previously found. (near "'test'" at position 51)
If I try this update directly in the phpMyAdmin user interface (search for record, edit field value, submit form) it works, and the query shown is:
UPDATE athlet_teamseason SET offkeyreturners = 'test' WHERE athlet_teamseason.id = 29701;
which appears to be identical. HOWEVER, if I do a string comparison between the two I get:
So while they appear to be the same, there is a difference somewhere.
The queries were created from a table in a database, using concatenation and referencing cells in a source table. For example:
="UPDATE athlet_teamseason SET offkeyreturners = '"&data!I2&"' WHERE athlet_teamseason.id = "&data!A2&";"
I have thousands of these and they all produce the same error. I've done this dozens of times in older servers, might be an issue with MySQL 5.7?
Thanks to Uueerdo, I eliminated non-printing characters in my query.

Python: Error in SQL Syntax

I am trying to get my Python code to count the number of records in my table. However, the Python shell keeps throwing up a "error in your SQL syntax" message. Does anyone have any ideas on what is wrong?
def count_rows(table):
cur.execute(
"SELECT COUNT(*) FROM %s",
(table,)
)
cur.connection.commit()
count_rows("home_service")
Bound parameters, such as the execute function has can only be used to represent values - not object names or syntactic elements. If you want to dynamically determine set the table name, you'd have to resort to string manipulation:
cur.execute("SELECT COUNT(*) FROM %s" % table)

Lua mySQL update statements and where clauses

So I'm trying to run an update with LuaSQL and mySQL, and seem to be stuck in one place. Whenever I try to update, the WHERE clause always fails on me, stating that the column doesn't exist. However, the column is correct, and the output gives a different column name. This is the update clause and what comes of it after running it
status,errorString = assert(conn:execute[[UPDATE Users SET count=count+1 WHERE userID = user#id50589297]]))
lua: test3.lua:16: LuaSQL: error executing query. MySQL: Unknown column 'user' in 'where clause'
stack traceback:
[C]: in function 'assert'
test3.lua:16: in main chunk
[C]: in ?
You're missing quotes around your string user#id50589297, it's trying to parse it as a column identifier.
status, err = assert(
conn:execute[[UPDATE Users SET count=count+1 WHERE userID='user#id50589297']]))