Error When Using Case When On SAP HANA : SAP DBTech JDBC: [403]: internal error: Error opening the cursor - hana

I have the query like this..
SELECT
sum(wms_trx."trans_net_amt") as "TRANS_AMT_FCY",
wms_trx."trans_type_cd",
CASE WHEN "trans_type_cd" IN (SELECT "ref_value" FROM "B_VIRTUAL"."man_upload_ref")
THEN '1' ELSE '0' END as "IS_FIN_TRANS_FLAG"
FROM "B_VIRTUAL"."sor_wms_trx" AS wms_trx
WHERE wms_trx."batch_date" = '20190501'
GROUP BY wms_trx."trans_type_cd", 'IS_FIN_TRANS_FLAG'
But when I executed it, I got error like this
Could not execute 'SELECT sum(wms_trx."trans_net_amt") as "TRANS_AMT_FCY", wms_trx."trans_type_cd", CASE WHEN ...' in 535 ms 609 µs .
SAP DBTech JDBC: [403]: internal error: Error opening the cursor for the remote database Error while compiling statement: FAILED: ParseException line 1:159 missing ) at 'V1' near 'trans_type_cd' in table source
line 1:196 cannot recognize input near 'V2' 'FROM' 'sor' in table source for query "SELECT "sor_man_upload_ref1"."V1", "sor_man_upload_ref1"."V2", "sor_man_upload_ref2"."V1" FROM ( (SELECT SUM("WMS_TRX"."trans_net_amt") AS "V1", "WMS_TRX"."trans_type_cd" AS "V2" FROM """sor"".""sor_wms_trx""" "WMS_TRX" WHERE "WMS_TRX"."batch_date" = '20190501' GROUP BY "WMS_TRX"."trans_type_cd" ) "sor_man_upload_ref1" LEFT OUTER JOIN (SELECT "sor_man_upload_ref"."ref_value" AS "V1" FROM """sor"".""sor_man_upload_ref""" "sor_man_upload_ref" GROUP BY "sor_man_upload_ref"."ref_value" ) "sor_man_upload_ref2" ON ("sor_man_upload_ref1"."V2" = "sor_man_upload_ref2"."V1") ) "
Please help me... thanks

Related

Excel "The multi-part identifier could not be bound" When Using Parameters

I have a SQL query in Excel that will work just fine if I hard code the dates into the query. As soon as I try to change them to ?'s it gives the error. I've used parameterized queries like this in loads of reports, so I'm not sure why this one is suddenly not working.
The full error is [Microsoft][ODBC SQL Server Driver][SQL Server]The multi-part identifier "cancel.arrival_date" could not be bound. which pops up twice.
Here is my query with the ? in it that gives the error:
SELECT cancel.reservation_number, (client.last_name + ', ' + client.first_name) AS 'guest_name',
cancel.cancel_date_time, cancel.arrival_date,
DATEDIFF(DAY, cancel.cancel_date_time, cancel.arrival_date) AS 'Days Out', cancel.cancel_reason,
CASE
WHEN EXISTS (SELECT *
FROM gbfol_head head
LEFT JOIN gbfol_det det ON head.folio_number = det.folio_number
WHERE cancel.reservation_number = head.source_id
AND head.folio_type <> 'b' AND det.posting_code = 'admn') THEN
'ADMN Charged'
ELSE
'No ADMN Fee'
END AS 'ADMN',
cancel.amount, cancel.cancel_clerk_code, cancel.sba_text
FROM canceled cancel
LEFT JOIN reservation res ON cancel.reservation_number = res.reservation_number
LEFT JOIN clients client ON res.home_client_code = client.client_code
WHERE DATEDIFF(DAY, cancel.cancel_date_time, cancel.arrival_date) < 21
AND (cancel.arrival_date BETWEEN ? AND ?)
If I change the last line to AND (cancel.arrival_date BETWEEN '2019-12-01' AND '2019-12-10') it works fine.
I have also tried using AND (cancel.arrival_date >= ? AND cancel.arrival_date <= ?) which didn't work either, same error.

i'm creating alert in Oracle EBS ERP R12 i wrote this statement and i received error app-alr-01408 SQL error ora-00909 invalid number of argument

I'm creating alert in Oracle EBS ERP R12. I wrote this statement and I received error
app-alr-01408 SQL error ora-00909 invalid number of argument
SELECT prla.line_num, prha.segment1,
prha.requisition_header_id, prla.requisition_line_id,prla.SUGGESTED_VENDOR_PRODUCT_CODE
INTO &pr_ln,
&pr_num,
&pr_hid,
&pr_lid
FROM apps.po_requisition_headers_all prha,
apps.po_requisition_lines_all prla
WHERE prha.requisition_header_id =
prla.equisition_header_id
and nvl( prla.SUGGESTED_VENDOR_PRODUCT_CODE,0 ) not in ( SELECT NVL(pla.vendor_product_num 'x')
FROM po_lines_all pla, po_headers_all pha
where 1 = 1
and pla.po_header_id = pha.po_header_id
and nvl(pla.CANCEL_FALG,'N') = 'N'
and pha.type_lookup_code = 'RFQ'
and pha.ORG_ID =prla.ORG_ID
)
and prla.ROWID = :ROWID

Fetching database that starts with number with R library RODBC

How can I fetch database which starts with number with RODBC library in R? This code gives an error:
myconn <-odbcConnect("Database")
dat <- sqlFetch(myconn, "db.8798")
Error is (after displaying dat in R console):
[1] "42000 102 [Microsoft][ODBC SQL Server Driver][SQL
Server]Incorrect syntax near '.8798'."
[2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT * FROM db.8798'"
Thanks!

weird query behavior oracle sql - convert text to number

oracle query This works
select *
from (
select to_number(substr(app_cluster,6,2), '99') as b
from xtern_app_info
WHERE app_cluster IS NOT NULL
AND APP_CLUSTER <> 'CLUSTER'
);
but when adding 'where b > 2' makes an error, why?
select *
from (
select to_number(substr(app_cluster,6,2), '99') as b
from xtern_app_info
WHERE app_cluster IS NOT NULL
AND APP_CLUSTER <> 'CLUSTER'
) where b > 2;
ORA-29913: error in executing ODCIEXTTABLEFETCH callout
ORA-01722: invalid number
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.

`FOR UPDATE` breaks batch execution in HANA

HANA 102.05 fails to execute the following code:
CREATE TABLE ATABLE( f INT );
CREATE PROCEDURE TestProc()
AS
BEGIN
SELECT f FROM ATABLE
FOR UPDATE; -- Without FOR UPDATE it works
END;
SELECT 'Hello' FROM DUMMY;
complaining that:
SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "SELECT": line 8 col 2 (at pos 124)
which points outside the proceudure, at SELECT 'Hello'. The procedure itself compiles without error. The entire script completes successfully if I remove the FOR UPDATE directive. What is wrong with the original?
Update
When I execute the same query from hdbsql.exe I get:
0 rows affected (overall time 26,076 msec; server time 6518 usec)
* 257: sql syntax error: line 5 col 9 (at pos 71) SQLSTATE: HY000
* 257: sql syntax error: incorrect syntax near "END": line 2 col 1 (at pos 32) SQLSTATE: HY000
'Hello'
"Hello"
1 row selected (overall time 4644 usec; server time 143 usec)