Fetching database that starts with number with R library RODBC - sql

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!

Related

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

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

Incorrect syntax near the keyword 'AND' in python html

I am running the code in Spyder(python2.7), the code create a user interface. I put all the values it needed in the input box but it return me with an error message
"('42000', u"[42000] [Microsoft][ODBC SQL Server Driver][SQL
Server]Incorrect syntax near the keyword 'AND'. (156)
(SQLExecDirectW)")"
This is what it should be like:
SELECT * FROM dbo.vw_xxxxxxxxxxxxxxxxxx
WHERE ProbabilityofClosing= xx AND InvestmentProgram = 'xxxxxInvestments'
AND MostLikelyAmount = 55555 AND MostLikelyFundingDate = '06112019'
AND CashOutflowOrInflow = 'Cash Outflow'
AND (FundingCurrency = 'CAD' OR FundingCurrency = 'CLP' OR
FundingCurrency = 'COP' OR FundingCurrency = 'CNH')
but it shows this:
DatabaseError: Execution failed on sql 'SELECT * FROM
dbo.vw_xxxxxxxxxxxxxxxxx WHERE InvestmentProgram = ' xxxxxx' AND AND
AND CashOutflowOrInflow = 'Cash Outflow' AND FundingCurrency = 'BRL'
AND DealStatus = 'Funded'': ('42000', u"[42000] [Microsoft][ODBC SQL
Server Driver][SQL Server]Incorrect syntax near the keyword 'AND'.
(156) (SQLExecDirectW)"

SQL Error: ORA-00971: missing SET keyword

I am getting below error
Error at Command Line : 1 Column : 29
Error report -
SQL Error: ORA-00971: missing SET keyword
00971. 00000 - "missing SET keyword"
Please help me to solve this
here is the query that i used
update siebel.S_LOY_MEMBER a,siebel.s_contact b,siebel.s_contact_x c
SET
a.REC_PTNR_PROM_FLG ='N',
b.SUPPRESS_EMAIL_FLG ='Y',
b.SUPPRESS_FAX_FLG ='Y',
c.ATTRIB_09 ='Y'
where a.PR_CON_ID = b.par_row_id
and b.row_id = c.par_row_id
and a.PROGRAM_ID = '1-15P'
and a.REG_CHANNEL_CD ='Booking'
and a.MEM_NUM ='677609224'
Thanks
Praveen

`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)

ORA-00933: SQL command not properly ended ORA-06512:

What is wrong with this ,
I get this error
OLE DB provider "OraOLEDB.Oracle" for linked server "hades" returned message "ORA-00933: SQL command not properly ended
ORA-06512: at "SAAP.EDI", line 1416".
OLE DB provider "OraOLEDB.Oracle" for linked server "hades" returned message "ORA-00933: SQL command not properly ended
ORA-06512: at "SAAP.EDI", line 1416".
Msg 7320, Level 16, State 2, Line 2
Cannot execute the query "select * from table(edi.ftCustomerCatalog('010','145','000164'))" against OLE DB provider "OraOLEDB.Oracle" for linked server "hades".
Code:
function ftCustomerCatalog(comno varchar2,cpls varchar2, cuno varchar2) return tblCustomerCatalog pipelined
is
c sys_refCursor;
r recCustomerCatalog;
sq varchar2(3000);
begin
sq:='select
a.comno
,a.t$cpls
,coalesce(a.t$cuno,b.t$cuno) as t$cuno
,a.t$cpgs,a.t$item
,a.t$Upcd
,a.t$dsca
,a.t$wght
,a.t$ship
,coalesce(b.t$stdt,c.t$stdt,d.t$stdt,e.t$stdt,f.t$stdt) as T$STDT
,coalesce(b.t$tdat,c.t$tdat,d.t$tdat,e.t$tdat,f.t$tdat) as t$tdat
,coalesce(b.t$qanp,c.t$qanp,d.t$qanp,e.t$qanp,f.t$qanp) as t$qanp
,a.t$pric
,coalesce(b.t$disc,c.t$disc,d.t$disc,e.t$disc,f.t$disc) as t$disc
,coalesce(b.source,c.source,d.source,e.source,f.source) as Source
from table(edi.ftAllPlCatalogs(:comno,cpls)) where t$cuno=:cuno a
left join table(edi.ft30ciDiscounts(:comno,:cpls,:cuno)) b on a.t$item=b.T$item and a.t$cuno=b.t$cuno
Left Join table(edi.ft31CPGDiscounts(:comno,:cpls,:cuno)) c on a.t$cpgs=c.t$cpgs
left Join table(edi.ft31Cdiscounts (:comno,:cpls,:cuno)) d on d.t$cpgs is null
left join table(edi.ft33plpgDiscounts(:comno,:cpls)) e on d.t$disc is null and a.t$cpgs=e.t$cpgs
left join table(edi.ft33PlDiscount(:comno,:cpls)) f on e.t$disc is null
Order by A.T$CPGS, a.t$item;';
Open c for SQ using
comno,cpls,cuno
,comno,cpls,cuno
,comno,cpls,cuno
,comno,cpls,cuno
,comno,cpls
,comno,cpls;
LOOP
fetch c into r;
exit when c%notfound;
pipe row(r);
END LOOP;
close c;
end;
I don't think the syntax
t$stdt=coalesce(b.t$stdt,c.t$stdt,d.t$stdt,e.t$stdt,f.t$stdt)
is valid in Oracle.
Assuming that the meaning is to provide an alias for the expression, I believe the Oracle equivalent would be:
coalesce(b.t$stdt,c.t$stdt,d.t$stdt,e.t$stdt,f.t$stdt) AS stdt
(the AS keyword begin optional)