Merge Sql - Doubt
Hi All,
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
can we use MERGE SQL like this
CREATE OR REPLACE PROCEDURE SAVE_PCS_SUMMARY(vENTRYDATE IN VARCHAR2, vCELLID IN VARCHAR2, vMACHINEID IN VARCHAR2, vFREQUENCY IN CHAR)
IS
l_sqlstr varchar2(32000);
BEGIN
l_sqlstr := PCS_PC_SUMMARY.GETSQLFORPLDAY_TIME(vENTRYDATE, vCELLID, vMACHINEID, vFREQUENCY); -- RETUEN SQL STATEMENT
MERGE INTO PCS_TL_MONTH_COMP P
USING ( SELECT * FROM l_sqlstr) S -- HERE I HAVE PROBLEM
ON (P.COMPANYID = S.FACT_COMPANYID AND P.ENTRYDATE = S.PRLM_ENTRYDATE)
WHEN NOT MATCHED THEN
INSERT VALUES(l_sqlstr); - HERE I HAVE PROBLEM
END;
My problem is i cannot use the stores sql string in USING clause and to INSERT values.
or is any other way there?
Sorry for not giving full details,
I try to explain.
Requirement is Generate Summary Data
Source tables are PCS_TL_MST, PCS_TL_DTL
Target table is PCS_TL_MONTH_COMP
Specification is to select data from the source tables to target tables whenever source tables are getting affected
Why I have used dynamic sql is that the select query will have lot of calculations that will be another query
Whole things are in a package
CREATE OR REPLACE PACKAGE BODY RRLVASPRD_APR13.PCS_PC_SUMMARY
IS
PROCEDURE SAVE_PCS_SUMMARY(vENTRYDATE IN VARCHAR2, vCELLID IN VARCHAR2, vMACHINEID IN VARCHAR2, vFREQUENCY IN CHAR)
IS
l_sqlstr varchar2(32000);
BEGIN
l_sqlstr := GETSQLFORPLDAY_TIME(vENTRYDATE, vCELLID, vMACHINEID, vFREQUENCY);
MERGE INTO PCS_TL_MONTH_COMP P
USING ( l_sqlstr) S
ON (P.COMPANYID = S.FACT_COMPANYID AND P.ENTRYDATE = S.PRLM_ENTRYDATE)
WHEN NOT MATCHED THEN
INSERT VALUES(l_sqlstr);
WHEN MATCHED THEN
DELETE WHERE PRLM_ENTRYDATE = vENTRYDATE AND MACHINEID = vMACHINEID
INSERT INTO PCS_TL_MONTH_COMP SELECT * FROM || l_sqlstr;
END;
FUNCTION GetSubSqlForIns RETURN VARCHAR2
IS
vSQLSTR VARCHAR2(30000);
CURSUBLOSS SYS_REFCURSOR;
PLCMKEY PCS_TL_LOGCONFIGURATION.PLCM_KEYID%TYPE;
PARAMNAME PCS_TL_LOGCONFIGURATION.PLCM_PARAMETERNAME%TYPE;
PARAMCODE PCS_TL_LOGCONFIGURATION.PLCM_PARAMETERCODE%TYPE;
ISLOSS PCS_TL_LOGCONFIGURATION.PLCM_ISLOSS%TYPE;
MAPFIELD PCS_TL_LOGCONFIGURATION.PLCM_MAPFIELD%TYPE;
MAPCOLUMNNO PCS_TL_LOGCONFIGURATION.PLCM_MAPCOLUMNNO%TYPE;
N NUMBER;
BEGIN
vSQLSTR := ', SUM(QAACCEPTEDQTY) AS QAACCEPTEDQTY, (' || PCS_PC_PRODUCTIONCALC.CELLEFF || ') AS CELLEFF
, SUM(' || PCS_PC_PRODUCTIONCALC.GetExpectedProductionVAS(NULL,NULL,'N','N') || ') AS THEORITICALPRODUCTION
, SUM(' || PCS_PC_PRODUCTIONCALC.GetOperatingTime(NULL,NULL,'N', 'N') || ') AS NETOPERATINGTIME
, SUM(DECODE(NVL(STARTUPLOSS_ML,0),0,0,1)) AS STARTUPLOSS_ML_INS
, SUM(DECODE(NVL(MINORSTOPPAGELOSS_ML,0),0,0,1)) AS MINORSTOPPAGELOSS_ML_INS
, SUM(DECODE(NVL(SPEEDLOSS_ML,0),0,0,1)) AS SPEEDLOSS_ML_INS
, SUM(DECODE(NVL(OPERATINGMOTIONLOSS_ML,0),0,0,1)) AS OPERATINGMOTIONLOSS_ML_INS
, SUM(DECODE(NVL(LINEORGANISATIONLOSS_ML,0),0,0,1)) AS LINEORGANISATIONLOSS_ML_INS
, SUM(DECODE(NVL(LOGISTICSLOSS_ML,0),0,0,1)) AS LOGISTICSLOSS_ML_INS
, SUM(DECODE(NVL(MEASURINGANDADJLOSS_ML,0),0,0,1)) AS MEASURINGANDADJLOSS_ML_INS
, SUM(DECODE(NVL(ENERGYLOSS_ML,0),0,0,1)) AS ENERGYLOSS_ML_INS
, SUM(DECODE(NVL(DIETOOLANDJIGLOSS_ML,0),0,0,1)) AS DIETOOLANDJIGLOSS_ML_INS
, SUM(DECODE(NVL(YIELDLOSS_ML,0),0,0,1)) AS YIELDLOSS_ML_INS
, SUM(DECODE(NVL(DEFECTSANDREWORKLOSS_ML,0),0,0,1)) AS DEFECTSANDREWORKLOSS_ML_INS ';
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(EQUIPMENTFAILURE_ML,0) ,0,0,1)) AS EQUIPMENTFAILURE_ML_INS ';
N:=PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL(CURSUBLOSS, 'EF');
LOOP
FETCH CURSUBLOSS INTO PLCMKEY,PARAMNAME,PARAMCODE,ISLOSS,MAPFIELD,MAPCOLUMNNO;
EXIT WHEN CURSUBLOSS%NOTFOUND;
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(' || MAPFIELD || ' ,0),0,0,1)) AS ' || PARAMCODE || '_INS';
END LOOP;
N:=PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL(CURSUBLOSS, 'SETUPANDADJ');
LOOP
FETCH CURSUBLOSS INTO PLCMKEY,PARAMNAME,PARAMCODE,ISLOSS,MAPFIELD,MAPCOLUMNNO;
EXIT WHEN CURSUBLOSS%NOTFOUND;
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(' || MAPFIELD || ' ,0),0,0,1)) AS ' || PARAMCODE || '_INS';
END LOOP;
N:=PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL(CURSUBLOSS, 'TOOLCHANGELOSS');
LOOP
FETCH CURSUBLOSS INTO PLCMKEY,PARAMNAME,PARAMCODE,ISLOSS,MAPFIELD,MAPCOLUMNNO;
EXIT WHEN CURSUBLOSS%NOTFOUND;
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(' || MAPFIELD || ' ,0),0,0,1)) AS ' || PARAMCODE || '_INS';
END LOOP;
N:=PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL(CURSUBLOSS, 'SHUTDOWNLOSS');
LOOP
FETCH CURSUBLOSS INTO PLCMKEY,PARAMNAME,PARAMCODE,ISLOSS,MAPFIELD,MAPCOLUMNNO;
EXIT WHEN CURSUBLOSS%NOTFOUND;
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(' || MAPFIELD || ' ,0),0,0,1)) AS ' || PARAMCODE || '_INS';
END LOOP;
N:=PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL(CURSUBLOSS, 'MANAGEMENTLOSS');
LOOP
FETCH CURSUBLOSS INTO PLCMKEY,PARAMNAME,PARAMCODE,ISLOSS,MAPFIELD,MAPCOLUMNNO;
EXIT WHEN CURSUBLOSS%NOTFOUND;
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(' || MAPFIELD || ' ,0),0,0,1)) AS ' || PARAMCODE || '_INS';
END LOOP;
vSQLSTR := vSQLSTR || ',SUM(DECODE(NVL(COMMONUTILITYLOSS_SL,0),0,0,1)) AS COMMONUTILITYLOSS_SL_INS ';
vSQLSTR := vSQLSTR || ',SUM(DECODE(NVL(DEFECTTIME_SL,0),0,0,1)) AS DEFECTTIME_SL_INS ';
vSQLSTR := vSQLSTR || ',SUM(NVL(' || PCS_PC_PRODUCTIONCALC.GetMapFieldForLoss('PM','N') || ',0)) AS PLANNEDMAINTENANCE ';
--+NVL(' || PCS_PC_PRODUCTIONCALC.GetMapFieldForLoss('BBM','N') || ',0)
vSQLSTR := vSQLSTR || ', SUM(NVL(' || PCS_PC_PRODUCTIONCALC.GetMapFieldForLoss('UPM','N') || ',0) ) AS ANCILLARYEQPFAIL ';
-- + NVL(' || PCS_PC_PRODUCTIONCALC.GetMapFieldForLoss('ANCEQUFAIL','N') || ',0)
vSQLSTR := vSQLSTR || ', SUM(NVL(REJECTEDQTY,0) + NVL(REWORKQTY,0)) AS DEFECTSANDREWORKLOSS_ML ';
vSQLSTR := vSQLSTR || ', SUM(NVL(' || PCS_PC_PRODUCTIONCALC.GetMapFieldForLoss('QAREJECTION','N') || ',0)) AS QAREJECTION ';
RETURN vSQLSTR;
End;
FUNCTION GetMainSql(vCELLID IN VARCHAR2, vMACHINEID IN VARCHAR2, vforcalc IN BOOLEAN DEFAULT FALSE, vFREQUENCY IN CHAR, vRECURSION IN NUMBER DEFAULT 1) RETURN VARCHAR2
IS
vSQLSTR VARCHAR2(30000);
BEGIN
vSQLSTR := ' SELECT ' ;
IF vFREQUENCY = 'M' THEN
IF vRECURSION = 1 THEN
vSQLSTR := vSQLSTR || ' SELECT TO_CHAR(PRLM_ENTRYDATE,''MON-YYYY'') PRLM_ENTRYDATE';
ELSE
vSQLSTR := vSQLSTR || ' SELECT ''01-'' || PRLM_ENTRYDATE ';
END IF;
ELSE
vSQLSTR := vSQLSTR || ' SELECT PRLM_ENTRYDATE';
END IF;
vSQLSTR := vSQLSTR || ',FACT_COMPANYID, PRLM_FACTORYID, PRLM_SECTIONID, CELLID ';
IF TRIM(vMACHINEID) <> '-99' AND TRIM(vMACHINEID) <> '{}' AND TRIM(vMACHINEID) IS NOT NULL THEN
vSQLSTR := vSQLSTR || ', MACHINEID ';
End If;
vSQLSTR := vSQLSTR || ', 0 AS PRODANDREJCTION,
SUM(NVL(CALENDARTIME,0)) AS CALENDARTIME,
SUM(NVL(NOPLANINMINS,0)) AS NOPLANINMINS,
SUM(NVL(PRODUCEDQTY,0)) AS PRODUCEDQTY,
SUM(NVL(MCHAVAILABLETIME,0)) AS MCHAVAILABLETIME,
SUM(NVL(UNACCOUNTEDTIME,0)) AS UNACCOUNTEDTIME,
SUM(NVL(DEFECTTIME_SL,0)) AS DEFECTTIME_SL,
SUM(NVL(PRODUCTIONLOSSES,0)) AS PRODUCTIONLOSSES,
SUM(NVL(EQUIPMENTFAILURE_ML,0)) AS EQUIPMENTFAILURE_ML,
SUM(NVL(SETUPANDADJUSTMENT_ML,0)) AS SETUPANDADJUSTMENT_ML,
SUM(NVL(TOOLCHANGELOSS_ML,0)) AS TOOLCHANGELOSS_ML,
SUM(NVL(STARTUPLOSS_ML,0)) AS STARTUPLOSS_ML,
SUM(NVL(MINORSTOPPAGELOSS_ML,0)) AS MINORSTOPPAGELOSS_ML,
SUM(NVL(SPEEDLOSS_ML,0)) AS SPEEDLOSS_ML,
SUM(NVL(SHUTDOWNLOSS_ML,0)) AS SHUTDOWNLOSS_ML,
SUM(NVL(MANAGEMENTLOSS_ML,0)) AS MANAGEMENTLOSS_ML,
SUM(NVL(COMMONUTILITYLOSS_SL,0)) AS COMMONUTILITYLOSS_SL,
SUM(NVL(OPERATINGMOTIONLOSS_ML,0)) AS OPERATINGMOTIONLOSS_ML,
SUM(NVL(LINEORGANISATIONLOSS_ML,0)) AS LINEORGANISATIONLOSS_ML,
SUM(NVL(LOGISTICSLOSS_ML,0)) AS LOGISTICSLOSS_ML,
SUM(NVL(MEASURINGANDADJLOSS_ML,0)) AS MEASURINGANDADJLOSS_ML,
SUM(NVL(ENERGYLOSS_ML,0)) AS ENERGYLOSS_ML,
SUM(NVL(DIETOOLANDJIGLOSS_ML,0)) AS DIETOOLANDJIGLOSS_ML,
SUM(NVL(YIELDLOSS_ML,0)) AS YIELDLOSS_ML,
SUM(NVL(LOADINGTIME,0)) AS LOADINGTIME,
SUM(NVL(PRODUCTIONAVLTIME,0)) AS PRODUCTIONAVLTIME,
SUM(NVL(EFFECTIVEPRODMINS,0)) AS EFFECTIVEPRODMINS ';
IF vforcalc = TRUE THEN
vSQLSTR := vSQLSTR || ',' || PCS_PC_PRODUCTIONCALC.GETROA(NULL,NULL, 'N') || ' AS ROA ';
vSQLSTR := vSQLSTR || ',' || PCS_PC_PRODUCTIONCALC.GETROP(NULL,NULL, 'N') || ' AS ROP ';
vSQLSTR := vSQLSTR || ',' || PCS_PC_PRODUCTIONCALC.GETROQ(NULL,NULL) || ' AS ROQ ';
vSQLSTR := vSQLSTR || ',' || PCS_PC_PRODUCTIONCALC.GETOEE(NULL,NULL, 'N') || ' AS OEE ';
ELSE
vSQLSTR := vSQLSTR || ', SUM(NVL(ROA,0)) AS ROA, SUM(NVL(ROP,0)) AS ROP,
SUM(NVL(ROQ,0)) AS ROQ, SUM(NVL(OEE,0)) AS OEE ';
END IF;
vSQLSTR := vSQLSTR || ', SUM(NVL(PLANNEDQTY,0)) AS PLANNEDQTY
, SUM(NVL(PRODUCEDQTY,0) + NVL(PRODUCTIONLOSSES,0)) AS SUMOFALLQTY ';
vSQLSTR := vSQLSTR || ' , SUM(NVL(THEORITICALCYCLETIME,0)) AS THEORITICALCYCLETIME ';
DBMS_OUTPUT.PUT_LINE('GETMAINSQLFORPLDAY');
GEN_PC_COMMONFUNCTIONS.GEN_FN_ADDDEBUGSQL(vSQLSTR,'PCS_PC_PRODUCTIONCALC', 'GETMAINSQLFORPLDAY');
RETURN vSQLSTR;
End;
FUNCTION GetSubSql RETURN VARCHAR2
IS
vSQLSTR VARCHAR2(30000);
vSUBLOSSCOL VARCHAR2(10000);
SubLossSql VARCHAR2(10000);
VALU NUMBER;
BEGIN
vSQLSTR := ',SUM(NVL(DEFECTSANDREWORKLOSS_ML,0)) AS DEFECTSANDREWORKLOSS_ML
, SUM(NVL(DEFECTSANDREWORKLOSS_ML_INS,0)) AS DEFECTSANDREWORKLOSS_ML_INS
, SUM(NVL(STARTUPLOSS_ML_INS,0)) AS STARTUPLOSS_ML_INS
, SUM(NVL(MINORSTOPPAGELOSS_ML_INS,0)) AS MINORSTOPPAGELOSS_ML_INS
, SUM(NVL(SPEEDLOSS_ML_INS,0)) AS SPEEDLOSS_ML_INS
, SUM(NVL(OPERATINGMOTIONLOSS_ML_INS,0)) AS OPERATINGMOTIONLOSS_ML_INS
, SUM(NVL(LINEORGANISATIONLOSS_ML_INS,0)) AS LINEORGANISATIONLOSS_ML_INS
, SUM(NVL(LOGISTICSLOSS_ML_INS,0)) AS LOGISTICSLOSS_ML_INS
, SUM(NVL(MEASURINGANDADJLOSS_ML_INS,0)) AS MEASURINGANDADJLOSS_ML_INS
, SUM(NVL(ENERGYLOSS_ML_INS,0)) AS ENERGYLOSS_ML_INS
, SUM(NVL(DIETOOLANDJIGLOSS_ML_INS,0)) AS DIETOOLANDJIGLOSS_ML_INS
, SUM(NVL(YIELDLOSS_ML_INS,0)) AS YIELDLOSS_ML_INS ';
SubLossSql := PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL1('EF');
If TRIM(SubLossSql) IS NOT NULL Then
vSQLSTR := vSQLSTR || ',' || SubLossSql || ' AS EQUIPMENTFAILURE_ML_INS ';
Else
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(EQUIPMENTFAILURE_ML,0),0,0,1)) AS EQUIPMENTFAILURE_ML_INS ';
End If;
SubLossSql := PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL1('SETUPANDADJ');
If TRIM(SubLossSql) IS NOT NULL Then
vSQLSTR := vSQLSTR || ',' || SubLossSql || ' AS SETUPANDADJUSTMENT_ML_INS ';
Else
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(SETUPANDADJUSTMENT_ML,0),0,0,1)) AS SETUPANDADJUSTMENT_ML_INS';
End If;
SubLossSql := PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL1('TOOLCHANGELOSS');
If TRIM(SubLossSql) IS NOT NULL Then
vSQLSTR := vSQLSTR || ',' || SubLossSql || ' AS TOOLCHANGELOSS_ML_INS ';
Else
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(TOOLCHANGELOSS_ML,0),0,0,1)) AS TOOLCHANGELOSS_ML_INS';
End If;
SubLossSql := PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL1('SHUTDOWNLOSS');
If TRIM(SubLossSql) IS NOT NULL Then
vSQLSTR := vSQLSTR || ',' || SubLossSql || ' AS SHUTDOWNLOSS_ML_INS ';
Else
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(SHUTDOWNLOSS_ML,0),0,0,1)) AS SHUTDOWNLOSS_ML_INS ';
End If;
SubLossSql := PCS_PC_PRODUCTIONCALC.PCS_FN_GETSUBLOSSSQL1('MANAGEMENTLOSS');
If TRIM(SubLossSql) IS NOT NULL Then
vSQLSTR := vSQLSTR || ',' || SubLossSql || ' AS MANAGEMENTLOSS_ML_INS ';
Else
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(MANAGEMENTLOSS_ML,0),0,0,1)) AS MANAGEMENTLOSS_ML_INS ';
End If;
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(COMMONUTILITYLOSS_SL,0),0,0,1)) AS COMMONUTILITYLOSS_SL_INS ';
vSQLSTR := vSQLSTR || ', SUM(DECODE(NVL(DEFECTTIME_SL,0),0,0,1)) AS DEFECTTIME_SL_INS ';
vSQLSTR := vSQLSTR || ', SUM(NVL(PLANNEDMAINTENANCE,0)) AS PLANNEDMAINTENANCE ';
vSQLSTR := vSQLSTR || ', SUM(NVL(ANCILLARYEQPFAIL,0)) AS ANCILLARYEQPFAIL ';
vSQLSTR := vSQLSTR || ', SUM(NVL(THEORITICALPRODUCTION,0)) AS THEORITICALPRODUCTION ';
vSQLSTR := vSQLSTR || ', SUM(NVL(NETOPERATINGTIME,0)) AS NETOPERATINGTIME ';
vSQLSTR := vSQLSTR || ', SUM(NVL(QAACCEPTEDQTY,0)) AS QAACCEPTEDQTY ';
vSQLSTR := vSQLSTR || ', SUM(NVL(CELLEFF,0)) AS CELLEFF ';
vSQLSTR := vSQLSTR || ', SUM(NVL(QAREJECTION,0)) AS QAREJECTION ';
GEN_PC_COMMONFUNCTIONS.GEN_FN_ADDDEBUGSQL(vSQLSTR,'PCS_PC_PRODUCTIONCALC', 'GETSUBSQLFORPLDAY');
RETURN vSQLSTR;
End;
FUNCTION GETSQLFORPLDAY_TIME(vENTRYDATE IN VARCHAR2, vCELLID IN VARCHAR2, vMACHINEID IN VARCHAR2, vFREQUENCY IN CHAR) RETURN VARCHAR2
IS
vSQLSTR VARCHAR2(30000);
vPLDTLTBL VARCHAR2(200);
vSECTIONID VARCHAR2(20);
N NUMBER;
BEGIN
IF TRIM(vMACHINEID) IS NOT NULL AND TRIM(vMACHINEID) <> '{}' THEN
SELECT CELL_SECTIONID INTO vSECTIONID FROM GEN_TL_MACHINEMST, GEN_TL_CELLMST WHERE MCHM_CELLID = CELL_KEYID AND MCHM_KEYID = vMACHINEID;
ELSIF TRIM(vCELLID) IS NOT NULL AND TRIM(vCELLID) <> '{}' THEN
SELECT CELL_SECTIONID INTO vSECTIONID FROM GEN_TL_CELLMST WHERE CELL_KEYID = vCELLID;
END IF;
IF TRIM(vSECTIONID) IS NOT NULL THEN
N:=PCS_FN_GETPLDETAILSTBL(vPLDTLTBL,vSECTIONID,'Y');
END IF;
vSQLSTR := GetMainSql(vCELLID, vMACHINEID,FALSE,vFREQUENCY);
vSQLSTR := vSQLSTR || GetSubSql;
vSQLSTR := vSQLSTR || ' FROM (';
vSQLSTR := vSQLSTR || GetMainSql(vCELLID, vMACHINEID,TRUE,vFREQUENCY);
vSQLSTR := vSQLSTR || GetSubSqlForIns;
vSQLSTR := vSQLSTR || ' FROM ' || vPLDTLTBL || ', PCS_TL_MST ';
vSQLSTR := vSQLSTR || ' GEN_TL_FACTORYMST ';
vSQLSTR := vSQLSTR || ' WHERE TRUNC(PRLM_ENTRYDATE) = ' || CHR(39) || vENTRYDATE || CHR(39) || '
AND PRLM_KEYID = PLMASTERID AND CELLID = ' || CHR(39) || vCELLID || CHR(39);
-- AND COMPLETEDFLAG = ''C''
vSQLSTR := vSQLSTR || ' PRLM_FACTORYID = FACT_KEYID ';
IF TRIM(vMACHINEID) <> '-99' AND TRIM(vMACHINEID) <> '{}' AND TRIM(vMACHINEID) IS NOT NULL THEN
vSQLSTR := vSQLSTR || ' AND MACHINEID = ' || CHR(39) || vMACHINEID || CHR(39);
End If;
--vSQLSTR := vSQLSTR || ' AND PRLM_LOGTYPE = ''H'' ';
vSQLSTR := vSQLSTR || ' GROUP BY ';
IF vFREQUENCY = 'M' THEN
vSQLSTR := vSQLSTR || ' TO_CHAR(PRLM_ENTRYDATE, ''MON-YYYY'')';
ELSE
vSQLSTR := vSQLSTR || ' PRLM_ENTRYDATE ';
END IF;
vSQLSTR := vSQLSTR || ' , FACT_COMPANYID, PRLM_FACTORYID, PRLM_SECTIONID, CELLID ';
If TRIM(vMACHINEID) <> '-99' AND TRIM(vMACHINEID) <> '{}' AND TRIM(vMACHINEID) IS NOT NULL THEN
vSQLSTR := vSQLSTR || ', MACHINEID ';
End If;
vSQLSTR := vSQLSTR || ')';
vSQLSTR := vSQLSTR || ' GROUP BY ';
IF vFREQUENCY = 'M' THEN
vSQLSTR := vSQLSTR || ' TO_CHAR(PRLM_ENTRYDATE, ''MON-YYYY'')';
ELSE
vSQLSTR := vSQLSTR || ' PRLM_ENTRYDATE ';
END IF;
vSQLSTR := vSQLSTR || ' , FACT_COMPANYID, PRLM_FACTORYID, PRLM_SECTIONID, CELLID ';
If TRIM(vMACHINEID) <> '-99' AND TRIM(vMACHINEID) <> '{}' AND TRIM(vMACHINEID) IS NOT NULL THEN
vSQLSTR := vSQLSTR || ', MACHINEID ';
End If;
GEN_PC_COMMONFUNCTIONS.GEN_FN_ADDDEBUGSQL(vSQLSTR,'PCS_PC_PRODUCTIONCALC', 'GETSQLFORPLDAY_TIME');
RETURN vSQLSTR;
End;
END PCS_PC_SUMMARY;
Similar Messages
-
Hi ABAP Gurus,
Please help me in solving following ABAP SQL doubt.
In the table Zonfig there are two fields: FNAME and REQFLAG
FNAME.....REQFLAG
S1...........X
S2...........X
S3..........._
S4...........X
Other table T_Zconfig has one field : XNAME
XNAME
S1
S3
Now I have to select REQFLAG from Zconfig table for the values of field XNAME in T_Zconfig table.
That is in this case for FNAME S1 and S2 in Zonfig I need to fetch REQFLAG since in XNAME in T_Zonfig we just have S1 and S2.
Points will be surly awarded...
Thanks.Hi ABAP Gurus,
Please help me in solving following ABAP SQL doubt.
In the table Zonfig there are two fields: FNAME and REQFLAG
FNAME.....REQFLAG
S1...........X
S2...........X
S3..........._
S4...........X
Other table T_Zconfig has one field : XNAME
XNAME
S1
S3
Now I have to select REQFLAG from Zconfig table for the values of field XNAME in T_Zconfig table.
That is in this case for FNAME S1 and S3 in Zonfig I need to fetch REQFLAG since in XNAME in T_Zonfig we just have S1 and S3.
Points will be surly awarded...
Thanks. -
Why below MERGE sql statement is throwing error on 10g?
Version: Ora 10g R2
Why below MERGE sql statement is throwing error on 10g?
SQL> merge into sess_stats
using
select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=:sid and (a.name like '%ga %' or a.name like '%direct temp%')
) curr_stats
on (sess_stats.name=curr_stats.name)
when matched then
update set diff=curr_stats.value-sess_stats.value, value=curr_stats.value
when not matched then
insert (name, value, diff) values (curr_stats.name, curr_stats.value, null) 2 3 4 5 6 7 8 SQL> SP2-0734: unknown command beginning "on (sess_s..." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "when match..." - rest of line ignored.
SQL> 2 3First of all, thank you all for your feedback!
first, I try remove the blank lines at those two places ( before curr_stats and after on) and it works.
then, again I try to set sqlblanklines on, and it works as well!
Edited by: PhoenixBai on Nov 10, 2009 10:54 PM -
Can I write merge SQL statement having count(*)?
Hi this is a followup question of my previous post. I tried to use a merge SQL statement to solve my problem but now I bump into another problem.
Now I have a table where the field I need to update is a partial PK
when using a merge SQL statement, I have to put a where clause that check if count(*) = 1 because of the PK constraint
Where can I put the count(*) = 1 clause?
Here are the details:
I have two tables TA and TB, where TA contains the fields ID, FULLNAME, TYPE and TB contains the fields ID, FIRSTNAME
I want to update the firstnames in TB to be the firstnames from TA where TB.ID = TA.ID and TA.TYPE = 'ABC'
{ID, FIRSTNAME} are PKs but for the same ID, there can be more than 1 firstname.
e.g.
TA
ID | FULLNAME | TYPE
1 Caroline T ABC
2 Mary C DEF
3 Peter J ABC
TB
ID | FIRSTNAME
1 Caroline
1 Carol
1 C,
3 Peter
I need to update TB with the new firstnames from TA where type is 'ABC' but only for those fields that have count(TB.ID) = 1
when I try to run this SQL statement
merge into TB B using TA A
on (A.ID = B.ID and A.TYPE = 'ABC')
when matched then update set B.FIRSTNAME = substr(A.FULLNAME, 1, instr(A.FULLNAME, ',') - 1)
I got this error SQL Error: ORA-00001: unique constraint (TEST.PK_TB) violated
which I believe is because I updated those fields say ID = 1, all with 'Caroline'
that means I will have to add a clause having count(TB.ID) = 1
How would you do it?
Server is Oracle 11g
Thank you!Hi,
One way is to join ta and tb in the USING clause, and eliminate the duplicates there.
MERGE INTO tb dst
USING (
SELECT ta.id
, REGEXP_SUBSTR ( MIN (ta.fullname)
, '^[^,]*'
) AS firstname
FROM ta
JOIN tb ON ta.id = tb.id
WHERE ta.type = 'ABC'
GROUP BY ta.id
HAVING COUNT (*) = 1
) src
ON (scr.id = dst.id)
WHEN MATCHED THEN UPDATE
SET dst.firstname = src.firstname
;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
I used REGEXP_SUBST instead of SUBSTR and INSTR to find the firstname, because I find it a little cleaner, and becuase it returns something even when there is no ',' in fullname, which I'm guessing is what you really want. (None of the fullnames in your sample data have ','s.) You could use SUBSTR and INSTR instead. -
Pl/sql doubts clarification
Hi,
I have doubts with some of the questions given below:
1.Identify two features of obfuscation. (Choose two.)
A. The Import and Export utilities accept wrapped files.
B. SQL' Plus cannot process the obfuscated source files.
C. Only the wrap utility can obfuscate multiple programs at a time.
D. Both the DBMS_DDL package and the Wrap utility can obfuscate multiple programs at a time.
E. The source code is visible only through the DBA_SOURCE view and not through the USER_SOURCE or
ALL_SOURCE View
ANSWER: A and C(not sure)
2.The anonymous block gives an error on execution. What Is the reason?
A.
The assignment in line 7 is not valid.
B.
The SQL does not support the Boolean data type.
C.
A null value cannot be applied to the bind arguments In the using clause in line 10
D.
The names of bind variables must be the same as the using clause bind arguments in line 10
Answer: A or B.
3.SCOTT executes the procedure as follows:
SQL>SET SERVEROUTPUT ON
SQL>EXEC read_file ('MY_DIR', FACULTYLIST.TXT')
What is the outcome?
A.
It goes into an infinite loop.
B.
It executes successfully and displays only the list of faculty names.
C.
It does not execute and displays an error message because the end-of-file condition is not taken care of.
D.
It executes successfully and displays the list of faculty names followed by a “no data found” error message.
Answer: D is right or not
4.Which two tasks should be created as functions instead of as procedures? (Choose two.)
A.
reference host or bind variables in a PL/SQL block of code
B.
tasks that compute and return multiple values to the calling environment
C.
tasks that compute a value that must be returned to the calling environment
D.
tasks performed in SQL that increase data independence by processing complex data analysis within the Oracle server, rather than by retrieving the data into an application
Answer: A and B(not sure B or C).
Please,kindly reply to me ASAP.
Thank you,
karthi
Edited by: 998492 on Apr 7, 2013 2:32 AM1. Thare are so many problems in this code. I will list a few.
1. You cant specify the size of an argument in a procedure.
2. You can call this procedure only once in a schema, coz the name of the table to be created is static.
3. *No need to create the table dynamically*. You can create the table at the design time and truncate/insert as required.
Even it will not be required, I hope, to meet your requirement( A Cursor will be enough).
4. In the EMP table join_date should be of date datatype. If it is already a date, no need of to_date in the procedure.
5. Not using BIND Variables.
6. Variable "v_cmd" is not declared2. Search for "string aggregation " in this forum and show us what you tried so far. -
Declare
cursor curname is select * from employees where employee_id in (100,101);
v_emp curname%rowtype;
begin
open curname;--this stage the query is executed and datas are available in Active set which is the area oracle allocated for this cursor
loop
fetch curname into v_emp;
exit when curname%notfound;--first value is retrieved in the above statement and the cursor is pointing to second value in the active set..so this wil result no
--bt for the next loop here cursor should nt point to anything and this should exit.. Am i ryt? becaz there are totally two values.. tis should exit witout printing..
-- i mean.. eventhough tis query gives two values second value should not be printed becaz we have given exit before before dbms_ouput statement.. ple help
--mainly I am getting confused about the functionalities of exit explain please.....
dbms_output.put_line('name:'||v_emp.first_name);
end loop;
close curname;
end;
tis is confusing somebody help please?? and gimme the link where can I find docs to clarify these doubts.. explain about for loop for the same please...
I am starter in PL/SQL please help.....
Edited by: user12869307 on Apr 19, 2010 2:43 PMHi,
Please don't post unformatted code.
Indent line to show the extent of BEGIN, LOOP and similar statements.
Don't put too much on one line.
For example:
Declare
cursor curname is select *
from employees
where employee_id in (100,101);
v_emp curname%rowtype;
begin
open curname; -- this stage the query is executed and
-- datas are available in Active set which is
-- the area oracle allocated for this cursor
loop
fetch curname into v_emp;
exit when curname%notfound; -- first value is retrieved in the above
-- statement and the cursor is pointing to
-- second value in the active set..so this wil result no
-- bt for the next loop here cursor should nt point to
-- anything and this should exit Am i ryt? becaz there
-- are totally two values.. tis should exit witout printing wiout
-- doing the below print..
dbms_output.put_line ('name:' || v_emp.first_name);
end loop;
close curname;
end;
/Type these 6 characters:
(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
I'm not sure I understand your comments. It would help if you posted the contents of your table, and the output you get, and asked a question specifically about those results, such as "Why do the results include ... ? Isn't the code supposed to ... because of ... in the data?"
If the query returns 2 rows, then FETCH will work 2 times with %FOUND = true. Only after the 3rd call to FETCH will %NOTFOUND become true. -
Hi All,
I am using Oracle 11g. I have SQL Query which has two select clause and comibined using union clause.
Execution of query takes more time to run
Pls share me your ideas to merge into single SQL
SELECT t1.REC_ST,
t1.VERSION_NO,
t1.ROW_TS,
t1.USER_ID,
t1.EFFECTIVE_DT,
t1.CREATE_DT,
t1.MIN_INT_AMT,
t1.ABSOLUTE_RATE,
t1.WAIVER_AMT,
t1.DRCR_IND,
t1.INDEX_RATE_ID,
t1.DEPOSIT_ACCT_INT_ID,
t1.DEPOSIT_ACCT_ID,
t1.OVR_FG,
t1.ACCRUAL_BAL_BASIS_TY,
t1.ACCRUAL_BASIS_TY,
t1.MARGIN_RATE,
t1.DEPOSIT_PROD_INT_ID,
t1.MIN_RATE,
t1.ACCRUAL_FREQ_VALUE,
t1.ACCRUAL_FREQ_CD,
t1.MAX_RATE,
t1.RATE_STRUCT_CD,
t1.INDEX_RATE,
t1.DEPOSIT_ACCT_INT_HIST_ID,
t1.MARGIN_TYPE_CD,
t1.MARGIN_BAL_BASIS_TY,
t1.INT_RATE_TY,
t2.INDEX_NM AS INDEX_RATE_NM,
NULL AS PROD_INT_HIST_ID
FROM DP_ACCT_INTEREST_HISTORY t1,
INDEX_RATE t2
WHERE t1.INDEX_RATE_ID = t2.INDEX_RATE_ID (+)
AND t1.OVR_FG = 'Y'
UNION
SELECT t1.REC_ST,
t1.VERSION_NO,
t1.ROW_TS,
t1.USER_ID,
t1.EFFECTIVE_DT,
t1.CREATE_DT,
t1.MIN_INT_AMT,
t1.ABSOLUTE_RATE,
t1.WAIVER_AMT,
t1.DRCR_IND,
t1.INDEX_RATE_ID,
t2.DEPOSIT_ACCT_INT_ID,
t2.DEPOSIT_ACCT_ID,
t2.OVR_FG,
t1.ACCRUAL_BAL_BASIS_TY,
t1.ACCRUAL_BASIS_TY,
t1.MARGIN_RATE,
t2.DEPOSIT_PROD_INT_ID,
t1.MIN_RATE,
t1.ACCRUAL_FREQ_VALUE,
t1.ACCRUAL_FREQ_CD,
t1.MAX_RATE,
t1.RATE_STRUCT_CD,
t1.INDEX_RATE,
t1.PROD_INT_HIST_ID AS DEPOSIT_ACCT_INT_HIST_ID,
t1.MARGIN_TYPE_CD,
t1.MARGIN_BAL_BASIS_TY,
t1.INT_RATE_TY,
t3.INDEX_NM AS INDEX_RATE_NM,
t1.PROD_INT_HIST_ID
FROM PRODUCT_INTEREST_HISTORY t1,
DEPOSIT_ACCOUNT_INTEREST t2,
INDEX_RATE t3
WHERE t1.PROD_INT_ID = t2.DEPOSIT_PROD_INT_ID
AND t2.OVR_FG = 'N'
AND t1.INDEX_RATE_ID = t3.INDEX_RATE_ID (+)Thanks & Regards
SamiHi All,
Sorry i have missed out..
Explain Plan
Plan
SELECT STATEMENT ALL_ROWSCost: 56,570 Bytes: 191,285,367 Cardinality: 1,188,177
12 SORT UNIQUE Cost: 56,570 Bytes: 191,285,367 Cardinality: 1,188,177
11 UNION-ALL
3 HASH JOIN RIGHT OUTER Cost: 14,252 Bytes: 190,997,842 Cardinality: 1,186,322
1 TABLE ACCESS FULL TABLE BENCHMARK.INDEX_RATE Cost: 3 Bytes: 588 Cardinality: 28
2 TABLE ACCESS FULL TABLE BENCHMARK.DP_ACCT_INTEREST_HISTORY Cost: 14,243 Bytes: 166,085,080 Cardinality: 1,186,322
10 HASH JOIN Cost: 135 Bytes: 287,525 Cardinality: 1,855
6 TABLE ACCESS BY INDEX ROWID TABLE BENCHMARK.DEPOSIT_ACCOUNT_INTEREST Cost: 126 Bytes: 10,800 Cardinality: 540
5 BITMAP CONVERSION TO ROWIDS
4 BITMAP INDEX SINGLE VALUE INDEX (BITMAP) BENCHMARK.DEP_ACCT_INT_OVR_FG_IDX
9 HASH JOIN RIGHT OUTER Cost: 9 Bytes: 60,750 Cardinality: 450
7 TABLE ACCESS FULL TABLE BENCHMARK.INDEX_RATE Cost: 3 Bytes: 588 Cardinality: 28
8 TABLE ACCESS FULL TABLE BENCHMARK.PRODUCT_INTEREST_HISTORY Cost: 5 Bytes: 51,300 Cardinality: 450 thanks & Regards
Sami -
Hi everybody,
I am new to Acrobat development and need some direction. I'd like to merge in data from a SQL Server DB into a PDF similar to how MS Word is able to merge data into documents. Then I would like to have that PDF sent to an email address that is also in the DB.
I have looked around and have seen references to ADBC in 8.0 (I am running 9.0 Pro), and other references to LiveCycle - the LiveCycle software seems a bit deep for what I am wanting but would greatly value some advice.
Thank you in advance!
CRDo you intend to do the merging on a server or desktop?
If server, check out: http://www.appligent.com/fdfmerge
or their FDF Merge Lite.
If desktop, it would be helpful if you provided more details about the type of workflow you envision.
George -
Web Application need to merge SQL and PDF on Server
I have written a internal web application .aspx using Acrobat Pro 9 and LifeCycle. I am using a California State PDF form that I cannot alter and merging data from SQL and an input form to produce the final PDF file. The application works great on the development server where the software is installed. The issue I am having is that I want my users to access the web application from their personal PC's in the office to great it and it appears that I need to have Acrobat Pro 9 installed on their desktops. This is not an acceptable solution for my 120 users. Is there anyway I can create the final pdf on the server and just provide them with a directory of the final document? This is my first application using Pro 9 and Life Cycle and really need anyone's help. Can Pro 9 even do this on the server ?
One of this:
http://forums.adobe.com/community/livecycle/livecycle_es
You can't use LiveCycle Designer or Adobe Acrobat on a server. -
Hi all,
I have merged around 15 patches. While applying that merged patch by using adpatch options=hotpatch it runs auto config at the end of patching . So i just want to know which patch cause to run auto config. How to find out.
EBS version: R12.1.3
ThanksGood day, Karan.
If we have the custom tops registered do we still be worried about losing customization after running autoconfig ?
Not if you follow the supported/documented methods.
Using AutoConfig to Manage System Configurations in Oracle E-Business Suite Release 12 (Doc ID 387859.1) -- SECTION 4: CUSTOMIZING AUTOCONFIG-MANAGED CONFIGURATIONS (Define a product_top)
R12: Customizations Are Lost When Cloning An Environment (Doc ID 1389730.1)
How To Preserve Customizations In adcfgclone.pl Script (Doc ID 828874.1)
Thanks,
Hussein -
Dear buddies,
I have a problem to fix.
I have a table:
t1
STKey: Just a primary key created using a sequence
Stable: source table name
SKey: Key that matches with the target table
Ttable: Target table's name
Tkey: The primary key in the target table
t2
FK: the same as t1's STKeyy
Source: The column in the source table
Target: The matching column from source to target
So the same FK can have more than 1 row
This is for some updating purpose.
Now my problem is I need to perform an update or create another table if the values of the columns are not the same, for example:
t1
STKey | STable | SKey | TTable | TKey
27 old_staff trim(staffid) new_staff trim(Staff_code)
t2
FK | Source | Target
27 address_1 home_address <- these are column names
27 address_2 office_address <- these are column names
I need to create a script which will check if both the columns given has the same value
like : if address_1 = home_address
How can I do this? It should be a script which runs for thousands of rows.
Please guide me?
Thanks in advance.select * from table_info;
create table t1
*(STKey varchar2(10),*
STable varchar2(30),
SKey varchar2(200),
TTable varchar2(30),
TKey varchar2(10),
TLastUpdate varchar2(30)
drop sequence seq_counter;
CREATE SEQUENCE seq_counter
MINVALUE 0
MAXVALUE 100
START WITH 1
INCREMENT BY 1;
-- to insert the source table details
insert into t1 (STKey, Ttable, tkey, TLastUpdate)
select seq_counter.nextval, tablename, 'LegacyKey', 'LastUpdateDate'
from table_info;
update t1
set stable = 'staff_details'
where ttable = 'S_Recruitment';
update t1
set skey = 'trim(staff_id) || ''_'' || trim(dep_no) || ''_'' || trim(campus_id)'
where ttable = 'S_Recruitment';
-- to create the columns table
drop table t2;
create table t2
*(FK number(10),*
Source varchar2(150),
Target varchar2(300)
--this has to be done manually*
insert into t2
select * from*
*(select 27, 'MIGRATION', 'created user' from dual) union*
*(select 27, to_char(sysdate), 'createddate' from dual) union*
*(select 27, 'case when trim(conditional) = ''1'' then ''Y'' else null end', 'Is_Borderline' from dual)*
I want to do something like this:
Update S_Recruitment
set dep_no = staff_details.dep_no
where legacykey = (select 'trim(staff_id) || ''_'' || trim(dep_no) || ''_'' || trim(campus_id)' from staff_details);
or
create table GenericUpdate
*(objectid varchar2(20),*
columnName varchar2(50),
NewValue varchar2(300));
insert into GenericUpdate
select a.objectid, b.target, ....
from S_Recruitment a , t1 b, t2 c
where a.legacykey = (trim(staff_id) || ''_'' || trim(dep_no) || ''_'' || trim(campus_id))
and c.fk = b.stkey
*.* -
hi all
observe the below query
SELECT RTRIM(XMLAGG(xmlelement (e,ename,',')).EXTRACT('//text()')) a
FROM EMP
group by deptno
it gives output as below
A
KING,MILLER,CLARK,
JONES,ADAMS,SMITH,FORD,SCOTT,
BLAKE,JAMES,TURNER,MARTIN,WARD,ALLEN,
CF_TYPE,CF_TYPE,CF_TYPE,
in the above output fourth row is having duplicate names
but i need to avoid duplicates and print all distinct as below
A
KING,MILLER,CLARK,
JONES,ADAMS,SMITH,FORD,SCOTT,
BLAKE,JAMES,TURNER,MARTIN,WARD,ALLEN,
CF_TYPE,Please help me on this.
am using oracle Application Express 4.0.2.00.08thanks for all in advanceHi,
WITH data AS
SELECT deptno, ename, DENSE_RANK() OVER (PARTITION BY deptno ORDER BY ename) rn
FROM emp
SELECT DISTINCT deptno, LTRIM(SYS_CONNECT_BY_PATH(ename,','),',') ename
FROM data
WHERE CONNECT_BY_ISLEAF = 1
CONNECT BY PRIOR rn + 1 = rn
AND PRIOR deptno = deptno
START WITH rn = 1
; -
HOW TO FIND THE RETURNING DATA TYPE OF THE FOLLOWING:
SELECT NVL(A,B) FROM DUAL ;
HERE 'A' HAS CHARACTER DATA TYPE AND 'B' HAS NUMBER DATA TYPE?
pLEASE HELPNVL is an overloaded function with different in params, Depending on the in-params, the return-value is defined. So look up the onlinehelp for the return-type. If you want to "proof", you could create a view with that expression as column and check USER_TAB_COLUMNS for the datatype.
-
Hi all,
SELECT plaf~matnr plaf~gsmng INTO CORRESPONDING FIELDS OF TABLE it_plan FROM plaf
INNER JOIN mara ON
plaf~matnr EQ mara~matnr
WHERE plaf~matnr IN s_matnr AND
plaf~plwrk EQ p_werks AND
mara~mtart EQ 'FERT' AND
plaf~umskz EQ 'X' AND
plaf~paart EQ 'LA' AND
plaf~pedtr IN s_date.
"In this query i want to get total quantity (gsmng) of particular material with in date range...
for example :
now I'm getting like this..
MATNR GSMNG
947604015 10.00 "13.12.2007
947604015 20.00 "16.12.2007
947604016 45.00 "11.12.2007
947604015 15.00 "18.12.2007
but I want like this...
947604015 30.00
947604016 60.00
please give me some suggetions....You can try with the following code:
SELECT plafmatnr sum(plafgsmng) as gsmng
INTO CORRESPONDING FIELDS OF TABLE it_plan FROM plaf
INNER JOIN mara ON
plafmatnr EQ maramatnr
WHERE plaf~matnr IN s_matnr AND
plaf~plwrk EQ p_werks AND
mara~mtart EQ 'FERT' AND
plaf~umskz EQ 'X' AND
plaf~paart EQ 'LA' AND
plaf~pedtr IN s_date
group by plaf~matnr.
This will help you to collect the figures per matnr from the ddatabase at one shot.
Regards,
Anindita -
Question about Merge Statement
Is it possible to use a CASE statement inside the update clause of a merge statement? Also what about a function?
I have a string (In Source) that needs to be split into multiple columns (In Target) depending on values in other columns (In Source).
I am on 11iR1Hi Chris,
You can take a look at the below examples :
SQL>create table t_test
col1,col2,col3
) as
select 1,2,3 from dual union all
select 2,3,4 from dual union all
select 3,4,2 from dual union all
select 9,10,12 from dual union all
select 11,23,43 from dual
create table succeeded.
SQL>select * from t_test;
COL1 COL2 COL3
1 2 3
2 3 4
3 4 2
9 10 12
11 23 43
SQL>merge INTO t_test t_t USING
SELECT
1 AS col1
FROM
dual
) d_d
ON
(d_d.col1 = t_t.col1)
WHEN matched THEN
UPDATE set
col2 = (
CASE
WHEN d_d.col1 = 1
THEN 123
ELSE -1
END );
1 rows merged
SQL>select * from t_test;
COL1 COL2 COL3
1 123 3
2 3 4
3 4 2
9 10 12
11 23 43
Maybe you are looking for
-
ITunes Match won't play complete songs, why?
I got itunes match when it first came out. I am running iTunes 10.5.2 for Windows (hopefully getting a Mac soon). I have a black iPhone 4S 32GB, and a black iPad 2 32GB, AT&T 3G. Both devices are running iOS 5.0.1. When I play songs from iTunes on my
-
hi to all.. i am new to BI concepts and is working as a trainee... can you people send me some links for the better understanding of the subject ...... so that it can help me in my report about the same... Thanks alot Prerna
-
Displaying Specified Report Rows per Page, w/ "Next" & "Previous" Buttons
I have a report on my page, and what I am trying to do SHOULD be very simple, but the options provided and their explanations within the HTML DB application are ambiguous. All I want to do is have my report display 50 records per page, and have butto
-
How to set up forwarded mail?
I have several email addresses associated with my personal domain name that I have, that I set up on my host as forwards/aliases so I don't actually check server for mail sent to those accounts. In Apple Mail I want to be able to send out mail someti
-
How does LabVIEW calculate filter coefficien​ts?
I am attempting to develop a model for a post - processing routine that uses a cascaded IIR lowpass filter, in order to demonstrate to a customer the performance of our data acqusition system, without divulging our proprietary source code. Does anyon