Turn a procedure into a Function?

I've got a procedure that generates a random 4 digit pin as per my unique requirements. I'd like to turn it into a function so that I could call it in an updated statement to update rows in a table with a random pin number.
Would it be possible to turn this into a function? Never written one before and could use a steer please.
CREATE OR REPLACE PROCEDURE TEST.scr_pin_generator
IS
v_candidate_pin NUMBER (4);
v_pin_1 NUMBER (1);
v_pin_2 NUMBER (1);
v_pin_3 NUMBER (1);
v_pin_4 NUMBER (1);
v_pin_count NUMBER := 0;
v_done CHAR(1) := 'N';
c_no_of_pins_reqd NUMBER := 200000;
BEGIN
WHILE v_done = 'N'
LOOP
v_candidate_pin := ROUND (DBMS_RANDOM.VALUE (1, 9999));
IF v_candidate_pin < 1000
THEN
-- dbms_output.put_line('Reject1='||to_char(v_candidate_pin));
GOTO end_loop;
END IF;
v_pin_1 := SUBSTR (v_candidate_pin, 1, 1);
v_pin_2 := SUBSTR (v_candidate_pin, 2, 1);
v_pin_3 := SUBSTR (v_candidate_pin, 3, 1);
v_pin_4 := SUBSTR (v_candidate_pin, 4, 1);
/* avoid all numbers the same */
IF v_pin_1 = v_pin_2
THEN
-- dbms_output.put_line('Reject2='||to_char(v_candidate_pin));
GOTO end_loop;
END IF;
/* avoid consecutive up */
IF v_pin_2 = v_pin_1 + 1 AND v_pin_3 = v_pin_2 + 1
THEN
-- dbms_output.put_line('Reject3='||to_char(v_candidate_pin));
GOTO end_loop;
END IF;
/* avoid consecutive down */
IF v_pin_2 = v_pin_1 - 1 AND v_pin_3 = v_pin_2 - 1
THEN
-- dbms_output.put_line('Reject4='||to_char(v_candidate_pin));
GOTO end_loop;
END IF;
v_pin_count := v_pin_count + 1;
INSERT INTO random_test
VALUES (v_candidate_pin);
--dbms_output.put_line('Number='||to_char(v_candidate_pin));
<<end_loop>>
IF v_pin_count = c_no_of_pins_reqd
THEN
v_done := 'Y';
END IF;
END LOOP;
COMMIT;
END;
/

I think something like this will give you what you want.
SQL> create table t as select object_name from dba_objects where rownum < 101;
Table created.
SQL> alter table t add pin number(4);
Table altered.
SQL> update t set pin = floor(dbms_random.value(1000, 9999));
100 rows updated.
SQL> select * from t;
OBJECT_NAME                          PIN
ICOL$                                4432
I_USER1                              2994
CON$                                 7600
UNDO$                                1970
C_COBJ#                              3502
I_OBJ#                               1052
PROXY_ROLE_DATA$                     7310
I_IND1                               1318
I_CDEF2                              8377
I_PROXY_ROLE_DATA$_1                 6997
FILE$                                4116
UET$                                 7381
I_FILE#_BLOCK#                       8885
I_FILE1                              6456
.

