Hi there I'm using MaxDB and trying to update a table and I get the error Missing keyword:WITH. Code: -5015.
Here is my SQL:
UPDATE agm
SET agm_confirm_stat = 'C',
agm_confirm_usr = 'MEDICWARE',
agm_confirm_obs = 'Wellon: Confirmado',
agm_obs = NVL(agm_obs, '') || '\/\/Wellon: Confirmar',
agm_confirm_dthr = TIMESTAMP
WHERE (agm_pac = '319900')
AND (
agm_obs NOT LIKE '%Wellon: Confirmar%'
OR agm_obs IS NULL
)
AND (agm_str_cod = 'FBC')
AND (agm_hini = '2022-12-07 08:00:00')
AND (agm_confirm_stat != 'C')
AND (agm_stat = 'A')
The code below is my Bollinger bands strategy for commodity. I add a position limit and want to optimize this strategy through parameter maxpos. For the function add.distribution, it asks for a component.label, but the function addPosLimit does not have a variable called "label". I wonder how to optimize maxpos at this case.
symbol <- 'C1'
currency("USD")
#stock(symbol, currency="USD", multiplier=1)
portfName <- 'RSI_Strategy'
acctName <- portfName
suppressWarnings(rm.strat(stratName))
initPortf(name = portfName, symbols = symbol, initDate = initDate,
currency = 'USD')
initAcct(name = acctName, portfolios = portfName,
initDate=initDate, initEq=initEq)
initOrders(portfolio = portfName, initDate = initDate)
stratName <- portfName
strategy(name = stratName, store=TRUE)
SD = 2
N = 20
add.indicator(strategy = stratName, name = "BBands",
arguments = list(HLC = quote(HLC(mktdata)), maType='SMA',
n=N, sd=SD),
label='BBands')
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("Close","up"),relationship="gt"),
label="Cl.gt.UpperBand")
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("Close","dn"),relationship="lt"),
label="Cl.lt.LowerBand")
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("High","mavg"),relationship="gt"),
label="Hi.Cross.Mid")
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("Low","mavg"),relationship="lt"),
label="Lo.Cross.Mid")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Cl.gt.UpperBand",sigval=TRUE, orderqty=-nShs,
ordertype='market', orderside=NULL, osFUN=osMaxPos
),type='enter',
label = "Enter.Short")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Cl.lt.LowerBand",sigval=TRUE, orderqty=nShs,
ordertype='market', orderside=NULL, osFUN=osMaxPos
),type='enter',
label = "Enter.Long")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Hi.Cross.Mid",sigval=TRUE, orderqty= 'all',
ordertype='market', orderside=NULL),type='exit',
label = "Exit.All")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Lo.Cross.Mid",sigval=TRUE, orderqty= 'all',
ordertype='market', orderside=NULL),type='exit',
label = "Exit.All")
addPosLimit(portfName, symbol, timestamp=initDate, maxpos=maxpos, minpos=0)
.maxpos = seq(3000,8000,1000)
add.distribution(stratName,
paramset.label = 'PosOpt',
component.type = 'order',
component.label = 'addPosLimit',
variable = list(maxpos = .maxpos),
label = 'MaxPos')
Is it better that I just use the where for update query with conditions or there is a better way to do?
Below is a sample of my SQL query which I wanted to update if the Order_ID = 10 plus payment_check is N or response_msg is null, kindly correct me if my query is wrong.
UPDATE dbo.sample1
SET Payment_Generated = 'Y',
Transaction_ID = '123',
Response_Msg = 'ok',
Response_Code = '1',
Created_on = '2020-05-29T11:29:30'
WHERE Order_ID = '10' and Payment_Check = 'N' or Response_Code IS NULL
Expected Result if the payment_check is N or response_code is null
Payment_Generated = 'Y',
Transaction_ID = '123',
Response_Msg = 'ok',
Response_Code = '1',
Created_on = '2020-05-29T11:29:30'
Order_ID = '10'
Payment_Check = 'N'
I know this question has been asked multiple times before, but I've seen every discussion about this here but none could help me to solve my problem.
So my problem is I got this error. From what I understand is this error was caused by column could not determine from which table it would pull the data, hence we can solve it by giving the column name variable such as s.sampleid as ssampleid. Right?
Here are my codes
select * from(select S.S_SAMPLEID,s.collectiondt,SDI.PARAMLISTID||'|'||SDI.PARAMID as paramlistparam,s.u_samcondition,SDI.enteredtext,sdi.displayunits As Unit, sd.s_datasetstatus
case when SDIS.condition = 'Pass' then 'Pass'
when SDIS.condition = 'Fail' then 'Fail'
when SDIS.condition = 'Warning' then 'Warning'
when SDIS.waivedflag = 'Y' then 'Waived'
else 'No Spec' end as quality
from s_sample s left join sdidata sd on s.s_sampleid=sd.keyid1 AND SD.SDCID = 'Sample'
LEFT JOIN SDIDATAITEM SDI ON sd.keyid1 = SDI.KEYID1 AND SDI.SDCID = 'Sample' AND SD.PARAMLISTVERSIONID = SDI.PARAMLISTVERSIONID AND SD.VARIANTID = SDI.VARIANTID AND SD.DATASET = SDI.DATASET AND SD.PARAMLISTID = SDI.PARAMLISTID
LEFT JOIN SDIDATAITEMSPEC SDIS ON SDI.KEYID1 = SDIS.KEYID1 AND SDI.PARAMLISTVERSIONID = SDIS.PARAMLISTVERSIONID AND SDI.VARIANTID = SDIS.VARIANTID AND SDI.DATASET = SDIS.DATASET AND SDI.PARAMLISTID = SDIS.PARAMLISTID AND SDI.PARAMID = SDIS.PARAMID AND SDI.PARAMTYPE = SDIS.PARAMTYPE AND SDIS.SDCID = 'Sample'
where s.samplepointid='"+samplepoint+"' and sdi.paramlistid in ('"+paramlistid+"') and sdi.paramid in ('"+paramid+"') and s.collectiondt between '"+startdt+"' and '"+enddt+"' and sd.s_datasetstatus in ('"+statussql+"') and SDIS.condition in ('"+qualitysql+"'))
pivot(max(enteredtext) as result, max(Unit) as unit for paramlistparam in ('"+paramlistpa+"')) order by collectiondt
And here are what I did by giving variables to the column
select * from(select s.S_SAMPLEID as ssampleid,s.collectiondt,SDI.PARAMLISTID||'|'||SDI.PARAMID as paramlistparam,s.u_samcondition as scondition,SDI.enteredtext as sdienteredtext,SDI.displayunits As Unit, sd.s_datasetstatus as sddataset
case when SDIS.condition = 'Pass' then 'Pass'
when SDIS.condition = 'Fail' then 'Fail'
when SDIS.condition = 'Warning' then 'Warning'
when SDIS.waivedflag = 'Y' then 'Waived'
else 'No Spec' end as quality
from s_sample s left join sdidata sd on s.s_sampleid=sd.keyid1 AND SD.SDCID = 'Sample'
LEFT JOIN SDIDATAITEM SDI ON sd.keyid1 = SDI.KEYID1 AND SDI.SDCID = 'Sample' AND SD.PARAMLISTVERSIONID = SDI.PARAMLISTVERSIONID AND SD.VARIANTID = SDI.VARIANTID AND SD.DATASET = SDI.DATASET AND SD.PARAMLISTID = SDI.PARAMLISTID
LEFT JOIN SDIDATAITEMSPEC SDIS ON SDI.KEYID1 = SDIS.KEYID1 AND SDI.PARAMLISTVERSIONID = SDIS.PARAMLISTVERSIONID AND SDI.VARIANTID = SDIS.VARIANTID AND SDI.DATASET = SDIS.DATASET AND SDI.PARAMLISTID = SDIS.PARAMLISTID AND SDI.PARAMID = SDIS.PARAMID AND SDI.PARAMTYPE = SDIS.PARAMTYPE AND SDIS.SDCID = 'Sample'
where s.samplepointid='"+samplepoint+"' and sdi.paramlistid in ('"+paramlistid+"') and sdi.paramid in ('"+paramid+"') and s.collectiondt between '"+startdt+"' and '"+enddt+"' and sd.s_datasetstatus in ('"+statussql+"') and SDIS.condition in ('"+qualitysql+"')
or s.samplepointid='"+samplepoint+"' and sdi.paramlistid in ('"+paramlistid+"') and sdi.paramid in ('"+paramid+"') and s.collectiondt between '"+startdt+"' and '"+enddt+"' and sd.s_datasetstatus in ('"+statussql+"') and SDIS.condition is null)
pivot(max(sdienteredtext) as result, max(Unit) as unit for paramlistparam in ('"+paramlistpa+"')) order by collectiondt
From what I test, the error was caused by paramlistpa
I have a query which is used in an OBIEE report which erroring out for "ora-32044 while executing recursive WITH query". Tried running in SQL and it is erroring out in there as well. Can anyone take a look at the query and suggest how it can be run without the WITH clause. I have seen examples but without any level, for a case where WITH has been used in the middle of the query, how can it be rewritten without WITH clause so no ora-32044 occurs
`SELECT 1 dummy, oh.order_number, ol.line_number, ol.shipment_number,
oh.ordered_date, ot.NAME order_type, items.concatenated_segments item,
items.description item_description
,bom.assembly_item
,bom.component_item
,bom.implementation_date
,bom.disable_date as date_disabled
,bom.component_item_description
,ol.flow_status_code line_status
,ol.ordered_quantity,
ol.shipped_quantity,
ol.unit_selling_price,
ol.fulfilled_quantity,
ol.invoiced_quantity,
ol.cancelled_quantity,
ol.schedule_ship_date,
ol.promise_date,
ol.actual_shipment_date,
ol.request_date,
cust_acct.account_number customer_number,
party.party_name customer,
ct.trx_number invoice_number,
ctl.line_number inv_line_number,
ctl.extended_amount,
ct.trx_date invoice_date,
ct.creation_date invoice_creation_date,
wnd.NAME delivery_number,
wdd.released_status,
hp2.party_name endcustomer,
oh.attribute6 business_unit,
TO_CHAR (ol.actual_shipment_date, 'MM/YY') shipped_month,
TO_CHAR (ol.actual_shipment_date, '"Q"Q YY') shipped_qtr,
TO_CHAR (ol.actual_shipment_date, 'YYYY') shipped_year,
mc.segment1 product_group, mc.segment2 product_subgroup,
items.attribute7 drive_capacity,
items.attribute10 drive_form,
items.attribute8 drive_speed,
items.attribute6 drive_type,
items.attribute12 AgileParttype,
items.organization_id,
case when dis.arithmetic_operator = 'NEWPRICE' then operand
when dis.arithmetic_operator = '%'
then (ol.unit_selling_price* ol.ordered_quantity)*dis.operand/100.0
else NVL((NVL (ol.pricing_quantity, 0) * NVL (dis.adjusted_amount, 0)),0) end
discount_amount
FROM apps.oe_order_headers_all oh,
apps.oe_order_lines_all ol,
apps.wsh_new_deliveries wnd,
apps.wsh_delivery_assignments wda,
apps.wsh_delivery_details wdd,
apps.ra_customer_trx_all ct,
apps.ra_customer_trx_lines_all ctl,
apps.oe_transaction_types_tl ot,
(SELECT *
FROM apps.mtl_system_items_vl
WHERE organization_id = 84
) items,
apps.hz_parties party,
apps.hz_cust_accounts cust_acct,
apps.hz_parties hp2,
apps.hz_cust_accounts hca2,
apps.mtl_item_categories mic,
(SELECT *
FROM apps.mtl_category_sets
WHERE category_set_name = 'Inventory') ms,
apps.mtl_categories mc,
(select a.header_id, a.line_id ,a.list_header_id,a.creation_date,
a.arithmetic_operator,a.unit_selling_price,a.operand,
a.ordered_quantity, a.adjusted_amount
from
(select oh.header_id,
ol.line_id,pl.list_header_id,pl.creation_date,opa.arithmetic_operator,
ol.unit_selling_price,opa.operand,
ol.ordered_quantity, opa.adjusted_amount
from apps.oe_price_adjustments opa,
apps.oe_order_lines_all ol,
apps.oe_order_headers_all oh,
apps.qp_list_headers_vl pl
where oh.header_id = opa.header_id
and ol.line_id = opa.line_id
and opa.list_header_id = pl.list_header_id
and opa.applied_flag = 'Y'
AND opa.list_line_type_code = 'DIS') a,
(select oh.header_id, ol.line_id,max(pl.creation_date) creation_date, min(operand)
operand
from apps.oe_price_adjustments opa,
apps.oe_order_lines_all ol,
apps.oe_order_headers_all oh,
apps.qp_list_headers_vl pl
where oh.header_id = opa.header_id
and ol.line_id = opa.line_id
and opa.list_header_id = pl.list_header_id
and opa.applied_flag = 'Y'
AND opa.list_line_type_code = 'DIS'
group by oh.header_id, ol.line_id) b
where
a.header_id = b.header_id
and a.line_id = b.line_id
and a.creation_date = b.creation_date
and a.operand = b.operand ) dis
,(
WITH recursiveBOM (parent_item_id,parent_item,parent_org_id,assembly_item_id,
assembly_item,assembly_org_id,
component_item_id,component_item, component_item_description,implementation_date,
disable_date) AS
(
SELECT item.inventory_item_id parent_item_id
,item.segment1 parent_item
,item.organization_id parent_org_id
,bom.assembly_item_id
,msi.segment1 assembly_item
,bom.organization_id assembly_org_id
,bic.component_item_id
,msi2.segment1 component_item
,msi2.description component_item_description
,bic.implementation_date
,bic.disable_date
FROM apps.mtl_system_items_b item, apps.bom_bill_of_materials_v bom,
apps.bom_inventory_components_v bic, apps.mtl_system_items msi,
apps.mtl_system_items msi2
WHERE 1=1
AND bom.assembly_item_id = item.inventory_item_id
AND bom.organization_id = item.organization_id
AND bic.bill_sequence_id = bom.common_bill_sequence_id
AND msi.inventory_item_id = bom.assembly_item_id
AND msi.organization_id = bom.organization_id
AND msi2.inventory_item_id = bic.component_item_id
AND msi2.organization_id = msi.organization_id
AND bic.implementation_date IS NOT NULL
AND item.organization_id = 84
AND item.inventory_item_id > 0
UNION ALL
SELECT parent.parent_item_id
,parent.parent_item
,parent.parent_org_id
,bom.assembly_item_id
,msi.segment1 assembly_item
,bom.organization_id assembly_org_id
,bic.component_item_id
,msi2.segment1 component_item
,msi2.description component_item_description
,bic.implementation_date
,bic.disable_date
FROM recursiveBOM parent, apps.bom_bill_of_materials_v bom,
apps.bom_inventory_components_v bic, apps.mtl_system_items msi,
apps.mtl_system_items msi2
WHERE 1=1
AND bic.bill_sequence_id = bom.common_bill_sequence_id
AND msi.inventory_item_id = bom.assembly_item_id
AND msi.organization_id = bom.organization_id
AND msi2.inventory_item_id = bic.component_item_id
AND msi2.organization_id = msi.organization_id
AND bic.implementation_date IS NOT NULL
AND bom.assembly_item_id = parent.component_item_id
AND bom.organization_id = parent.assembly_org_id
AND bom.organization_id = 84
AND parent.assembly_org_id = 84
)
SELECT DISTINCT parent_item_id,parent_item,parent_org_id
,assembly_item_id
,assembly_item
,assembly_org_id
,component_item_id
,component_item
,component_item_description
,implementation_date
,disable_date
FROM recursiveBOM
) bom
WHERE oh.header_id = ol.header_id
AND ol.line_id = wdd.source_line_id
AND wdd.source_code = 'OE'
AND wda.delivery_detail_id = wdd.delivery_detail_id
AND wda.delivery_id = wnd.delivery_id
AND ol.line_id = ctl.interface_line_attribute6(+)
AND ctl.customer_trx_id = ct.customer_trx_id(+)
AND oh.order_type_id = ot.transaction_type_id
AND ol.inventory_item_id = items.inventory_item_id
AND ol.sold_to_org_id = cust_acct.cust_account_id
AND cust_acct.party_id = party.party_id
AND oh.end_customer_id = hca2.cust_account_id(+)
AND hca2.party_id = hp2.party_id(+)
AND items.inventory_item_id = mic.inventory_item_id(+)
AND items.organization_id = mic.organization_id(+)
AND mic.category_id = mc.category_id(+)
AND mic.category_set_id = ms.category_set_id(+)
and ol.line_id = dis.line_id(+)
and ol.header_id = dis.header_id(+)
AND bom.parent_item_id (+) = items.inventory_item_id
AND bom.parent_org_id (+) = items.organization_id `