This question already has an answer here:
Getting error ORA-00909: invalid number of arguments
(1 answer)
Closed 1 year ago.
I'm trying to retrieve report from postgreSQL database to Oracle data base, but it isn't working as I thought. I tried to find related tables in Oracle database and found them as SOR tables, some data is in Datamarts.
SQL Error [909] [42000]: ORA-00909: invalid number of arguments
SQL statement that works just fine in postgreSQL:
`SELECT
'loan' as product,
count(cc.id),
cc."type",
cc.topic,
cc.direction,
TRIM(cc.subject) AS subject,
case when EXISTS (SELECT caf.communication_id
FROM serp_bigmoney_lv.comm_attachment_files caf where cc.id = caf.communication_id) then
'yes'
else 'no' end as file_attached,
concat(us."name",' ',us.surname) as user_name,
cc.createdat::date
from erp_bigmoney_lv.comm_communication cc
left join erp_bigmoney_lv.erp_users us on us.user_id = cc.created_by
where cc."type" = 'note'
GROUP BY cc.createdat::date, user_name, file_attached, cc.direction, cc.topic, cc."type",
product, cc.subject`
CONCAT function only accept two arguments use || to concatenate the fields like:
FIELD_1 || ‘ ‘ || FIELD_2
Related
This question already has answers here:
getting "invalid column" when trying to use column alias in a query
(3 answers)
Closed 1 year ago.
SELECT .....
'NewReserveSum' =
case
when h.ApprovedCurrencyID = 417 then new.ReserveSumV
else [dbo].[GetCurrencyRate](h.ApprovedCurrencyID, #PresentDate) * new.ReserveSumV
end,
(o.ReserveSummN - NewReserveSum) as 'DifferenceReserveSummN'
FROM ......
I want to use the ** NewReserveSum ** variable in the following columns, but I got an error:
Invalid column name 'NewReserveSum'
How can I do it correctly in MSSQL?
In SQL, = is comparison, not assignment
In a SELECT statement, you can use AS to give a name top an expression column:
SELECT
case
when h.ApprovedCurrencyID = 417 then new.ReserveSumV
else [dbo].[GetCurrencyRate](h.ApprovedCurrencyID, #PresentDate) * new.ReserveSumV
end as NewReserveSum,
...
I am sure that you are used to this question but nonetheless I am having trouble with my SQL script. It is very frustrating.
When I execute the SQL against the SAP Hana database, I continuously receive this error:
Errors occurred while executing the SQL statement: SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near ")": line 14 col 35
Let me present the SQL concerned here:
SELECT
BKPF.BKTXT, BKPF.MONAT, BSEG.BELNR, BSEG.BUKRS, BSEG.DMBTR, BSEG.GJAHR, BSEG.MANDT, BSEG.PRCTR, BSEG.SAKNR, CEPCT.KTEXT, CEPCT.LTEXT, SKAT.MCOD1, SKAT.TXT20, SKAT.TXT50
FROM
SAPPR1.BSEG
INNER JOIN SAPPR1.BKPF ON BSEG.GJAHR = BKPF.GJAHR
INNER JOIN SAPPR1.CEPCT ON BSEG.PRCTR = CEPCT.PRCTR
INNER JOIN (SELECT
SAKNR, TXT20, TXT50, MCOD1
FROM
SAPPR1.SKAT
WHERE
SPRAS not LIKE '%[a-z0-9 .]%' ) AS SKAT_SUB ON BSEG.SAKNR = SKAT_SUB.SAKNR
WHERE
BKPF.MONAT = (SELECT Month('?')-1)
AND (BSEG.GJAHR = (SELECT Year('?')-1 HAVING Month('?')-1 < 4) OR BSEG.GJAHR = (SELECT Year('?') HAVING Month('?')-1 > 3))
AND BSEG.MANDT = ?
;
Unlike other DBMS HANA does not support selecting records out of nothing.
A SELECT without a FROM is not valid.
In order to create a single-row set one can use the DUMMY table.
SELECT current_date FROM DUMMY;
creates the single-row set with the result of the function expression.
Having said that, for comparisons a set is not required. Instead the function can be directly put into the expression:
WHERE
BKPF.MONAT = (MONTH(?)-1)
Also note that for string typed bind variables no quotation marks are required or allowed.
this is my first time using oracle Database in the company and I encountered this problem.
SELECT w.TABLE_NAME tbl_nm,
MAX(CASE WHEN t.partition_range LIKE 'year' THEN SUBSTR((w.PARTITION_NAME),1, LENGTH(w.PARTITION_NAME)-4) ELSE concat(SUBSTR((w.PARTITION_NAME), 1, LENGTH(w.PARTITION_NAME)-6)) END) AS par_nm,
MAX(CASE WHEN t.partition_range LIKE 'year' THEN SUBSTR((w.PARTITION_NAME), LENGTH(w.PARTITION_NAME)-3,4) ELSE concat(SUBSTR((w.PARTITION_NAME), LENGTH(w.PARTITION_NAME)-5,6)) END) AS par_date,
t.partition_range par_range,
t.data_dir data_dir,
t.index_dir index_dir,
t.add_range add_range,
CASE WHEN t.partition_range LIKE 'year' THEN EXTRACT(YEAR FROM systimestamp) ELSE TO_CHAR(systimestamp, 'YYYYMM') END AS cur_date
FROM INFORMATION_SCHEMA.PARTITIONS w, t_partition_manage t
WHERE w.TABLE_NAME = t.TABLE_NAME
GROUP BY w.TABLE_NAME
when I Select tbl_nm, par_nm, par_date, par_range, data_dir, index_dir, add_range, cur_date from INFORMATION_SCHEMA.PARTITIONS and t_partition_manage,
there seem to be a problem around in MAX( ... ) and I don't know what is wrong...
This is the error code
00909. 00000 - "invalid number of arguments"
*Cause:
*Action:
and I'm using SQLDeveloper as a client.
There is a problem with concat as it takes two parameters and You are passing only one parameter. Concat is not required at all in your solution:
SUBSTR(w.PARTITION_NAME, 1, LENGTH(w.PARTITION_NAME)-6)
And
SUBSTR(w.PARTITION_NAME), LENGTH(w.PARTITION_NAME)-5,6)
Also, you need more columns in GROUP BY as select can not use columns directly which are not in GROUP BY clause or you can use aggregate function.
Looks like CONCAT; it expects two parameters, while yours has only one.
CONCAT (SUBSTR ((w.PARTITION_NAME), 1, LENGTH (w.PARTITION_NAME) - 6))
This question already has an answer here:
MS Access Query with CASE statement
(1 answer)
Closed 3 years ago.
Getting Syntax Error( missing operator) in query expression, What am I getting wrong?
SELECT
ExportUF_NEW.Position,
ExportUF_NEW.[User Defined Field 03]
(CASE
WHEN ExportUF_NEW.[User Defined Field 03] = OP THEN "Production"
WHEN ExportUF_NEW.[User Defined Field 03] = STM THEN "Thermal"
ELSE NULL
END) AS OperationGroup
FROM ExportUF_NEW
WHERE (((ExportUF_NEW.[User Defined Field 03]) Is Not Null))
Expect an outcome to new column "OperationGroup" based on ExportUF_NEW[User Defined Field 03].
MS Access did not support CASE WHEN, use switch instead.
Similar link: What is the equivalent of Select Case in Access SQL?
In AS400, how can i perform arithmetic operations (like +, -) on fields.
For the query Select id, sum(field1+field2) as Total from table
group by id, getting the following error msg in German "[IBM][System
i Access ODBC-Treiber][DB2 für i5/OS]SQL0104 - Token & ungültig.
Gültige Token: + - AS <IDENTIFIER>." English Translation is something
like "[IBM] [System i Access ODBC Driver] [DB2 for i5/OS] SQL0104 -
Token <END Instruction> invalid. Valid tokens: CL AS IN LOG OUT DATA
<identifier>."
For the query Select count(*) from (select distinct field1 from table where field2="abc", getting the following error msg "[IBM][System i Access ODBC-Treiber][DB2 für i5/OS]SQL0104 - Token <ENDE DER ANWEISUNG> ungültig. Gültige Token: AS CL IN LOG OUT DATA <IDENTIFIER>."
For a query with sub-query got the following error msg
"[IBM][System i Access ODBC-Treiber][DB2 für i5/OS]SQL0104 - Token & ungültig. Gültige Token: < > = <> <= !< !> != >= ¬< ¬> ¬= IN NOT."
Could someone please tell me what's wrong with my sql queries.
TABLE is a reserved word. SQL Reference: Reserved schema names and reserved words.
Single quotes escape a string literal
Double quotes escape a reserved word (similar to brackets in TSQL)
SQL Reference: Identifiers
The queries could be re-written as:
SELECT ID, SUM(FIELD1 + FIELD2) AS TOTAL FROM "TABLE" GROUP BY ID
SELECT COUNT(*) FROM (SELECT DISTINCT FIELD1 FROM "TABLE" WHERE FIELD2 = 'ABC')
UPDATE
DB/2 for i does not support your method of numeric to character conversion or the type of character comparison used in your LIKE query.
The query can be re-written as:
SELECT eds, SUM(INT(sds)) AS totalh
FROM tbl1
WHERE eds BETWEEN 20130500 AND 20130599
AND siteds IN (
SELECT DISTINCT site
FROM tbl2
WHERE H_04 IN ('1234') AND PERIOD = 201305
)
GROUP BY eds
ORDER BY eds
You may need to use DEC instead of INT depending upon the definition of field sds.
SQL Reference:
- INT
- DEC
- BETWEEN
Is the table's name really 'table'?
Odd as it seems, if I use the SQL statement you indicated as is, I get the same error... but if I change 'table' to 'table1', it just complains that it can't find 'table1'.