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 AM
1. 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.
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. -
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,
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; -
Pl sql procedure - clarification
1)
create or replace procedure sp_emp(i_ename varchar2(5), i_date date) is
begin
v_cmd := 'create table emp_duplicate(eno number(5), ename varchar2(20) as select eno, ename
from emp e ' || 'where to_date(e.join_date,'dd-mm-yy') = ' || to_date(i_date,'dd-mm-yy') || 'and e.ename = ' i.ename;
execute v_cmd;
end;
The above procedure is not a compiled one. I have a procedure as above. I am getting error like ' not a
valid expresion '. Please make the above code to run. I have to implement in my project. The issue is with
the sttement (quotes , dd-mm-yy)
2)
ename dno
a 10
a 20
b 30
b 40
c 50
c 60
The table have two columns as above. I need an output as below.
ename dno output
a 10 10,20
a 20 10,20
b 30 30,40
b 40 30,40
c 50 50,60
c 60 50,60
please guide me.1. 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. -
Please help to understand the Service parts planning doubts/clarifications
Please help to understand the Service parts planning,we r tring to do poc for project
1)How the sales history flow from cube to Interactive forecasting screen(in spp,like dp in apo there is no Planning area to store data and no load planning area from cube,so please let me know how it will sales history load data?)
2)Does Sales History of the child location will agregated to entry level ? if so like that we need to run statistical forecats at entry location?
3)where we will create the from and To Product(eg:Maping Product A to Product B ) to do the Relignment /Phase in profile/Interchangebility
4)What is the leading indicator forecasting and the purpose?
5)Where data will store in SPP (forecasting and other data like liveache in dp)? Mpos and Planning area is not there in SPP?
6)Can you please forward the process document to understand the flow as i am not able understand completely by the help document
Thanks for advance help
Regards
KKKHi,
Please check Service Parts Planning - Enterprise Services in SAP Advanced Planning and Optimization - SAP Library
BR -
Hi
Now i have a report with select-option and parameter both. My requirement is i want to change the parameter input as a select-option input(RANGE). If i modified its need any changes in select statments or not. only if i make changes in declaration area its enough or its need select statment modification also ? i have little bit confusion kindly help this.
my statement is
PARAMETERS: P_STRUCT(4) TYPE C .
SELECT-OPTIONS: S_MATNR FOR MARC-MATNR.
i want to change the parameter into select-option. Its need any select statment modification?
Thanks,
Mohanayes ,
in select query you must have written
where structure = p_struct
now you need to change it to
where structure IN s_structure.
reward and close the thread if answered.
regards
taher -
Hi,
I have a table called inst_hst contains
institution_id modifiedate_time institution_status_code
3316 1/7/2009 AP
3316 9/13/2009 RE
3316 1/28/2010 SB
here i want to get the last modified date time record for example... the latest record here is
3316 1/28/2010 SB should be return... i dont want to retrieve other institution id...
can anyone please give me the query to retrieve the above valueuser572087 wrote:
Hi,
Thanks for your reply.. But i have more than one institution id like this... for example
3316 1/1/2001 SB
3316 1/2/2001 RE
3316 1/3/2001 AP
3317 1/1/2001 SB
3317 1/2/2001 RE
3318 1/3/2001 AP
3318 1/4/2001 SB
Hi,
In your sample data code 'AP' and 'RE' has two records with same date. so the result will look like this.
PRAZY@solarc> with T as
2 (
3 select 3316 institution_id, '1/1/2001' modifiedate_time, 'SB' institution_status_code From dual
4 UNION
5 select 3316, '1/2/2001', 'RE' From dual
6 UNION
7 select 3316, '1/3/2001', 'AP' From dual
8 UNION
9 select 3317, '1/1/2001', 'SB' From dual
10 UNION
11 select 3317, '1/2/2001', 'RE' From dual
12 UNION
13 select 3318, '1/3/2001', 'AP' From dual
14 UNION
15 select 3318, '1/4/2001', 'SB' From dual
16 )
17 select *
18 from (select t1.*, Dense_rank() over
19 (partition by institution_status_code order by modifiedate_time Desc) NewRow from T t1)
20 where NewRow=1;
INSTITUTION_ID MODIFIED IN NEWROW
3316 1/3/2001 AP 1
3318 1/3/2001 AP 1
3316 1/2/2001 RE 1
3317 1/2/2001 RE 1
3318 1/4/2001 SB 1
Elapsed: 00:00:00.00or
IF you just want to retrieve 1st record alone you can go with row_number instead of dense_rank
PRAZY@solarc> with T as
2 (
3 select 3316 institution_id, '1/1/2001' modifiedate_time, 'SB' institution_status_code From dual
4 UNION
5 select 3316, '1/2/2001', 'RE' From dual
6 UNION
7 select 3316, '1/3/2001', 'AP' From dual
8 UNION
9 select 3317, '1/1/2001', 'SB' From dual
10 UNION
11 select 3317, '1/2/2001', 'RE' From dual
12 UNION
13 select 3318, '1/3/2001', 'AP' From dual
14 UNION
15 select 3318, '1/4/2001', 'SB' From dual
16 )
17 select *
18 from (select t1.*, row_number() over
19 (partition by institution_status_code order by modifiedate_time Desc) NewRow from T t1)
20 where NewRow=1;
INSTITUTION_ID MODIFIED IN NEWROW
3316 1/3/2001 AP 1
3316 1/2/2001 RE 1
3318 1/4/2001 SB 1or
Partition using institution_id if you want the result based on ID
PRAZY@solarc> with T as
2 (
3 select 3316 institution_id, '1/1/2001' modifiedate_time, 'SB' institution_status_code From dual
4 UNION
5 select 3316, '1/2/2001', 'RE' From dual
6 UNION
7 select 3316, '1/3/2001', 'AP' From dual
8 UNION
9 select 3317, '1/1/2001', 'SB' From dual
10 UNION
11 select 3317, '1/2/2001', 'RE' From dual
12 UNION
13 select 3318, '1/3/2001', 'AP' From dual
14 UNION
15 select 3318, '1/4/2001', 'SB' From dual
16 )
17 select *
18 from (select t1.*, row_number() over
19 (partition by institution_id order by modifiedate_time Desc) NewRow from T t1)
20 where NewRow=1
21 /
INSTITUTION_ID MODIFIED IN NEWROW
3316 1/3/2001 AP 1
3317 1/2/2001 RE 1
3318 1/4/2001 SB 1Regards,
Prazy -
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 -
DB2 SQL statement clarification required
Good evening,
Hoping someone can help me as my Portal system is currently down and I have been unable to resolve the issue. Please refer to point 3 of Sap Note 1156313 :
3. Deploy the change. This should create an empty table WCR_USERSTAT with the new structure.
Does someone know what is meant by this statement? Please,
AnetteHello,
I had the same problem in our BI JAVA.
After renaming the table WCR_USERSTAT (step 2 in the note) I went back to the JSPM and resumed the deployment of the Support Packages. This time it worked.
In our case the table was empty, so I didn't have to copy the data afterwards.
Thanks,
Ingrid -
How to store and retrieve clob data fields
Hai al l,
How to sotre resumes of a Jobseekers in Oracle Data Base.Which version is enough(8i or 9i) and CLOB or BLOB is Preferable.
Now my requirement is to insert the all the Attachments into Oracle database. I have little bit knowledge on inserting image file into DB. Now I want to insert More than 1000000 resume Attachments (all are .doc or .rtf files).Can you suggest me on this with a sample program .I am really thankful to all of our Members support and Valuable doubt clarifications.
I am waiting for your valueble reply
thanks in advance
Kanchnaa
I am really thankful for your support and Valuable doubt clarifications.CLOBs and BLOBs are physically stored just like any other Oracle data type, in the data files that make up the database, the .dbf files. They're not stored as seperate files that you can use outside of Oracle.
Oracle has a seperate special data type for binary objects stored outside the database, the BFILE data type. However, this type is read-only from a database connection (and therefore from JDBC); the files have to be placed on the Oracle server some other way and the BFILE object is created as a pointer to that external resource. I think built-in stored procedures are used to actually read the data from the binary object.
I've never used this datatype and can't tell you much more about it. See the documentation:
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#sthref175 -
Hi Experts,
This is with reference to Logical Database (LDB) , I have some Doubts\Clarifications ,
1, What is the Significance of the Hierarchy of LDB structure (I.e Nodes\Tables).?
2, How to find the relation between to Nodes\Tables that is with which field references the tables were interlinked.
Thanks in Advance,
Regards,
SenHi
The Hierarchy/Tree structure of tables indicates the order of database tables data fetching. As per the order it should fetch.
For example take sales order 3tables VBAK,VBAP, VBEP
so the data has to be fetched from VBAK first, then VBAP and lastly from VBEP.
You can't fetch the data from VBEP starting. it is wrong.
Always tables were interlinked with the correct Keys fields.
for example if you take the above tables VBAK and VBAP are linked with VBELN field
and VBAP and VBEP are linked with VBELN and POSNR fields
So always LDB is created with such a linking tables only, not with any table just like that.
Reward points if useful
Regards
Anji
Maybe you are looking for
-
Mixing RAM types on my new MacBook Pro
Hello all, Just purchased a week 44 Mac Book Pro (Core Duo Only), and so far, everything is good, no cpu whine, no screen whine (though I think those issues were solved by this revision). I wanted to know, is it possible to take the 1GB of the ddr2 p
-
Hooking Up LCD TV Using mini DP to HDMI adapter ?
I am wondeirng if the Mini DP to HDMI adapters will work for my application as I have searched a few MFG. websites for the details but it seem all will only work fully (audio + video) with a LCD TV with a HDMI chip V1.3 or above. A LCD TV with a HDMI
-
How in detail, do you create a group message for the Mac Mini?
Could someone please help me create a group message in Mail on my Mac Mini computer. I have gone into Address Book but cannot find anywhere to create a group. Tried it and put the Group name at the top, then listed all the group but when I send a m
-
Setting a default folder view for all folders in Windows 7
How do you set up a default folder view of "List" for ALL the folders in Windows 7 including the optical drive? Artoo
-
MQSeries 5.2 still support old Java API 1.1.8 ?
We are using MQseries 5.1 and java 1.1.8. now we are upgrading to MQseries 5.2, do we need java 1.2 or 1.3. does the MQSeries 5.2 still support old Java API 1.1.8 ? thanks Rupinder