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 - sql

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

Related

Error in SQL statement: ParseException: mismatched input 'FROM' expecting from Databricks SQL

I am trying to update the columns based on other table data but receiving the below error
Trying to execute in Databricks
Error in SQL statement: ParseException:
mismatched input 'FROM' expecting {<EOF>, ';'}(line 8, pos 0)
== SQL ==
UPDATE
rd
SET
rd.transaction_date = olc.transaction_date,
rd.store_number = olc.store_number,
rd.terminal_number = olc.terminal_id,
rd.sequence_number = olc.transaction_number
FROM delta.`/reservation_detail_olc` rd
^^^
UPDATE
rd
SET
rd.transaction_date = olc.transaction_date,
rd.store_number = olc.store_number,
rd.terminal_number = olc.terminal_id,
rd.sequence_number = olc.transaction_number
FROM delta.`reservation_detai` rd
inner JOIN
delta.`order_line` olc
ON rd1.confirmation_number =olc.res_confirmation_number
WHERE rd.confirmation_number =olc.res_confirmation_number
The syntax used in Databricks SQL guide for update command does not have FROM clauses. They do not support it.

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.

Error after executing a cursor (oracle 11g - divisor is equal to zero)

After executing my cursor i got this error message: divisor is equal to zero
SELECT oel.org_id,
oeh.header_id,
oel.line_id,
oeh.order_number,
sum(mr.reservation_quantity) quantity,
oel.order_quantity_uom uom_code,
oel.unit_selling_price,
(oel.tax_value/oel.ordered_quantity) unit_tax_value,
(nvl(sum(mr.reservation_quantity),0) - oel.ordered_quantity)
FROM oe_order_lines_all oel
, oe_order_headers_all oeh
, oe_order_sources oos
, ra_terms_b rt
, ra_terms_b_dfv rt_dfv
, mtl_reservations mr
, mtl_system_items_b msi
WHERE 1 = 1
and oeh.org_id = 378
and mr.organization_id = msi.organization_id
and mr.inventory_item_id = msi.inventory_item_id
and mr.demand_source_line_id = oel.line_id
and rt.rowid = rt_dfv.rowid
and oel.payment_term_id = rt.term_id
and oeh.org_id = oel.org_id
and oel.header_id = oeh.header_id
and oeh.flow_status_code = 'BOOKED'
and oos.order_source_id = oeh.order_source_id
and oos.name = 'Portal'
If i delete this statement: and oeh.flow_status_code = 'BOOKED' it does not show the error message but i need to have that condition
Have you got any idea? Why is this happening?
EDIT: i have edited my query
There's only one division being performed in this operation and the divisor is oel.ordered_quantity, so it appears that at least one row in oe_order_lines_all has an ordered_quantity of zero.
You can change the line which reads
(oel.tax_value/oel.ordered_quantity) unit_tax_value,
to
(oel.tax_value/NULLIF(oel.ordered_quantity, 0)) unit_tax_value,
Alternatively, you can add
and oel.ordered_quantity <> 0
to the end of the WHERE clause.
Either way, it won't give you the divide-by-zero error any more, but there may be other issues which I can't predict.

How to run procedure without parameter in Teradata

