Oracle , when merge, show " invalid identifier" - sql

MERGE INTO EP_PR
using(
select
SYSDATE AS CREATION_TIME_1,
1 AS STATUS_1,
0 AS DELETED_1,
SYSDATE AS LAST_MOD_TIME_1,
0 AS EP_STATUS_1,
SYSDATE AS EP_ISSUE_DATE_1,
CASE WHEN LENGTH(EKORG)<2 THEN 'UMC1' ELSE EKORG END AS EP_PURORG_1,
EKGRP AS EP_PURGRP_1
from ZEPT02
Where proc_flag='N'
) TABLE1
ON
(
TABLE1.EP_PR_NO_1=EP_PR.EP_PR_NO
)
WHEN MATCHED
THEN UPDATE SET
EP_PR.CREATION_TIME=TABLE1.CREATION_TIME_1,
EP_PR.STATUS=TABLE1.STATUS_1,
EP_PR.DELETED=TABLE1.DELETED_1,
EP_PR.LAST_MOD_TIME=TABLE1.LAST_MOD_TIME_1,
EP_PR.EP_STATUS=TABLE1.EP_STATUS_1,
EP_PR.EP_ISSUE_DATE=TABLE1.EP_ISSUE_DATE_1,
EP_PR.EP_PURORG=TABLE1.EP_PURORG_1,
EP_PR.EP_PURGRP=TABLE1.EP_PURGRP_1;
It shows errors that
SQL error: ORA-00904: "TABLE1"."EP_PR_NO_1": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
I'm trying to google it,
but my on clause "TABLE1"."EP_PR_NO_1" didn't appear at the merge column,
where did it wrong?
Thanks!

You haven't defined TABLE1.EP_PER_NO_1 anywhere, which is exactly what the Oracle error is telling you.

Related

Is it possible to run sql query against an oracle package?

I have a query regarding a sql query that passes some data to an Oracle package. My sql query tries to cross against the data that is processed by this package, furthermore I visually validated that this package exists and I have access. But when executing the query, it returns me that there is no such package.
I leave the sql statement:
SELECT NVL(ROUND(SUM(MONTO_CUOTA *
DECODE(A.TIPO_IMPUTACION, 1, 1, 2, -1, 1) *
CONTROL_OPERAC.PCK_SERVICIO.OBTENER_VALOR_1(FECHA_VALOR_CUOTA,
TIPO_FONDO) / CASE
WHEN VINU_TIPO_MONEDA = 1 THEN
1
WHEN VINU_TIPO_MONEDA = 2 THEN
CONTROL_OPERAC.PCK_SERVICIO.OBTENER_VALOR_2(FECHA_IMPUTACION)
ELSE
1
END),
2),
0)
FROM TABLE(MOVIMIENTO.PCK_CART_PIPELINED.EXAMPLE(44682158,
1,
1,
NULL,
NULL,
NULL,
13-05-1981,
31-07-2020,
NULL)) A,
DATOSEXAM.MAPEO_CODIGOS B
WHERE A.ID_CODIGO_MVTO = B.ID_CODIGO_MVTO
AND B.TIPO_CUENTA = A.TIPO_CUENTA
AND B.CLASIFICACION = 'EXAMPLE'
AND A.ID_ADMINISTRADORA = 900;
The error message that I get is the following:
ORA-00904: "MOVIMIENTO"."PCK_CART_PIPELINED"."EXAMPLE": identificador no válido
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error en la línea: 15, columna: 18
Is it possible to execute this query when being against a package?
Thank you very much in advance, I will be attentive to your answers.
Regards!

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

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.

Can we execute select statement in AND conditon (getting error missing expression)

I am building a complex query. First here is my query
select LOSA_APP.app_ref_no AS "App.Ref.No."
from losa_app LOSA_APP,
losa_app_z LOSA_APP_Z
where
LOSA_APP.app_status='A'
and
trunc(sysdate) between (nvl(LOSA_APP_Z.li_dt, LOSA_APP_Z.li_collect_dt)) AND ((trunc(sysdate)))
and
(trunc(sysdate) - nvl(losa_app_z.li_dt,losa_app_z.li_collect_dt)) > 90
and
(select losa_app_z.app_ref_no
from losa_app_z
where (trunc(sysdate) - nvl(losa_app_z.li_dt, losa_app_z.li_collect_dt)) > 90
)
The problem is if i run the last query separately or i omit the last query then it is run fine, like if i only run
(select losa_app_z.app_ref_no
from losa_app_z
where (trunc(sysdate) - nvl(losa_app_z.li_dt, losa_app_z.li_collect_dt)) > 90)
but if i run the whole query then i get the error
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Error at Line: 7 Column: 128
Line 7 is the line at which my last query and
(select losa_app_z.app_ref_no from losa_app_z.... is present. What i am doing wrong ? Please help.
Thanks
You should compare result of this query
and
(select losa_app_z.app_ref_no
from losa_app_z
where (trunc(sysdate) - nvl(losa_app_z.li_dt, losa_app_z.li_collect_dt)) > 90
) = something_here
to something.
For future always try to manage your brackets properly. Count them if necessary.

getting error while executing case statement

I am trying to execute case statement but i am getting an error. Here is my query
select LOSA_APP.app_ref_no AS "App.Ref.No.", CODE_BRANCH.branch_name AS "BRANCH"
from losa_app LOSA_APP
INNER JOIN
losa_app_z LOSA_APP_Z
ON
losa_app.app_ref_no = losa_app_z.app_ref_no
INNER JOIN
code_branch CODE_BRANCH
ON
LOSA_APP.attend_branch = CODE_BRANCH.branch_id
where
LOSA_APP.app_status='A' -- Application Status in {‘accepted’}
and
trunc(sysdate) between (nvl(LOSA_APP_Z.li_dt, LOSA_APP_Z.li_collect_dt)) AND ((trunc(sysdate))) -- falling under the reporting period
and
(trunc(sysdate) - nvl(losa_app_z.li_dt,losa_app_z.li_collect_dt)) > 90 -- select application cases at any step after entering Documentation flows.
and
losa_app.product_type = 'MG' -- Select records based on input parameter value passed in.
and
case :input1
when 'ABB' Then code_branch.branch_code1 like '%0232%'
when 'AiBB' Then code_branch.branch_code1 like '%0347%'
end
While executing it asks me for input. After that it gives me error that
ORA-00905: missing keyword
00905. 00000 - "missing keyword"
*Cause:
*Action:
Error at Line: 22 Column: 50
Line 22 is when 'ABB' Then code_branch.branch_code1 like '%0232%'
What keyword i am missing?
Thanks
Don't try to return a logical boolean from the CASE statement.
Instead, make the CASE statement part of the logical test. Such as...
code_branch.branch_code1
like
case :input1 when 'ABB' Then '%0232%'
when 'AiBB' Then '%0347%' end
try this one
SELECT ....
FROM...
WHERE ....
AND
(
((:input1 = 'ABB') AND code_branch.branch_code1 like '%0232%') OR
((:input1 = 'AiBB') AND code_branch.branch_code1 like '%0347%')
)