Skip to content
Advertisement

sqlalchemy concat with more than 2 elements on Oracle DB

considering the following table definition

I create a select-statement using the sqlalchemy.sql.functions.concat with 3 statements

using

the query

is generated. However, when I run this, the exception ORA-00909: invalid number of arguments is thrown. This is because CONCAT (https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions026.htm) only allows 2 Arguments.

My workaround for now ist to use concat inside of concat, which works

However, this makes the resulting sql-query far less readable. Is there a way to create a query using | oparator or to create a more readable sql query for this case using sqlalchemy

Advertisement

Answer

To create a concat with more than 2 parameters + operator can be used:

resulting in a || connected query like this

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement