I am trying to execute the below script
CREATE VIEW JOES.WEBSKULOOKUPVIEW (
STYLEID ,
STYLENAME ,
DISPLAYSTYLENUMBER ,
B2BSTYLE ,
WEBPRODDESCR ,
WEBSTYLENAME ,
WEBSKUNUMBER ,
SUPPLIERNAME ,
SKUID ,
SKUNUMBER ,
SKUACTIVESTATUS ,
B2BSKU ,
SKUSIZE ,
SKUCOLOUR ,
WPSTYLEID )
AS
SELECT DISTINCT ESTYLE.STYLEID, ESTYLE.STYLENAME, ESTYLE.DISPLAYSTYLENBR, ESTYLE.B2BSTYLE, WPROD.H1SJXT, WPSTYLE.H2AMNA,
WPSKU.H3DINB, SUPP.SUPPLIERNAME, ESKU.SKUID, ESKU.SKUNUMBER, ESKU.SKUACTIVESTATUS, ESKU.B2BSKU,
(COALESCE(TRIM(FIRSTSIZE.SHORTSCALEVALUE) , '') || COALESCE(TRIM(', ' || SECSIZE.SHORTSCALEVALUE), '')) AS "SIZE",
STYLEACTUALCOLOUR.SPECIFICCOLOURNAME , STYLE.STYLEID
FROM ENTERPRISE.STYLE ESTYLE, ENTERPRISE.SUPPLIER SUPP, MWWDATA.DGH1CPP WPROD,
MWWDATA.DGH2CPP WPSTYLE, MWWDATA.DGH3CPP WPSKU, ENTERPRISE.STOCKKEEPINGUNIT ESKU, ENTERPRISE.STYLEACTUALCOLOUR STYLEACTUALCOLOUR,
ENTERPRISE.STYLE STYLE, ENTERPRISE.STYLEACTSTATUS STYLEACTSTATUS, ENTERPRISE.STYLEACTSTATUS SKUACTSTATUS, ENTERPRISE.SKUSIZE SKUSIZE
LEFT OUTER JOIN ENTERPRISE.SIZESCALEVALUE FIRSTSIZE ON FIRSTSIZESCALEID = FIRSTSIZE.SIZESCALEID AND FIRSTSIZESCALEOBJI = FIRSTSIZE.SIZESCALEOBJID
LEFT OUTER JOIN ENTERPRISE.SIZESCALEVALUE SECSIZE ON SECSIZESCALEID = SECSIZE.SIZESCALEID AND SECSIZESCALEOBJID = SECSIZE.SIZESCALEOBJID
WHERE ESTYLE.DEFAULTSUPPLIERID = SUPP.SUPPLIERID AND
SUPP.VENDORENTITYCODE = WPSTYLE.H2RWCO AND
ESTYLE.STYLEUSERCODE = WPSTYLE.H2AICD AND
WPSTYLE.H2SCNS = WPROD.H1SCNS AND
WPROD.H1SCNS = WPSTYLE.H2SCNS AND
WPSTYLE.H2SCNS = WPSKU.H3SCNS AND
WPSTYLE.H2RWCO = WPSKU.H3RWCO AND
WPSTYLE.H2AICD = WPSKU.H3AICD AND
WPSKU.H3DINB = CAST (ESKU.SKUNUMBER AS DECIMAL) AND
STYLE.STYLEID = ESKU.STYLEID AND
ESKU.STYLEID = STYLEACTUALCOLOUR.STYLEID AND
ESKU.ACTUALCOLOUROBJID = STYLEACTUALCOLOUR.ACTUALCOLOUROBJID AND
STYLE.STYLEACTIVESTATUS = STYLEACTSTATUS.STYLEACTIVESTATUS AND
ESKU.SKUACTIVESTATUS = SKUACTSTATUS.STYLEACTIVESTATUS AND
ESKU.SKUID = SKUSIZE.SKUID AND SKUACTIVESTATUS NOT IN ('P', 'D') ;
And it throws the error as mentioned below.
(COALESCE(TRIM(FIRSTSIZE.SHORTSCALEVALUE) , '') || COALESCE(TRIM(', ' || SECSIZE.SHORTSCALEVALUE), '')) AS "SIZE",
*
ERROR at line 20:
ORA-12704: character set mismatch
But that is the syntax for coalesce and trim.
So what possible changes should I make to solve this issue.
Related
Error Message:- ORA-01407: cannot update ("PSOWNER"."PS_VCHR_LINE_STG"."CLASS_FLD") to NULL Failed SQL stmt: UPDATE
When I am generating the report it is saying NO Success in Peoplesoft.
Below is the code for the Update statement.
Please help me how to overcome this problem.
UPDATE %Table(VCHR_LINE_STG) A
SET A.CLASS_FLD = (
SELECT SUBSTR(DCP_FLD49
,3
,4)
FROM %Table(DCP_AP11_TMP2)
WHERE VCHR_BLD_KEY_C1 = A.VCHR_BLD_KEY_C1
AND DCP_FLD34= A.VOUCHER_LINE_NUM),A.BUSINESS_UNIT =(
SELECT D.CF_ATTRIB_VALUE
FROM %Table(CF_ATTRIB_TBL) D
, %Table(DEPT_TBL) E
WHERE ( D.EFFDT = (
SELECT MAX(D_ED.EFFDT)
FROM %Table(CF_ATTRIB_TBL) D_ED
WHERE D.SETID = D_ED.SETID
AND D.CHARTFIELD_VALUE = D_ED.CHARTFIELD_VALUE
AND D_ED.EFFDT <= SYSDATE)
AND E.EFFDT=D.EFFDT
AND D.CHARTFIELD_VALUE = (
SELECT M.DCP_FLD41
FROM %Table(DCP_AP11_TMP2) M
WHERE M.VCHR_BLD_KEY_C1 = A.VCHR_BLD_KEY_C1
AND M.DCP_FLD34= A.VOUCHER_LINE_NUM)
AND D.SETID = E.SETID
AND D.SETID = 'DCPID'
AND D.CF_ATTRIBUTE='AP_BUSN_UNIT'
AND E.EFFDT = (
SELECT MAX(E_ED.EFFDT)
FROM %Table(DEPT_TBL) E_ED
WHERE E.SETID = E_ED.SETID
AND E.DEPTID = E_ED.DEPTID
AND E_ED.EFFDT <= SYSDATE)
AND E.DEPTID = D.CHARTFIELD_VALUE
AND E.SETID = D.SETID
AND E.EFF_STATUS='A')),A.BUSINESS_UNIT_GL=(
SELECT D.CF_ATTRIB_VALUE
FROM %Table(CF_ATTRIB_TBL) D
, %Table(DEPT_TBL) E
WHERE ( D.EFFDT = (
SELECT MAX(D_ED.EFFDT)
FROM %Table(CF_ATTRIB_TBL) D_ED
WHERE D.SETID = D_ED.SETID
AND D.CHARTFIELD_VALUE = D_ED.CHARTFIELD_VALUE
AND D_ED.EFFDT <= SYSDATE)
AND E.EFFDT=D.EFFDT
AND D.CHARTFIELD_VALUE = (
SELECT M.DCP_FLD41
FROM %Table(DCP_AP11_TMP2) M
WHERE M.VCHR_BLD_KEY_C1 = A.VCHR_BLD_KEY_C1
AND M.DCP_FLD34= A.VOUCHER_LINE_NUM)
AND D.SETID = E.SETID
AND D.SETID = 'DCPID'
AND D.CF_ATTRIBUTE='GL_BUSN_UNIT'
AND E.EFFDT = (
SELECT MAX(E_ED.EFFDT)
FROM %Table(DEPT_TBL) E_ED
WHERE E.SETID = E_ED.SETID
AND E.DEPTID = E_ED.DEPTID
AND E_ED.EFFDT <= SYSDATE)
AND E.DEPTID = D.CHARTFIELD_VALUE
AND E.SETID = D.SETID
AND E.EFF_STATUS='A'))
WHERE EXISTS (
SELECT 'X'
FROM %Table(DCP_AP11_TMP2)
WHERE VCHR_BLD_KEY_C1 = A.VCHR_BLD_KEY_C1
AND VOUCHER_LINE_NUM = A.VOUCHER_LINE_NUM)
Above is the code for the Update statement in App engine.
Please help me how to overcome this problem.
Thanks in Advance.
The sub-selects populating each field are not returning values so the database is trying to update the field to NULL. In PeopleSoft null values are not allowed in character fields. A field with no value needs to be set to a single space, like ' '.
You will need to wrap each sub-select with a COALESCE() function, with a non-null alternative option if the sub-select does not return a value. Character fields need to be set to ' ', numbers to 0 if no values returned. Date fields can be null. Here is an example using the first few lines of the code provided.
UPDATE %Table(VCHR_LINE_STG) A
SET A.CLASS_FLD =
COALESCE(
(SELECT SUBSTR(DCP_FLD49,3,4)
FROM %Table(DCP_AP11_TMP2)
WHERE VCHR_BLD_KEY_C1 = A.VCHR_BLD_KEY_C1
AND DCP_FLD34= A.VOUCHER_LINE_NUM), ' ')
, A.BUSINESS_UNIT_GL=(SELECT
...
I have used the below query to calculate the onhand quantity from InventTrans table but that onhand does not match with the AvailPhysical and/or PhysicalInvent of InventSum table. I have tried matching with other quantities as well but onhand is not matching. Please guide me what am i missing here
SELECT T1.ITEMID AS ITEMID
,T1.QTY
,T1.INVENTDIMID AS INVENTDIMID
,DATEDIFF(dd, T3.TRANSDATE, getdate()) AS Age
,t19.price as RetailPrice
,t1.CurrencyCode AS CurrencyKey
,T1.DATAAREAID AS DATAAREAID
,T1.PARTITION AS PARTITION
FROM INVENTTRANS T1
LEFT JOIN INVENTTRANSORIGIN T2 ON (
T1.INVENTTRANSORIGIN = T2.RECID
AND (T1.DATAAREAID = T2.DATAAREAID)
AND (T1.PARTITION = T2.PARTITION)
)
INNER JOIN INVENTTRANSPOSTING T3 ON (
(
(
(
T1.VOUCHERPHYSICAL = T3.VOUCHER
AND (T1.DATAAREAID = T3.DATAAREAID)
AND (T1.PARTITION = T3.PARTITION)
)
)
AND (
T1.DATEPHYSICAL = T3.TRANSDATE
AND (T1.DATAAREAID = T3.DATAAREAID)
AND (T1.PARTITION = T3.PARTITION)
)
)
AND (
T1.INVENTTRANSORIGIN = T3.INVENTTRANSORIGIN
AND (T2.DATAAREAID = T3.DATAAREAID)
AND (T2.PARTITION = T3.PARTITION)
)
) and t3.INVENTTRANSPOSTINGTYPE in (0)
LEFT JOIN INVENTDIM t4 ON (
t4.inventdimid = t1.inventdimid
AND t4.PARTITION = t1.PARTITION
AND t4.dataareaid = t1.dataareaid
)
LEFT OUTER JOIN INVENTTABLEMODULE T19 ON T19.ItemID = T1.ItemID AND T19.DataAreaID = T1.DataAreaID and T19.Partition = T1.Partition AND T19.MODULETYPE=0
LEFT OUTER JOIN INVENTTABLE T20 ON T1.ITEMID = T20.ITEMID AND T1.DATAAREAID = T20.DATAAREAID
where T20.ITEMTYPE <> 2
Any help would be greatly appreciated.
I have stuck in this issue from the last two days.
Please help.
I want to assign the following query .
$qr = "( select subconfigcode.field_subconfigcode_value AS configcode FROM node node LEFT JOIN field_data_field_select_parent_configuratio select_parent_configuratio ON node.nid = select_parent_configuratio.entity_id AND (select_parent_configuratio.entity_type = node AND select_parent_configuratio.deleted = 0) LEFT JOIN node select_parent_configuratio_node ON select_parent_configuratio.field_select_parent_configuratio_nid = select_parent_configuratio_node.nid LEFT JOIN field_data_field_subconfigcode subconfigcode ON select_parent_configuratio_node.nid = subconfigcode.entity_id AND (subconfigcode.entity_type = 'node' AND subconfigcode.deleted = '0') WHERE (( (select_parent_configuratio.field_select_parent_configuratio_nid = node_field_data_field_select_parent_configuratio.nid) )AND(( (node.status = '1') AND (node.type IN ('offering')) ))) ORDER BY node.created DESC, configcode ASC LIMIT 1 OFFSET 0)";
to
one view's field value.
I have used the following code.
function general_views_query_alter(&$view, &$query) {
$qr = " ( select subconfigcode.field_subconfigcode_value AS configcode FROM node node LEFT JOIN field_data_field_select_parent_configuratio select_parent_configuratio ON node.nid = select_parent_configuratio.entity_id AND (select_parent_configuratio.entity_type = node AND select_parent_configuratio.deleted = 0) LEFT JOIN node select_parent_configuratio_node ON select_parent_configuratio.field_select_parent_configuratio_nid = select_parent_configuratio_node.nid LEFT JOIN field_data_field_subconfigcode subconfigcode ON select_parent_configuratio_node.nid = subconfigcode.entity_id AND (subconfigcode.entity_type = 'node' AND subconfigcode.deleted = '0') WHERE (( (select_parent_configuratio.field_select_parent_configuratio_nid = node_field_data_field_select_parent_configuratio.nid) )AND(( (node.status = '1') AND (node.type IN ('offering')) ))) ORDER BY node.created DESC, configcode ASC LIMIT 1 OFFSET 0)";
$query->add_where(1, "node_field_data_field_select_parent_configuratio__field_data_field_subconfigcode.field_subconfigcode_value", $qr);
}
But, it is returning the following where query.
where node_field_data_field_select_parent_configuratio__field_data_field_subconfigcode.field_subconfigcode_value = '( select subconfigcode.field_subconfigcode_value AS configcode FROM node node LEFT JOIN field_data_field_select_parent_configuratio select_parent_configuratio ON node.nid = select_parent_configuratio.entity_id AND (select_parent_configuratio.entity_type = node AND select_parent_configuratio.deleted = 0) LEFT JOIN node select_parent_configuratio_node ON select_parent_configuratio.field_select_parent_configuratio_nid = select_parent_configuratio_node.nid LEFT JOIN field_data_field_subconfigcode subconfigcode ON select_parent_configuratio_node.nid = subconfigcode.entity_id AND (subconfigcode.entity_type = \'node\' AND subconfigcode.deleted = \'0\') WHERE (( (select_parent_configuratio.field_select_parent_configuratio_nid = node_field_data_field_select_parent_configuratio.nid) )AND(( (node.status = \'1\') AND (node.type IN (\'offering\')) ))) ORDER BY node.created DESC, configcode ASC LIMIT 1 OFFSET 0) ')
I want to get query without the single quote assigned for sub query and remove extra slashed added to each value.
Please help.
Answer :
Direct query is not applicable for assignment purpose in the add_where condition.
For that, I have generated the query object using.
function general_views_query_alter(&$view, &$query) {
$subQuery = db_select('node', 'node'); $subQuery->leftJoin('field_data_field_select_parent_configuratio', 'select_parent_configuratio ', 'node.nid = select_parent_configuratio .entity_id');
$subQuery->condition('select_parent_configuratio.entity_type', 'node', '=');
$subQuery->condition('select_parent_configuratio.deleted', '0', '=');
$subQuery->leftJoin('node', 'select_parent_configuratio_node', 'select_parent_configuratio.field_select_parent_configuratio_nid = select_parent_configuratio_node.nid');
$subQuery->leftJoin('field_data_field_subconfigcode', 'subconfigcode', 'select_parent_configuratio_node.nid = subconfigcode.entity_id');
$subQuery->condition('subconfigcode.entity_type', 'node', '=');
$subQuery->condition('subconfigcode.deleted', '0', '=');
$subQuery->where("select_parent_configuratio.field_select_parent_configuratio_nid = node_field_data_field_select_parent_configuratio.nid");
$subQuery->condition('node.status', "1", '=');
$subQuery->condition('node.type', array('offering'), 'IN');
$subQuery->orderBy('configcode');
$subQuery->addField('subconfigcode', 'field_subconfigcode_value', 'configcode');
//$subQuery->range(0, 1);
$query->add_where($group,'node_field_data_field_select_parent_configuratio__field_data_field_subconfigcode.field_subconfigcode_value',$subQuery,'in');
}
Using this, I am able to generate it the query and assignment to value of the variable.
SubQuery pulling in the same record in the "ON_ORDER" column. I want the query to pull in the ON_ORDER qty per Item. Can someone please show me what I am not doing right? I have been on this for quite awhile.
SELECT
N.SITEID,
C.LOCATION,
(I.EX2AREARESP||I.EX2STDSTS||I.EX2APPTYPE) AS STD,
I.ITEMNUM,
I.COMMODITY,
I.COMMODITYGROUP,
I.DESCRIPTION,
I.ISSUEUNIT,
C.AVGCOST,
SUM(NVL(B.CURBAL,0)) AS CURBAL,
NVL(SUM(D.SHIPPEDQTY),0) AS IN_TRANSIT,
(
SELECT
SUM(PL.ORDERQTY - NVL(PL.RECEIVEDQTY,0))
FROM MSCRADS.PO P,
MSCRADS.POLINE PL,
MXRADS.ITEM I
WHERE P.PONUM = PL.PONUM
AND PL.LINETYPE = 'ITEM'
AND P.RECEIPTS <> 'COMPLETE'
AND PL.ITEMNUM = I.ITEMNUM
AND P.ORDERDATE >= TO_DATE('2014/05/26','YYYY/MM/DD')
AND PL.RECEIPTSCOMPLETE = '0'
AND P.INTERNAL = '0'
AND PL.ISSUE = '0'
AND P.STATUS NOT IN ('COMPLETE','CLOSE','CAN')
AND P.SITEID <> 'MS'
AND P.REVISIONNUM = PL.REVISIONNUM
AND (P.HISTORYFLAG = '0' OR (P.HISTORYFLAG = '1'
AND P.STATUS = 'CLOSE' AND PL.RECEIVEDQTY > '0'))
AND NOT (P.STATUS = 'COMPLETE'
AND (PL.RECEIVEDQTY = '0' OR PL.RECEIVEDQTY IS NULL))
) AS "ON_ORDER",
NVL(SUM(CASE WHEN D.RESTYPE = 'APSOFT' THEN D.RESERVEDQTY
ELSE NULL END),0) AS "ALLOCATED",
NVL(SUM(CASE WHEN D.RESTYPE = 'APHARD' THEN D.RESERVEDQTY
ELSE NULL END),0) AS "RESERVE",
N.MINLEVEL AS ROP,
N.ORDERQTY AS EOQ,
N.DELIVERYTIME AS LEADTIME,
NVL(N.SSTOCK,0) "SAFETY STOCK",
CASE N.REORDER WHEN 1 THEN 'AUTO_RE-ORDER'
WHEN 0 THEN 'MANUAL_RE-ORDER'
ELSE ' '
END AS "REORDER PROCESS",
N.STATUS "INVENTORY STATUS"
FROM MXRADS.INVENTORY N
LEFT OUTER JOIN
MXRADS.ITEM I
ON I.ITEMNUM = N.ITEMNUM
LEFT OUTER JOIN
MSCRADS.INVCOST C
ON N.ITEMNUM = C.ITEMNUM
AND N.LOCATION = C.LOCATION
LEFT OUTER JOIN
MSCRADS.INVBALANCES B
ON N.ITEMNUM = B.ITEMNUM
AND N.LOCATION = B.LOCATION
LEFT OUTER JOIN
MSCRADS.INVRESERVE D
ON N.ITEMNUM = D.ITEMNUM
AND N.LOCATION = D.LOCATION
WHERE N.SITEID <> 'MS'
AND N.LOCATION = '&WHSE'
AND N.STATUS = 'ACTIVE'
--AND N.ITEMNUM = '505611'
GROUP BY
N.SITEID,
C.LOCATION,
(I.EX2AREARESP||I.EX2STDSTS||I.EX2APPTYPE),
I.ITEMNUM,
I.COMMODITY,
I.COMMODITYGROUP,
I.DESCRIPTION,
I.ISSUEUNIT,
C.AVGCOST,
N.MINLEVEL,
N.ORDERQTY,
N.DELIVERYTIME,
N.SSTOCK,
N.REORDER,
N.STATUS
ORDER BY 4
I'm struggling to update the table data in the following code for GUI. It works to add each new request to the previous, so that it doesn't fit the screen, while I need to replace old request with the new one. Thanks! A.
require ( gWidgets )
options ( guiToolkit="RGtk2" )
window <- gwindow ( "Pilot>>" , visible = FALSE, horizontal = FALSE )
paned <- gpanedgroup ( cont = window )
group <- ggroup ( cont = paned, horizontal = FALSE )
glabel ( "FPC:" , cont = group )
entry <- gedit ( "" , cont = group )
entry [ ] <- actfpc$CURFPC ##list of codes for auto-filling
search_button <- gbutton ( "Go!" , cont = group )
addSpring ( group )
frame <- gframe ( "Supply:" , cont = paned , horizontal = FALSE,use.scrollwindow=TRUE )
addHandlerChanged ( search_button , handler = function ( h , ... ) {
##Data subset for entered value
a<-skulist[skulist$FPC==svalue(entry),]
a<-a[c("X_id","FPC","STATUS","COMMENT","DCTR","DCSTOCK")]
tbl <- gtable ( a , cont = frame, expand=TRUE )
} )
size ( frame) <- c ( 950 , 250)
visible ( window ) <- TRUE