How to run procedure without parameter in Teradata
I'm trying with : call db1.proc_dbOSA()
Error Msg:
Call failed 3707: PROC_DBOSA: Syntax error, expected something
like a name or a Unicode delimited identifier between ‘(‘ and ‘)’
New Procedure with error result.
When i run only code then everything works ok.
REPLACE PROCEDURE db1.proc_dbOSA()
BEGIN
DELETE FROM db1.LOG_dbOSA;
INSERT INTO
db1.LOG_dbOSA
(StoreNo, IDX, Flow, Status, MRP, OSA_IDX, OSA_AC)
WITH a AS (
SELECT
c.StoreCode,
CAST(SUBSTRING(c.ArticleCode FROM 13 FOR 6) AS INT) AS IDX,
RpType,
CASE
WHEN c.MinimumTargetStockWrpl >= l.MinimumTargetStockWrpl THEN CAST(l.MinimumTargetStockWrpl AS INT)
WHEN c.MinimumTargetStockWrpl < l.MinimumTargetStockWrpl THEN CAST(c.MinimumTargetStockWrpl AS INT)
End AS StoreMin,
c.ValUnrestrictedStock
FROM
db1.tab1 c
INNER JOIN
(
SELECT
StoreCode,
ArticleCode,
MinimumTargetStockWrpl
FROM
db1.tab1
WHERE
ProcessingDate = CURRENT_DATE - 14
) l ON c.StoreCode = l.StoreCode AND c.ArticleCode = l.ArticleCode
WHERE
c.ProcessingDate = CURRENT_DATE AND c.MinimumTargetStockWrpl IS NOT NULL AND l.MinimumTargetStockWrpl IS NOT NULL AND l.MinimumTargetStockWrpl > 0
)
, t AS
(
SELECT
CAST(SUBSTRING(ArticleCode FROM 13 FOR 6) AS INT) AS IDX,
RpType,
ArticlesPlanner
FROM
DWH_db_V.STK_B_ARTICLE_DAY_V
WHERE
ProcessingDate = CURRENT_DATE AND StoreCode = 'DR04'
)
SELECT
a.StoreCode,
a.IDX,
t.RpType,
t.ArticlesPlanner,
a.RpType,
CASE
WHEN a.ValUnrestrictedStock > 0 THEN 1
WHEN a.ValUnrestrictedStock <= 0 THEN 0
End AS OSA_IDX,
CASE
WHEN a.ValUnrestrictedStock >= StoreMin THEN 1
WHEN a.ValUnrestrictedStock < StoreMin THEN 0
End AS OSA_AC
FROM
a
LEFT JOIN
t ON t.IDX = a.IDX;
End;
BTEQ Error:
+---------+---------+---------+---------+---------+---------+---------+----
Call proc_dbOSA;
Call proc_dbOSA;
$
* Failure 3707 Syntax error, expected something like '(' between the word
'proc_dbOSA' and ';'.
Statement# 1, Info =18
* Total elapsed time was 1 second.
Call proc_dbOSA();
* Failure 3707 PROC_DBOSA:Syntax error, expected something like a name or
a Unicode delimited identifier between '(' and ')'.
* Total elapsed time was 1 second.
Stored procedures do not support the following:
EXPLAIN and USING request modifiers within a stored procedure
EXECUTE macro statement
WITH clause within a stored procedure.
Stored procedures, as well as macros, do not support the following query logging statements:
BEGIN QUERY LOGGING
END QUERY LOGGING
FLUSH QUERY LOGGING
REPLACE QUERY LOGGING

Msg 8115, Level 16, State 2, Line 1: Arithmetic overflow error converting %ls to data type %ls