Similar Messages

  • Calling a procedure into select

    Is this possible ?
    select sp_info_element_ctrl(:new.code_usager_ctrl), from dual;

    Hi,
    932262 wrote:
    Yes it was part of a trigger, what i am trying to do is to insert data of an old tabl into new one, the new one contains all the old colomns plus one, the code_usager_ctrl which is given by the procedure. But i don't want to use the trigger. Is that possible ? Or do i need to convert the procedure into a function.There is no way to call a procedure from a SQL statement.
    You can call a function from a SQL statement, such as a query. There are some restrictions on the function. In particular, it can't have IN OUT or OUT arguments, only IN arguments. It looks like you could convert your procedure into a fucntion. The return value of the function would be what the IN OUT argument p_code_usager_ctrl is in the procedure. It looks like p_date_ctrl is always SYSDATE, so you might as well just use SYSDATE.
    Here's the procedure
    CREATE OR REPLACE PROCEDURE SP_INFO_ELEMENT_CTRL
    ( P_DATE_CTRL IN OUT DATE -- TIMESTAMP DE LA TRX
    ,P_CODE_USAGER_CTRL IN OUT CHAR -- CODE D'usager utilise
    ) AS
    BEGIN
    -- RECHERCHE DE LA DATE
    P_DATE_CTRL := SYSDATE;
    -- Si l'usager est IGD, c'est le package qui fourni le nom d'utilisateur
    IF (USER = 'IGD' OR USER = 'GDI' OR USER='IGDD') AND P_CODE_USAGER_CTRL IS NOT NULL THEN
    P_CODE_USAGER_CTRL := 'IGDD\'||TRIM(P_CODE_USAGER_CTRL);
    ELSE
    -- RECHERCHE DE L'usager
    P_CODE_USAGER_CTRL := USER;
    END IF;
    END;
    Edited by: 932262 on 2012-05-11 10:28It looks like this procedure doesn't do anything that you couldn't do as eaily in a CASE expression in pure SQL

  • SQL Server Procedures to Oracle Functions

    Is there an option in the Migration Assistant 1.2.0 that will convert the SQL Server procedures into Oracle Functions (rather than procedures)?
    By default the T/SQL procedures return a integer status code. Our middle-tier requires calls to procedures to return a status code (integer), and I'd like the migration to modify the "procedure" to a "Function returning Integer" rather than Procedure.

    Thomas,
    This is not an option currently. We will look into this for a future release. You could manually make the changes post conversion, prior to generation. As well as adding appropriate RETURN statements, you may want to add additional exception handling so the appropriate error is passed back.
    Donal

  • Need to turn this PLSQL into a procedure

    Hi All,
    I have the following PLSQL which declares a cursor, then loops using the cursor variable. I'm new to creating procedures and packages and i'm having trouble turning this PLSQL into one of those. When i put my PLSQL code in a procedure it doesn't like the DECLARE statement or the CURSOR section. I'm not sure how to tweak it to get the syntax correct for a procedure. Can someone point me in the right direction?
    Here is the PLSQL:
    DECLARE
    /* Output variables to hold the result of the query: */
    groupid assignment_group.id%TYPE;
    /* Cursor declaration: */
    CURSOR Asset_Rank_HistoryCursor IS
    select distinct id from assignment_group;
    BEGIN
    OPEN Asset_Rank_HistoryCursor;
    LOOP
    /* Retrieve each row of the result of the above query into PL/SQL variables: */
    FETCH Asset_Rank_HistoryCursor INTO groupid;
    /* If there are no more rows to fetch, exit the loop: */
    EXIT WHEN Asset_Rank_HistoryCursor%NOTFOUND;
    /* Insert the the new rows */
    insert into ASSET_RANK_GROUPED (asset_id , dt, rank, score, ASSIGNMENT_GROUP_ID)
    select asset_id, max_dt, rownum, score, groupid from (
    SELECT <big nasty select statement>
    END LOOP;
    /* Free cursor used by the query. */
    CLOSE Asset_Rank_HistoryCursor;
    END;
    How do i change my DECLARE and CURSOR statement so the procedure will create. Do i need to break it out into a function?

    I figured it out... just had to play w/ the syntax. Had to make sure the BEGIN statement was AFTER the CURSOR declaration and had to make sure any variables are declared up top, didn't need a DECLARE section in procedure. I just put the groupid variable right after IS at the top of procedure creation statement.

  • Turn a case statement into a function

    I have a case statement (from an earlier post - thank you) that works. I was wondering if it could be edited and change into a function instead. I think it would be cleaner. The variable is set in the Form Properties (pCounterA).
    switch (pCounterA.value)
        case "1":
        profileA__1image.rawValue = profileA_1image.value.image.value;
        pCounterA.value = "2";
        break;
        case "2":
        profileA__1image.rawValue = profileA_2image.value.image.value;
        pCounterA.value = "3";
        break;
        case "3":
        profileA__1image.rawValue = profileA_3image.value.image.value;
        pCounterA.value = "4";
        break;
        case "4":
        profileA__1image.rawValue = profileA_4image.value.image.value;
        pCounterA.value = "5";
        break;
        case "5":
        profileA__1image.rawValue = profileA_5image.value.image.value;
        pCounterA.value = "1"; // loops back to the first image
        break;

    Hi,
    If you insert a script object by right clicking on the root container (often "form1"). It will appear unnamed in the root / variables in the hierarchy.
    First of all you should name the script object, staying away from reserved names, eg "this". Say "myScripts"
    Script objects can only contain Javascript, so you would need to convert FormCalc scripts (not an issue in your case).
    When you go into the script object, you start off a function with "function" followed by its name and inputs in brackets. The extent of the function is given by curly brackets:
    function changeImage(vCounter)
         switch (vCounter)
             case "1":
             profileA__1image.rawValue = profileA_1image.value.image.value;
             pCounterA.value = "2";
             break;
         } // close switch statement
    } // close function
    Back in the form you can call the function by referencing the name of the script object and the name of the function.
    myScripts.changeImage(pCounterA.value);
    A couple of things to note:
    The input in the script can refer to an objects value or a global variable, but in the function you can assign it s different name. So above the input pCounterA.value is EQUAL to vCounter in the function;
    You can have several inputs in the call for the function separated by commas;
    Don't have the same name for the script object AND the function
    Hope that helps,
    Niall

  • The Complete Procedure For Turning Audio Cassettes Into MP3s

    Please consider me a baby , or ignorant on how to begin the process of turning many old and rare cassettes into MP3 format.
    One friend told me that I need to get an audio interface device to go with my MacBook Pro to do this.
    Another friend said he uses Adobe Audition to turn his cassettes into MP3s, but I am not sure if he uses this with a PC or with a Mac. The whole thing is not clear to me. 
    I read briefly in another query that Taste or Spin Doctor is used to do this. Are they similar soft ware like Adobe Audition, and if so are they more user friendly ?
    I need to be able to visualize what kind of wires I need to connect the Mac to an audio interface to the cassette player.
    I want to get the best quality sound I can, within a certain budget, if there are certain factors that I am not aware of. I'm archiving these recordingsd for generations to come.
    Once I learn from you how to connect all of this together, I need to know how I will edit these tapes. Some will be at a low volume and I may need to increase the volume, some may be distorted and loud. Some will have a hiss on them or some other interference.
    Another concern is that when a freind did some cassettes for me into MP3 before, entire sides of a cassette with many songs all got "stuck together" as if they were all one song. I would like to be able to divide them up on a side. Do I do this editing as the recording is being done, or do I do this later ? What is possible ? It seems it is better to do it as it is playing.
    Thanks very much for reading this and helping me to get started with your guidance !
    Sincerely,
    Gaura
    Message was edited by: Gauradas

    If you can see the track in your iTunes library, right-click the track and choose "Show in Windows Explorer."  This will take you right to the folder where the corresponding song file is located.

  • Calling a Procedure inside a Function

    How to call procedure within the function. please help

    I called the procedure as u said but it is firing.. please help me out.. here is the code.
    This code is to generate the SEquence ids.
    *********** Procedure ***************
    create or replace procedure ExecImmd
    is
    Begin
         EXECUTE IMMEDIATE 'DROP SEQUENCE emplseqid';
         EXECUTE IMMEDIATE 'CREATE SEQUENCE emplseqid START WITH 1001 INCREMENT BY 1';
    END;
    CREATE OR REPLACE FUNCTION GenCustId RETURN VARCHAR2
    IS
    VEMPID VARCHAR2(6);
    ISEQID NUMBER(5);
    P1 VARCHAR2(10);
    P2 VARCHAR2(10);
    BIND2 VARCHAR2(10);
    BEGIN
         SELECT MAX(SUBSTR(EMPID,1,2)) INTO P1 FROM EMPL;     
         SELECT EMPLSEQID.NEXTVAL INTO ISEQID FROM DUAL;
         IF ASCII(SUBSTR(P1,2,1)) < ASCII('Z') THEN
              IF ISEQID <= 9999 THEN
              bind2 := SUBSTR(P1,1,2) || ISEQID;
              ELSE
              /* here i am calling a procedure.
              ExecImmd();
              SELECT EMPLSEQID.NEXTVAL INTO ISEQID FROM DUAL;
              bind2 := SUBSTR(P1,1,1) || CHR(ASCII(SUBSTR(P1,2,1))+1) || ISEQID;
              END IF;
         ELSE
              if p1 is null then
                   bind2 := 'AA' || ISEQID;          
              else
                   IF ISEQID <= 9999 THEN
                   bind2 := SUBSTR(P1,1,2) || ISEQID;
                   Else
                   bind2 := CHR(ASCII(SUBSTR(P1,1,1))+1) || 'A' || ISEQID;          
                   End If;
              End If;
         END IF;
         return bind2;
         END;

  • Pass SQL into a Function

    Is it possible to pass a SQL into a Function
    DECLARE
       f        sys_refcursor;
       RESULT   NUMBER;
       FUNCTION myfunction (r sys_refcursor)
          RETURN NUMBER
       IS
       BEGIN
          RETURN TO_NUMBER (TO_CHAR (r.dt, 'DD'));
       END;
    BEGIN
       OPEN f FOR
          SELECT SYSDATE dt
            FROM DUAL;
       RESULT := myfunction (f);
       CLOSE f;
    END;

    Yes you are allowed to pass ref cursor but they have to processed the way you processur cursor i.e. OPEN, FETCH, CLOSE.
    See demonostration of working code:
    SQL>DECLARE
      2     f        sys_refcursor;
      3     RESULT   NUMBER;
      4
      5     FUNCTION myfunction (r sys_refcursor)
      6        RETURN NUMBER
      7     IS
      8     v_currDate DATE;
      9
    10     BEGIN
    11        IF r%ISOPEN THEN
    12          FETCH r INTO v_currDate;
    13        END IF;
    14
    15        RETURN TO_NUMBER (TO_CHAR (v_currDate, 'DD'));
    16     END;
    17  BEGIN
    18     OPEN f FOR
    19        SELECT SYSDATE dt
    20          FROM DUAL;
    21
    22     RESULT := myfunction (f);
    23
    24     DBMS_OUTPUT.PUT_LINE('Date : ' || RESULT );
    25
    26     CLOSE f;
    27  END;
    28  /
    Date : 23
    PL/SQL procedure successfully completed.
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I have turned PowerPoint slides into a PDF and now want to insert this into a docx packet.  I can't do this.  Help.

    I have turned PowerPoint slides into a PDF and now want to insert this into a docx packet.  I can't do this.  Help.

    Hi leastoners,
    If you're trying to insert a file into a Word document, your best bet is to check the Word online Help. (What you describe sounds like a function of Word, not of Acrobat). I did a quick search and came up with this: Add a PDF to a document - Word. But I'm not sure that's what you're looking for.
    If I misunderstood your request, please let me know and we can take it from there.
    Best,
    Sara

  • Have just turned my beloved into a PC by downloading Mavericks.  How do I get rid of it?

    Have just turned my Apple into a PC by downloading Mavericks.  How do I get rid oif it?

    Erase the hard drive, then restore your old system from your backup. Otherwise,
    Install Mavericks, Lion/Mountain Lion Using Internet Recovery
    Be sure you backup your files to an external drive or second internal drive because the following procedure will remove everything from the hard drive.
    Boot to the Internet Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND-OPTION- R keys until a globe appears on the screen. Wait patiently - 15-20 minutes - until the Recovery main menu appears.
    Partition and Format the hard drive:
    1. Select Disk Utility from the main menu and click on the Continue button.
    2. After DU loads select your newly installed hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Click on the Options button, set the partition scheme to GUID then click on the OK button. Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the process has completed. Quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion. Mavericks: Select Reinstall Lion/Mountain Lion, Mavericks and click on the Install button. Be sure to select the correct drive to use if you have more than one.
    Note: You will need an active Internet connection. I suggest using Ethernet
                if possible because it is three times faster than wireless.
    This should restore the version of OS X originally pre-installed on the computer.
    If you originally started with Snow Leopard:
    Clean Install of Snow Leopard
    Be sure to make a backup first because the following procedure will erase
    the drive and everything on it.
         1. Boot the computer using the Snow Leopard Installer Disc or the Disc 1 that came
             with your computer.  Insert the disc into the optical drive and restart the computer.
             After the chime press and hold down the  "C" key.  Release the key when you see
             a small spinning gear appear below the dark gray Apple logo.
         2. After the installer loads select your language and click on the Continue
             button. When the menu bar appears select Disk Utility from the Utilities menu.
             After DU loads select the hard drive entry from the left side list (mfgr.'s ID and drive
             size.)  Click on the Partition tab in the DU main window.  Set the number of
             partitions to one (1) from the Partitions drop down menu, click on Options button
             and select GUID, click on OK, then set the format type to MacOS Extended
             (Journaled, if supported), then click on the Apply button.
         3. When the formatting has completed quit DU and return to the installer.  Proceed
             with the OS X installation and follow the directions included with the installer.
         4. When the installation has completed your computer will Restart into the Setup
             Assistant. Be sure you configure your initial admin account with the exact same
             username and password that you used on your old drive. After you finish Setup
             Assistant will complete the installation after which you will be running a fresh
             install of OS X.  You can now begin the update process by opening Software
             Update and installing all recommended updates to bring your installation current.
    Download and install Mac OS X 10.6.8 Update Combo v1.1.

  • How do I return two values from a stored procedure into an "Execute SQL Task" within SQL Server 2008 R2

    Hi,
    How do I return two values from a
    stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
    Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
    Something like ?
    CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
    @intPeriod INT,
    @strPeriod_Length NVARCHAR(1),
    @dtStart NVARCHAR(8) OUTPUT,
    @dtEnd NVARCHAR(8) OUTPUT
    AS
    then within the SSIS component; -
    Kind Regards,
    Kieran. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
    Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
    Add a script task to check ssis variables values using,
    Msgbox(Dts.Variables("User::strExtractStartDate").Value)
    Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
    Regards, RSingh

  • How to go into a function module through SE80 t - code

    Hi All , 
                 How to go into a function module through SE80 t - code.
    Thanks in advance.

    >
    Balaji Krishnamoorthy wrote:
    > Hi All , 
    >              How to go into a function module through SE80 t - code.
    >
    > Thanks in advance.
    Hi,
    With  help of  function group
    Thanks & Regards
    Edited by: Always Learner on Oct 16, 2008 2:31 PM

  • How to Split a Stored Procedure into  4 SP's URGENT!!!!!!!!!!!!!!!!

    hi,
    Every thing is set now. But only one issue is left over.
    CREATE OR REPLACE package dyn_query_MBU21
    is
    type r_cur is ref cursor;
    procedure get_query(p_scorecard_id in integer,p_user_id in integer,p_start_bu in integer,p_end_bu IN INTEGER,p_parent_srsid in integer);
    procedure printQuery(p_scorecard_id integer,p_user_id integer,p_start_bu integer,p_end_bu integer,p_parent_srsid integer);
    end dyn_query_MBU21;
    CREATE OR REPLACE package body dyn_query_MBU21
    is
    procedure get_query(p_scorecard_id in integer,p_user_id in integer,p_start_bu in integer,p_end_bu IN INTEGER,p_parent_srsid in integer)
    is
    l_query VARCHAR2(32700);
    v_temp varchar2(300);
    v_strLength integer;
    val integer;
    --p_start_bu INTEGER;
    --p_end_bu INTEGER;
    --v_cur r_cur;
    l_buCount integer default 0;
    BEGIN
    l_query := 'select
    a.PLAN_TO_WIN PTWID,
    a.SPQRC SPQRCID,
    l.NAME Plan_to_Win,
    m.NAME BPD,
    a.metric_id,
    a.NAME Key_Measures,
    a.DESCRIPTION,
    c.DATE_MONTH_DIM_KEY,
    c.CALENDAR_MONTH_NBR,
    c.CALENDAR_YEAR_MONTH_CDE,
    e.SRS_ID,e.YEAR_VALUE,
    f.YTD_VALUE YTD,
    g.CALENDAR_YEAR_NBR,
    h.FIRST_NAME || h.LAST_NAME Scorecard_Owner
    , j.TYPE_NAME Management_Level,
    k.NAME Business_Unit
    , N.SCORECARD_ID
    , N.NAME
    , K.LOC_CURRENCY_ID
    --decode(ltrim(rtrim(k.PARENT_SRS_ID)),' || p_parent_srsid || ', k.NAME) Parent_BU ';
    , decode(ltrim(rtrim(k.PARENT_SRS_ID)),3,''Bill Boggs'') Parent_BU ';
    for x in ( select distinct NAME from SRS_DIM where parent_srs_id = p_parent_srsid and rownum < 20)
    loop
    l_buCount := l_buCount + 1;
    l_query := l_query ||
    ' , decode(ltrim(rtrim(K.NAME)),'''||ltrim(rtrim(x.NAME))||''', D.MONTH_VALUE ) '||replace(to_char(x.NAME),' ','_');
    -- dbms_output.put_line('this is the query'||l_query);
    end loop;
    l_query := l_query ||
    ' FROM
    METRIC_DIM A,TARGET_MONTH B,DATE_MONTH_DIM C,METRIC_SRS_MONTH_EVAL D,TARGET_YEAR E,METRIC_SRS_YTD_EVAL F,DATE_YEAR_DIM G,
    GM_USER_DIM H,USER_PRIV I,SRS_ITEMTYPE_DIM J,SRS_DIM K,PLAN_TO_WIN_DIM L,SPQRC_DIM M,SCORECARD_DIM N
    WHERE
    L.PLAN_TO_WIN_ID= A.PLAN_TO_WIN
    AND M.SPQRC_ID= A.SPQRC
    AND A.METRIC_ID=B.METRIC_ID
    AND B.DATE_MONTH_DIM_KEY=C.DATE_MONTH_DIM_KEY
    AND B.SRS_ID=K.SRS_ID
    AND B.SRS_ID=F.SRS_ID
    AND D.SRS_ID=F.SRS_ID
    AND D.SRS_ID=K.SRS_ID
    AND D.DATE_DIM_KEY=C.DATE_MONTH_DIM_KEY
    AND D.METRIC_ID = B.METRIC_ID
    AND D.METRIC_ID = E.METRIC_ID
    AND D.METRIC_ID = F.METRIC_ID
    and d.SRS_ID=b.SRS_ID
    and d.DATE_DIM_KEY=b.DATE_MONTH_DIM_KEY
    AND E.SRS_ID = F.SRS_ID
    AND G.DATE_YEAR_DIM_KEY = E.DATE_YEAR_DIM_KEY
    AND G.CALENDAR_YEAR_NBR = C.CALENDAR_YEAR_NBR
    AND F.DATE_DIM_KEY = E.DATE_YEAR_DIM_KEY
    AND K.PARENT_SRS_ID =n.SRS_ID
    AND N.SCORECARD_ID= :p_scorecard_id
    AND H.USER_ID = :p_user_id
    AND K.SRS_ID BETWEEN :p_start_bu AND :p_end_bu
    --AND P_PARENT_SRS_ID = :p_parent_srsid1
    -- ANd n.Scorecard_id=2
    -- AND H.USER_ID = 7000001
    AND J.TYPE_ID = :p_parent_srsid
    --AND K.SRS_ID = 8
    GROUP BY
    a.PLAN_TO_WIN,
    a.SPQRC,
    l.NAME,
    m.NAME,
    a.metric_id,
    a.NAME,
    a.DESCRIPTION,
    c.DATE_MONTH_DIM_KEY,
    c.CALENDAR_MONTH_NBR,
    c.CALENDAR_YEAR_MONTH_CDE,
    e.SRS_ID,
    e.YEAR_VALUE,
    f.YTD_VALUE,
    g.CALENDAR_YEAR_NBR,
    h.FIRST_NAME || h.LAST_NAME,
    j.TYPE_NAME,
    K.NAME,
    l.PLAN_TO_WIN_ID,
    m.SPQRC_ID,
    N.SCORECARD_ID,
    N.NAME,
    K.LOC_CURRENCY_ID,
    --decode(ltrim(rtrim(k.PARENT_SRS_ID)),' || p_parent_srsid || ', k.NAME) Parent_BU ';
    , decode(ltrim(rtrim(k.PARENT_SRS_ID)),3,''Bill Boggs'') Parent_BU ';
    for x in (select distinct NAME from SRS_DIM where parent_srs_id = p_parent_srsid and rownum < 20 )
    loop
    l_query := l_query ||' , decode(ltrim(rtrim(K.NAME)),''' || x.NAME || ''', D.MONTH_VALUE ) ';
    end loop;
    l_query := l_query ||'order by a.PLAN_TO_WIN';
    -- open p_cur for l_query using p_scorecard_id,p_user_id,p_start_bu,p_end_bu,p_parent_srsid;
    select (length(l_query)/255) + 1 into v_strLength from dual;
    dbms_output.put_line('String Lenghth is :'||v_strLength);
    for c in 1..v_strLength
    loop
    if c = 1 then
    v_temp := SUBSTR(l_query, 1, 255);
    else
    if length(l_query) > (255 * c) then
    v_temp := SUBSTR(l_query, 255 * (c-1) , 255);
    end if;
    end if;
    dbms_output.put_line(v_temp);
    end loop;
    end get_query;
    procedure printQuery(p_scorecard_id in integer,p_user_id in integer,p_start_bu in integer,p_end_bu IN INTEGER,p_parent_srsid in integer) is
    Begin
    get_query(p_scorecard_id,p_user_id,p_start_bu,p_end_bu,p_parent_srsid);
    End printQuery;
    end dyn_query_MBU21;
    I want to split this procedure into 6 procedures to make it look easier.
    1.getSQLSelect
    2.getSQLFrom
    3.getSQLWhere
    4.getSQLGroupBY
    5.getSQLOrderBY
    add another proc...getSQL that returns all the above procs ie,
    I need to build the entire sql & call "Open Cursor" meaning...getSQLSelect||getSQLFrom()...
    How to do this ?
    Thanks in Advance

    You're missing a comma.

  • How do I turn an image into a transparency?

    Hi,
    There's a question I've seen asked dozens or hundreds of times, and I thought I found an answer a few years ago. I've since forgotten how to do it:
    Turn an image into a transparency.
    Now, the obvious solution is to set the layer to "multiply." Yes, this is the effect I want. However, I want the layer to be transparent instead.
    Another solution is to draw an image on a transparent layer. This works great, but only applies if I create the image from scratch. I want to convert an existing image.
    Another solution is multiple steps:
    1) Copy image
    2) Click "edit in quick mask mode."
    3) Paste image
    4) Exit quick mask mode.
    5) Invert selection.
    6) Ctrl+backspace to fill selection with black, on a blank transparent layer.
    Result? The image is now transparent! However, this converts the image to greyscale! Great for linework and text, terrible for photos or art!
    In an older version of Photoshop 7, I believe I got the following to work:
    A) Follow the previous steps 1-6, creating a layer with transparency
    B) Copy the original picture to a layer above the transparency
    C) Group the layer with the transparency layer below. (Note, grouping doesn't work the same any more.)
    D) The top layer provides the colors, but the bottom layer provides the transparency.
    E) It is too light, so you take the top layer, and maximize "saturation" 100%.
    F) Merge the two layers. It retains the transparency of the bottom layer, with the hue of the top layer.
    This no longer works, because I don't know how grouping layers works anymore.
    So, I need white pixels to be transparent. Black pixels to have zero transparency. Red pixels to have zero transparency. Etc.
    Meanwhile, grey pixels are solid black, but partly transparent. Pink pixels are solid red, but partly transparent.
    All pixels are 100% saturated, and the "lightness" is determined by how transparent they are.
    So, an analogy would be printing a photo on a transparency. I need to convert an image to a transparency.
    If the image/layer were overlaid on white, it would look exactly like the original photo.
    Does anyone know how to accomplish this? Mathematically, it's easy. But I don't know about any filter, process, or method to make the conversion using CS5.
    Thanks,
    Ben

    Hello!
    I hope that I understand what you need.
    (One could just put the image on a layer, and lower its opacity, but you seem to be looking for an effect in wich the tranparency is not the same for all pixels.)
    Try this:
    1) Turn your image image as a layer (double-click it if it is a background layer) [In order to add a mask]
    2) Select all, Copy (CTRL+a, CTRL+C)
    3) add a layer mask (click the rectangle with a circle in the bottom of the layers panel) [to be able to change transparency]
    4) target the mask [so that you can past an image in it] ALT+click the mask, paste the image.
    5) Invert the colors of the mask (CTRL+I) [in order for the white to be transparent and the black opaque].
    You now have a layer whose transparency is based on the lightness of the pixels.
    Hope that's what you are after!
    Pierre

  • How to pass a locale object into another function?

    Greetings,
    i like to pass a locale object into another function. These are my code below
    import java.util.*;
    public class Locales{
         public static void main(String[] args){
              Locale locale= new Locale("EN", "US");
              convert(locale);
    public void convert(Locale convert)
         String language = convert.getDisplayLanguage();
         System.out.println(language);          
    }I got this error:
    Locales.java:6: non-static method convert(java.util.Locale) cannot be referenced from a static content
                    convert(locale);
                    ^How do i correct it?
    Thanks

    Did you bother to do a search?
    Did you bother to read any of the material that the search would have linked you to?
    If you had then you would be able to understand where you are going wrong and how to fix it yourself. Instead of being spoonfed by us.

Maybe you are looking for