PL SQL - In Operator Issue [message #270632] |
Thu, 27 September 2007 12:44 |
trauwitz
Messages: 3 Registered: September 2007 Location: Mexico
|
Junior Member |
|
|
Hi,
I hope somebody could help me on my code,
here is the question:
The following code is working fine:
--------------------------------------------------------------
SET TERMOUT OFF
SET SERVEROUTPUT ON SIZE 999999
SET ECHO ON
DECLARE
v_week NUMBER;
v_year NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('*** START ***');
SELECT MAX(fiscal_year),
MAX(fiscal_week)
INTO v_year,
v_week
FROM pwc_ias_inv_highest_parts
WHERE fiscal_year = (SELECT MAX(fiscal_year)
FROM pwc_ias_inv_highest_parts
WHERE plant_cd IN ('AAA','BBB','CCC','DDD'));
DBMS_OUTPUT.PUT_LINE('v_year= '||v_year);
DBMS_OUTPUT.PUT_LINE('v_week= '||v_week);
END;
/
-----------------------------------------------
-- SQLPlus LOG:
--
-- v_year= 2007
-- v_week= 37
-- PL/SQL procedure successfully completed.
-----------------------------------------------
BUT this another one NOT, Why????
-----------------------------------------------------------------
DECLARE
v_code VARCHAR2(200);
v_week NUMBER;
v_year NUMBER;
BEGIN
v_code:= ''''||'AAA'||''''||','||''''||'BBB'||''''||','||''''||'CCC'||'''';
DBMS_OUTPUT.PUT_LINE('*** START***');
DBMS_OUTPUT.PUT_LINE('v_code = ' || v_code);
SELECT MAX(fiscal_year),
MAX(fiscal_week)
INTO v_year,
v_week
FROM pwc_ias_inv_highest_parts
WHERE fiscal_year = (SELECT MAX(fiscal_year)
FROM pwc_ias_inv_highest_parts
WHERE plant_cd IN (v_code));
DBMS_OUTPUT.PUT_LINE('v_year= '||v_year);
DBMS_OUTPUT.PUT_LINE('v_week= '||v_week);
END;
/
-----------------------------------------------------------------
-- v_code = 'AAA','BBB','CCC'
-- v_year=
-- v_week=
-- PL/SQL procedure successfully completed.
-----------------------------------------------------------------
Note: In the fist one I use the IN Operator without a variable, but in the second one I use it with a variable as parameter.
Please , somebody help me
Thanks!
|
|
|
|
|
|
|
|