I'm running this query on SQL Server 2005 and getting error. Could not found the root cause of this issue.
Please help to solve this issue. Is this issue Version specific and coming only with SQL Server 2005 not with 2008?
SELECT "AAA1_before_Final13"."AAA1" AS "level0key",
"AAA1_before_Final13"."Reporting_Month_Year" AS "levelkey",
"AAA1_before_Final13"."Reporting_Period" AS "Reporting_Period",
"Charge_Type14"."U_INV_CHG_TYPE" AS "level1key",
MIN(1) AS "rowCount",
SUM("AAA1_before_Final13"."Lag_Days") AS "Lag_Days",
SUM("AAA1_before_Final13"."Invoice_Count") AS "Invoice_Count"
FROM
(SELECT "AAA111"."Division_Name" AS "Division_Name",
"AAA111"."Original_FSC" AS "Original_FSC",
"AAA111"."FSC_Class" AS "FSC_Class",
"AAA111"."FSC_Name" AS "FSC_Name",
"AAA111"."Billing_Area_Category" AS "Billing_Area_Category",
"AAA111"."Billing_Area" AS "Billing_Area",
"dateDim12"."Reporting_Period" AS "Reporting_Period",
"dateDim12"."Reporting_Month_Year" AS "Reporting_Month_Year",
"AAA111"."AAA1" AS "AAA1",
"AAA111"."Lower_Range" AS "Lower_Range",
"AAA111"."Upper_Range" AS "Upper_Range",
SUM("AAA111"."Lag_Days") AS "Lag_Days",
SUM("AAA111"."Inv_Count") AS "Invoice_Count",
"AAA111"."GRP" AS "GRP"
FROM
(SELECT "idxAnalyzer"."dbo"."Date_Dim"."Reporting_Period" AS "Reporting_Period",
"idxAnalyzer"."dbo"."Date_Dim"."Reporting_Month_Year" AS "Reporting_Month_Year",
"idxAnalyzer"."dbo"."Date_Dim"."Reporting_Year" AS "Reporting_Year",
"idxAnalyzer"."dbo"."Date_Dim"."Deposite_Days" AS "Deposite_Day",
"idxAnalyzer"."dbo"."Date_Dim"."Deposite_Days" AS "Deposite_Day1",
"idxAnalyzer"."dbo"."Date_Dim"."Deposite_Days" AS "Deposite_Day_Grp"
FROM "idxAnalyzer"."dbo"."Date_Dim"
WHERE "idxAnalyzer"."dbo"."Date_Dim"."Reporting_Year" = 2013
AND "Date_Dim"."Day_of_Month" = 1
) "dateDim12"
LEFT OUTER JOIN
(SELECT "AAA1_Lag_Days"."Reporting_Period" AS "Reporting_Period",
"AAA1_Lag_Days"."Division_Name" AS "Division_Name",
"AAA1_Lag_Days"."FSC_Class" AS "FSC_Class",
"AAA1_Lag_Days"."Original_FSC" AS "Original_FSC",
"AAA1_Lag_Days"."FSC_Name" AS "FSC_Name",
"AAA1_Lag_Days"."Billing_Area_Category" AS "Billing_Area_Category",
"AAA1_Lag_Days"."Billing_Area" AS "Billing_Area",
SUM("AAA1_Lag_Days"."Lag_Days") AS "Lag_Days",
SUM("AAA1_Lag_Days"."Inv_Count") AS "Inv_Count",
"AAA1_Lag_Days"."Lower_Range" AS "Lower_Range",
"AAA1_Lag_Days"."Upper_Range" AS "Upper_Range",
'AAA1' AS "AAA1",
"AAA1_Lag_Days"."GRP" AS "GRP"
FROM
(SELECT "AAA1_Lag_Days"."Reporting_Period" AS "Reporting_Period",
"AAA1_Lag_Days"."Division_Name" AS "Division_Name",
"AAA1_Lag_Days"."Original_FSC" AS "Original_FSC",
"AAA1_Lag_Days"."FSC_Class" AS "FSC_Class",
"AAA1_Lag_Days"."FSC_Name" AS "FSC_Name",
"AAA1_Lag_Days"."Billing_Area" AS "Billing_Area",
"AAA1_Lag_Days"."Billing_Area_Category" AS "Billing_Area_Category",
"AAA1_Lag_Days"."Reporting_Period_Year" AS "Reporting_Period_Year",
"AAA1_Lag_Days"."Lag_Days" AS "Lag_Days",
"AAA1_Lag_Days"."Inv_Count" AS "Inv_Count",
"AAA1_Lag_Days"."Lower_Range" AS "Lower_Range",
"AAA1_Lag_Days"."Upper_Range" AS "Upper_Range",
"AAA1_Lag_Days"."Group_Num" AS "GRP"
FROM "idxAnalyzer"."dbo"."AAA1_Lag_Days_View" "AAA1_Lag_Days"
) "AAA1_Lag_Days"
WHERE (4 = 0
OR 4 = "AAA1_Lag_Days"."GRP")
AND "AAA1_Lag_Days"."Reporting_Period_Year" = 2013
AND "AAA1_Lag_Days"."Lower_Range" = 16.49
GROUP BY "AAA1_Lag_Days"."Reporting_Period",
"AAA1_Lag_Days"."Division_Name",
"AAA1_Lag_Days"."FSC_Class",
"AAA1_Lag_Days"."Original_FSC",
"AAA1_Lag_Days"."FSC_Name",
"AAA1_Lag_Days"."Billing_Area_Category",
"AAA1_Lag_Days"."Billing_Area",
"AAA1_Lag_Days"."Lower_Range",
"AAA1_Lag_Days"."Upper_Range",
"AAA1_Lag_Days"."GRP"
) "AAA111"
ON "dateDim12"."Reporting_Period" = "AAA111"."Reporting_Period"
GROUP BY "AAA111"."Division_Name",
"AAA111"."Original_FSC",
"AAA111"."FSC_Class",
"AAA111"."FSC_Name",
"AAA111"."Billing_Area_Category",
"AAA111"."Billing_Area",
"dateDim12"."Reporting_Period",
"dateDim12"."Reporting_Month_Year",
"AAA111"."AAA1",
"AAA111"."Lower_Range",
"AAA111"."Upper_Range",
"AAA111"."GRP"
) "AAA1_before_Final13",
"idxAnalyzer"."dbo"."U_INVOICE_HEADER" "Charge_Type14"
WHERE CAST ("AAA1_before_Final13"."GRP" AS BIGINT) = CAST ("Charge_Type14"."GRP" AS BIGINT)
GROUP BY "AAA1_before_Final13"."AAA1",
"AAA1_before_Final13"."Reporting_Month_Year",
"AAA1_before_Final13"."Reporting_Period",
"Charge_Type14"."U_INV_CHG_TYPE"