Home > Database > Mysql Tutorial > How to Fix 'ORA-00909: invalid number of arguments' in Oracle's CONCAT Function?

How to Fix 'ORA-00909: invalid number of arguments' in Oracle's CONCAT Function?

Mary-Kate Olsen
Release: 2024-12-17 19:35:13
Original
423 people have browsed it

How to Fix

Error: "ORA-00909: invalid number of arguments" in CONCAT Function

In your query, you are attempting to use the CONCAT function to concatenate three arguments:

SELECT CONCAT(Name, "(", SUBSTR(Occupation, 1, 1), ")") FROM Occupations;
Copy after login

However, CONCAT only accepts two arguments, and therefore throws the error "ORA-00909: invalid number of arguments."

Solution

To fix this error, you can either use the concatenation operation (||) or the CONCAT_WS function.

Using the concatenation operation (||):

SELECT Name || '(' || SUBSTR(Occupation, 1, 1) || ')' FROM Occupations;
Copy after login

Using the CONCAT_WS function:

SELECT CONCAT_WS('(', Name, SUBSTR(Occupation, 1, 1), ')') FROM Occupations;
Copy after login

Both methods will concatenate the Name, the opening parenthesis, the first character of the Occupation, and the closing parenthesis.

Additional Notes:

  • Double quotes (") are used to enclose identifiers, while single quotes (') are used to wrap strings.
  • CONCAT_WS accepts three arguments: a separator character, and two strings to concatenate.

The above is the detailed content of How to Fix 'ORA-00909: invalid number of arguments' in Oracle's CONCAT Function?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template