Can we use return statement in procedure?

Can we use return statement in procedure or we can use more than one return statement in procedure?

HamidHelal wrote:
NOReally? Did you at least test it? You can use RETURN in procedure or in anonymous PL/SQL block. The only restriction is you can't specify return value:
SQL> begin
  2      dbms_output.put_line('Before return');
  3      return;
  4      dbms_output.put_line('After return');
  5  end;
  6  /
Before return
PL/SQL procedure successfully completed.
SQL> create or replace
  2    procedure p1
  3      is
  4      begin
  5          dbms_output.put_line('Before return');
  6          return;
  7          dbms_output.put_line('After return');
  8  end;
  9  /
Procedure created.
SQL> exec p1;
Before return
PL/SQL procedure successfully completed.
SQL> begin
  2      dbms_output.put_line('Before return');
  3      return 99;
  4          dbms_output.put_line('After return');
  5  end;
  6  /
    return 99;
ERROR at line 3:
ORA-06550: line 3, column 5:
PLS-00372: In a procedure, RETURN statement cannot contain an expression
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
SQL> create or replace
  2    procedure p1
  3      is
  4      begin
  5          dbms_output.put_line('Before return');
  6          return 99;
  7          dbms_output.put_line('After return');
  8  end;
  9  /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE P1:
LINE/COL ERROR
5/9      PL/SQL: Statement ignored
5/9      PLS-00372: In a procedure, RETURN statement cannot contain an
         expression
SQL> SY.

Similar Messages

  • How can i use return statement in a method no flaming pls

    public class example2
    public int add(int i,int j)
    int k = i + j;
    return k; <<<< -HERE->
    public static void main(String[] args)
    example2 obj=new example2();
    obj.add(2,3);
    System.out.println("k"+k);
    Iam really really new to java programming so dont flame me
    In the above program i was hoping by putting return k it would return vlaue of k to the calling object but it didnt work i had to place sys.out.println in the method and take out the return from the method for it to work
    So why dosent it work and where is it returned to the k value.

    BlueRibbon wrote:
    In the above program i was hoping by putting return k it would return vlaue of k to the calling objectThat's what happens, yes. The VALUE of k is returned, not the NAME k, so you cannot refer to the value by just k. To the caller, the value is obtained by evaluating the expression that calls the function. So you could do
    public class example2
         public int add(int i, int j)
              return i + j;
         public static void main(String[] args)
              example2 obj = new example2();
              System.out.println(obj.add(2, 3));
    }

  • Can we use Loop Statement for Ranges

    Hi Friends,
    I have a range say R_Range. I need to loop at each line item and get the values in another range R_New_Range, i have to count the number of items in R_new_range. How is it possible.
    I know range is nothing but an internal table. So we can direcly use Move statements or so ...,
    But my question is .....
    My R_range has values as below
    'I' 'EQ' '001'
    'I' 'EQ' '002'
    'I' 'BT' '003' '007'
    'I' 'EQ' '008'
    I have to move all these values to R_New_range and my count of items should be '8'.
    How can i do that????????
    Expecting ur answers....
    Thanks in advance
    Cheers,
    R.Kripa.

    hey friends,
    Its nice to see the replies.... but i think i had confused u all with the question
    Now i'll explain u all in detail ....
    See i have 15000 projects ( eg., AAA111... ) and 100 GL accounts ( eg., 123443... ) .....
    I have to get the costs from COSS and COSP tables for all the projects - GL account combinations which leads to some 1500000 entries ..... So it is giving me a SQL Dump "DBIF_RSQL_INVALID_RSQL" .........
    Description of the Dump is
    Error in the module RSQL accessing the database interface
    An exception occurred. This exception is dealt with in more detail below
    . The exception, which is assigned to the class 'CX_SY_OPEN_SQL_DB', was
    neither                                                                
    caught nor passed along using a RAISING clause, in the procedure        
    "GET_COSP_COSS" "(FORM)"                                               
    Since the caller of the procedure could not have expected this exception
    to occur, the running program was terminated.                          
    The reason for the exception is:                                        
    The SQL statement generated from the SAP Open SQL Statement violates a  
    restriction imposed by the database system used in R/3.                                                                               
    Possible errors:                                                        
    o The maximum size of an SQL statement has been exceeded.              
    o The statement contains too many input variables.                     
    o The space needed for the input data exceeds the available memory.    
    o ...                                                                               
    You can usually find details in the system log (SM21) and in the        
    developer trace of the work process (ST11).                             
    If an error occurs the developer trace often informs you about the      
    current restrictions.                                                   
    So now i want to fine tune the program so that the execution works perfectly and get me the values for all the data 1500000 :-|
    Now :
    My Projects are stored in the form of a range R_Range
    I have to loop at this range and then process 100 records at a time and then again take other 100 records .... i'll count till 100 records by getting loopaing at the range and for each loop pass i'll increment the counter ....
    I am clear till this .....
    If record consist of 'EQ' option .... then ofcourse we can consider the total record to be 1 record and we can add 1 to counter ......
    But if the record consist of 'BT' option ...... then how can we loop that and get the number of -low numbers in that range and add to my counter ????
    Hope iam clear with my question
    If not do revert back ....
    Thanks in advance for the replies
    Cheers,
    R.Kripa.
    My Doubt is ....

  • How do we use if statement in labview?moreover can i use if statement inside for loop?

    how do we use if statement in labview?moreover can i use if statement inside for loop?

    The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
    Attachments:
    For_Loop_with_Case.jpg ‏21 KB

  • Can we use Perform statement in start routine ,Form and endform.

    Hi,
    Can we use Perform statement in start routine ? Then write the ABAP code between Form and Endform.
    Example : Can I use Perform ABC in start routine. Then define ABC at the end of start routine.
          Form ABC,
          ......<ABAP> code .....
          Endform.

    Hi,
    In BI 7.0 we have start routines defined using Class where you might be able to create your own performs, but in case of BW3.5 Start routines are defined using Form so there I don't think it will allow you to create one more form.
    But you can surely try both the approaches.
    Reards,
    Durgesh.

  • Using return statement in jsp

    Hi all,
    I am using return statement in JSP page after a redirect to stop executing that page. If the data bean is not present then it must go to previous page. When this return statement is executed the previous page is displayed but url in browser remains same. Why it is so ?. Is there any other way to tell a JSP page to stop executing and redirect to another page.
    rgds
    Antony Paul

    Hi Antony,
    do you use the "forward()" method or the "redirect()" method???
    rgds
    Howy

  • Can I use case statements in triggers?

    I created this trigger, it works BUT I don't like those parentheses at the begining, I would like
    to change those parentheses for case statements, well that is my question, can you use case statements in triggers, how you would translate the following in case statement?
    FOR EACH ROW
    WHEN ( (new.sgbstdn_levl_code = 'UG')
    and
    ( (NEW. SGBSTDN_STST_CODE NOT IN ('GR','SA','AS','IS') )
    OR
    ( (NEW. SGBSTDN_STST_CODE = 'IS' ) AND
    (NEW. SGBSTDN_STYP_CODE IN ('N' , 'T' )) AND
    (OLD. SGBSTDN_STST_CODE = 'AS' ) ) ) )
    ==================================================================================================
    CREATE OR REPLACE TRIGGER CC_STUD_WITHDRAWAL
    AFTER UPDATE OR INSERT ON SATURN . SGBSTDN
    FOR EACH ROW
    WHEN ( (new.sgbstdn_levl_code = 'UG')
    and
    ( (NEW. SGBSTDN_STST_CODE NOT IN ('GR','SA','AS','IS') )
    OR
    ( (NEW. SGBSTDN_STST_CODE = 'IS' ) AND
    (NEW. SGBSTDN_STYP_CODE IN ('N' , 'T' )) AND
    (OLD. SGBSTDN_STST_CODE = 'AS' ) ) ) )
    DECLARE
    v_params gokparm.t_parameterlist;
    event_code gtveqnm.gtveqnm_code%TYPE;
    firstname spriden.spriden_first_name%TYPE;
    lastname spriden.spriden_last_name%TYPE;
    middlename spriden.spriden_mi%TYPE;
    id spriden.spriden_id%TYPE;
    CURSOR get_stud_name IS
    SELECT
    spriden_id ,
    spriden_last_name ,
    spriden_first_name ,
    spriden_mi
    FROM
    saturn.spriden
    WHERE spriden_pidm = :NEW.SGBSTDN_PIDM
    AND spriden_change_ind IS NULL;
    BEGIN
    IF goksyst . f_isSystemLinkEnabled ( 'WORKFLOW' ) THEN
    event_code := SUBSTR ( gokevnt.F_CheckEvent ( 'WORKFLOW' ,'CC_STUDENT_WITHDRAW' ),1,20);
    OPEN get_stud_name ;
    FETCH get_stud_name INTO id , lastname , firstname , middlename ;
    CLOSE get_stud_name ;
    ----pass parameters to the event
    v_params ( 1 ).param_value := 'CC_STUDENT_WITHDRAW' ;
    v_params ( 2 ).param_value := '' ;
    v_params ( 3 ).param_value := 'Student Withdrawal:' || lastname || ',' || firstname || ' ' ||
    middlename ;
    v_params ( 4 ).param_value := :NEW.sgbstdn_pidm ;
    v_params ( 5 ).param_value := id ;
    v_params ( 6 ).param_value := lastname ;
    v_params ( 7 ).param_value := firstname ;
    v_params ( 8 ).param_value := middlename ;
    v_params ( 9 ).param_value := :NEW.sgbstdn_term_code_eff ;
    v_params ( 10 ).param_value := :NEW.SGBSTDN_STST_CODE ;
    v_params ( 11 ).param_value := :NEW.SGBSTDN_STYP_CODE ;
    gokparm.Send_Param_List ( event_code , v_Params );
    END IF;
    END;
    /

    You could delete a fair number of extraneous parentheses.
    CREATE OR REPLACE TRIGGER cc_stud_withdrawal
      AFTER UPDATE OR INSERT
      ON saturn.sgbstdn
      FOR EACH ROW
      WHEN     NEW.sgbstdn_levl_code = 'UG'
           AND (   NEW.sgbstdn_stst_code NOT IN ('GR', 'SA', 'AS', 'IS')
                OR (    NEW.sgbstdn_stst_code = 'IS'
                    AND NEW.sgbstdn_styp_code IN ('N', 'T')
                    AND OLD.sgbstdn_stst_code = 'AS'))

  • Can i use select statements in LDB

    Hai All,
       Can i use select statements and internal table in a LDB program.
    my requirement is that if i enter company code , fiscal year and reporting periods.
    generally fiscal year will be jan to dec.but in my requirement the fiscal year is apr of previous year to march of currentyear.
    so as i require the last years data can iuse select statement in that ldb program or is there any solution for this.
    Thanks in Advance
    kiran

    Hi Kiran,
    To retrive records from ldb you have to use the
    GET <node> statement. This will invoke the selection screen of the node. An alternate solution is to use the function module LDB_PROCESS.
    Please see the following link for help and example
    http://help.sap.com/saphelp_nw04/helpdata/en/64/237f8cd43711d1950b0000e8353423/content.htm
    Thanks
    Vinod

  • Can we use IF statement in PDF templates

    Hi,
    I developed a PDF template. I need to underline ang bold the records based on a specific condition. Can we use IF conditon in PDF templates. Please suggest.
    Thanks...

    Billy  Verreynne  wrote:
    The case syntax is a bit funny though as there's not a single condition evaluation (like a DECODE or case structs from some other languages).
    This is what I would expect a typical case struct to look like - evaluating a single condition:
    case <condition>
    when <value-1> then return <result-1>
    when <value-n> then return <result-n>
    else
    return <return-z>
    end
    ?:| You mean like this...?
    SQL> ed
    Wrote file afiedt.buf
      1  select empno, ename, deptno
      2        ,case deptno
      3           when 10 then 'This is Department 10'
      4           when 20 then 'And department 20'
      5           when 30 then 'And of course department 30'
      6         else
      7           'Blimey it is something else!'
      8         end as dept_desc
      9* from emp
    SQL> /
         EMPNO ENAME          DEPTNO DEPT_DESC
          7369 SMITH              20 And department 20
          7499 ALLEN              30 And of course department 30
          7521 WARD               30 And of course department 30
          7566 JONES              20 And department 20
          7654 MARTIN             30 And of course department 30
          7698 BLAKE              30 And of course department 30
          7782 CLARK              10 This is Department 10
          7788 SCOTT              20 And department 20
          7839 KING               10 This is Department 10
          7844 TURNER             30 And of course department 30
          7876 ADAMS              20 And department 20
          7900 JAMES              30 And of course department 30
          7902 FORD               20 And department 20
          7934 MILLER             10 This is Department 10
    14 rows selected.

  • Can I use if statement in SQL???

    Hello everyone.
    I know that this is a silly question. The answer is no. Instead I should use decode function.
    But what if I dont know all possible outcomes, can I still use decode function?
    Also, I have created a view, in the where clause i want to use if statement. Is it possible to do?
    Thanks in advance,
    Sonya

    here is the view that I created:
    create or replace view import_shipment2
    ( order_no, cust_no,ORDER_SUFFIX,ship_addr1,ship_addr2, city,state,ZIP,country, terms_cd,shipvia_cd,
    freight_cd, shipto_cdoehead,shipto_cdshipto,ship_name,ship_attn,order_status, org_unit_id, order_date,
    estship_dt,confirm_status,gross_inv_value,phone,total_line_no,total_qty_order,total_qty_shipped,
    total_qty_backordered,service,hold_cd,invno)
    as select
    to_char(c.order_no)||'_'||c.ORDER_SUFFIX, c.cust_no,c.ORDER_SUFFIX,d.ship_addr1,
         d.ship_addr2, b.city, b.state, b.zip_code,b.country, d.terms_cd,d.shipvia_cd,d.freight_cd, d.shipto_cd,b.shipto_cd,
         nvl(d.ship_name,b.shipto_attn), nvl2(d.ship_attn,b.shipto_attn,e.contact),d.order_status, d.org_unit_id,
         d.order_date, d.estship_dt, c.confirm_status, f.gross_inv_value ,nvl(d.shipto_recip_phone ,g.phone_no),
         sum(c.line_no),sum(c.qty_order),sum(c.qty_shipped),sum(c.qty_bo),d.shipvia_cd ,d.hold_cd,d.invno
    from shipto_test b, oehead_test d,oedetl_test c, oesummary_test f ,CONTACT_MASTER_TEST e ,CONTACT_PHONE_TEST g
    where c.order_no=d.order_no
    and b.cust_no=d.cust_no
    and b.shipto_cd=d.shipto_cd
    and d.cust_no=f.cust_no
    and d.order_no=f.order_no
    and d.org_unit_id in ('110','120')
         and e.cust_no=d.cust_no
    and e.shipto_cd= d.shipto_cd
    and d.order_status in ('J','S')
    and g.contact_id=e.contact_id
    and g.phone_type='Business'
    Group by
    to_char(c.order_no)||'_'||c.ORDER_SUFFIX, c.cust_no,c.ORDER_SUFFIX,d.ship_addr1,
         d.ship_addr2, b.city, b.state, b.zip_code,b.country, d.terms_cd,d.shipvia_cd,d.freight_cd, d.shipto_cd,b.shipto_cd,
         nvl(d.ship_name,b.shipto_attn), nvl2(d.ship_attn,b.shipto_attn,e.contact),d.order_status, d.org_unit_id,
         d.order_date, d.estship_dt, c.confirm_status, f.gross_inv_value ,nvl(d.shipto_recip_phone ,g.phone_no),
         d.shipvia_cd ,d.hold_cd,d.invno;
    I need to do the validation of the g.phone_type. Does phone number exist at all in table?
    How do I all PL/SQL to this view??
    Thanks once agin,
    Sonya

  • Unreachable statement error occured while using return statement.

    Consider this code
    class q25{
         public static void main(String args[]){
              amethod(args);
         public static void amethod(String args[]){
              String str;
              try{
                   str = "Hello "+args[0];
                   System.out.println(str);
                   System.out.println("Returning to caller");
                   System.exit(0);
              catch(Exception e){
                   System.out.println("Exception ocured");
                   System.exit(0);          
              finally{
                   System.out.println("In finally");
              System.out.println("At the end of method");     
    }Above code compiles and runs successfully without any errors.
    Now consider below code which is same as above one except "System.exit(0)" statements were replace by "return" statements. Below code when compiled gives error as
    "q25.java:22: unreachable statement
    System.out.println("At the end of method");
    ^
    1 error"
    One thing i didn't understood in this context that, the above code when compiled should get same error as stated above. But not. It is obvious that presence of System.exit(0) must generate unreachable statement same as when it is replaced by "return" statement. What is the difference in getting the error for above but not for below code. Pls anyone help.
    class q25{
         public static void main(String args[]){
              amethod(args);
         public static void amethod(String args[]){
              String str;
              try{
                   str = "Hello "+args[0];
                   System.out.println(str);
                   System.out.println("Returning to caller");
                   return;
              catch(Exception e){
                   System.out.println("Exception ocured");
                   return;     
              finally{
                   System.out.println("In finally");
              System.out.println("At the end of method");     
    }

    warnerja wrote:
    masijade. wrote:
    Since you have a "return" in both the try and the catch portions of the try/catch block *(the second of which you should never do)* , anything thing that comes after the try/catch/finally blocks will be unreachable.That is not true. There are plenty of reasons to return from a catch block. If you handle the exception instead of rethrowing it or another exception, then you'll need a return somehow, either there or after the catch block. What you should never do is "return" in a finally block, because that will mask any exception in flight about to be thrown to the caller.Perhaps masijade's use of never is too strong, but I too prefer/tend to avoid using return anywhere in try/catch/finally to avoid potential gotchas. Consider:
    public class TryCatchFinally
      public Data process(String s)
        Data returnData = new Data();
        try
          returnData.value = Integer.parseInt(s);
          returnData.message = "Success";
          return returnData;
        catch (Exception ex)
          returnData.value = -1;
          returnData.message = "Fail";
          return returnData;
        finally
          returnData.value = 42;
          returnData.message = "?";
      public static void main(String[] args)
        TryCatchFinally demo = new TryCatchFinally();
        Data d = demo.process("2");
        System.out.println(d.message + ": " + d.value);
        d = demo.process("2.1");
        System.out.println(d.message + ": " + d.value);
      class Data
        int value = 0;
        String message = "";
    }

  • Can I use if statement in side FIX

    Can I use like this..would this improve better performance.<BR>Say dimension, Temp has member1,member2 and member3<BR><BR>FIX ("Member1","Member2")<BR>IF(@ISMBR(("net"))"403"*0.20;<BR>ENDIF;<BR>ENDFIX<BR><BR>instead of <BR><BR>IF (@ISMBR("Member1","Member2"))<BR>IF(@ISMBR((""net"))"403"*0.20;<BR>ENDIF;<BR>ENDIF;

    <p>Yes you can.</p><p> </p><p>Try using this</p><p> </p><p>  <span style=" color: #ff9933;">  FIX("Member1","Member2")   </span></p><p>         <spanstyle=" color:#ff9933;"> "net"(    </span></p><p>    <span style=" color:#ff9933;">            IF(@ISMBR(("net"))</span></p><p><span style=" color:#ff9933;">                    "403"*0.20;</span></p><p><span style=" color:#ff9933;">                ENDIF;</span></p><p><span style=" color:#ff9933;">            )</span></p><p><span style=" color:#ff9933;">    ENDFIX</span></p>

  • Can I use return table in non-cumulative cubes upd rules?

    hi,
    Is it possible to use return table in non-cumulative cubes upd rules?
    What I mean is:
    In non-cumulative cubes I need to use Automatic Time Conversion for time chars and when I use return table I have to map fields from comm structure to return table.
    I am designing stock cube (with granularity on storage bin and quant level) where material movement data is took from Transfer Order docs. Data for source and target storage bin are in one document item, so I have to split each record.
    Regadrs,
    Andrzej
    ps. Maybe somebody has some technical documentation on Automatic Time Conversion?

    Hello Andrez,
      May be this code will be useful for you.
    *data decleration
    data: num type i,
          num1(2) type c,
    *variable for fiscper
          lv_fiscper type RSFISCPER,
    *variable for the calendar month
          lv_calmonth type RSCALMONTH,
    *variable for the period
          lv_period type T009B-POPER,
    *variable for the fiscal year
          lv_year type T009B-BDATJ,
    *variable to find out the calendar quarter
          lv_month TYPE RSCALMONTH,
          lv_calquarter type RSFO_CALQUARTER.
    *ICUBE_VALUES contain data for cube.Put these value into RESULT_TABLE
    RESULT_TABLE = ICUBE_VALUES.
    *add 12 times entry into result_table for 12 months
    do 12 times.
    append RESULT_TABLE.
    enddo.
    *processing for the split the value into 12 periods
    loop at RESULT_TABLE.
    num = num + 1.
    num1 = num.
    *divide the value by 12 for each month
      RESULT_TABLE-/BIC/ISMPLNRV = COMM_STRUCTURE-/BIC/ISMPLNRV / 12.
      RESULT_TABLE-CRM_CURREN = COMM_STRUCTURE-CRM_CURREN.
    case strlen( num1 ).
    WHEN 1.
    concatenate  RESULT_TABLE-fiscyear '00' num1 into lv_fiscper.
    RESULT_TABLE-fiscper = lv_fiscper.
    WHEN 2.
    concatenate  RESULT_TABLE-fiscyear '0' num1 into lv_fiscper.
    RESULT_TABLE-fiscper = lv_fiscper.
    endcase.
    lv_period = lv_fiscper+4(3).
    lv_year = lv_fiscper(4).
    *find out the calendar month from the period and year
    CALL METHOD CL_RSAR_FUNCTION=>FISCPER_CALMONTH
      EXPORTING
        I_FISCPER  = lv_PERIOD
        I_FISCVRNT = 'Z9'
        I_YEAR     = LV_YEAR
       I_CASE     = 0
      IMPORTING
        E_CALMONTH = lv_calmonth
    RESULT_TABLE-CALMONTH = lv_calmonth.
    *find out the calendar quarter from the fiscper
    concatenate lv_fiscper0(4) lv_fiscper5(2) into lv_month.
    *find out the calendar quarter
      if not lv_month is initial.
        CALL METHOD CL_RSAR_FUNCTION=>MONTH_QUARTER
          EXPORTING
            I_MONTH   = lv_month
          IMPORTING
            E_QUARTER = lv_calquarter.
        if sy-subrc <> 0.
          lv_calquarter = '00000'.
        endif.
      else.
        lv_calquarter = '00000'.
      endif.
      RESULT_TABLE-CALQUARTER = lv_calquarter.
      modify RESULT_TABLE.
    endloop.
    Regards
    Gopal

  • Can i use returning  with insert?

    Hi,
    when i am using following code in my procedure I am getting error
    Insert into employees ( employee_id,last_name) (select employee_id,last_name from employees) returning bulk collect into var_list_emp_id,
    var_list_last_name;
    sql command not properly ended ..
    can you suggest am I wrong?
    Thanks and Regards,
    Pradeep

    Check this link for syntax of Insert statement.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#SQLRF01604
    Regards
    Raj

  • Can not use prepared statement

    i am using a prepared statement for the following query but the query does not give me an output where as if i use a create statement i am getting my result
    can any one say why is it ? or what the problem is
                String strQuery = " select lic.lic_id  licId, "+                                                   " lic.license_nbr licNo, "+                                                   " lt.display_desc licType "+                                                   " from colamgr.cola_entities ent, "+                                                 " colamgr.cola_licenses lic, "+                                                 " colamgr.cola_lic_types lt, "+                                                 " colamgr.cola_boards    boa "+                                           " where (( 'E'= ? and ent.ent_id = ?) "+                                           " or ( 'L'= ? and lic.lic_id = ?)) "+                                           " and lic.ent_id = ent.ent_id "+                                           " and lic.license_status ='ACTIVE' "+                                           " and lic.lt_id = lt.lt_id "+                                           " and boa.boa_id = lt.boa_id "+                                           " and (( 'E' = ? and (lt.print_ent_addr_ind <> 'N' "+                                           " or (lt.print_lic_addr_ind <> 'N' and lic.addr1 is null))) "+                                           " or  ( 'L' = ? and lt.print_lic_addr_ind <> 'N')) "+                                           " UNION "+                                           " select  empl_lic.lic_id  licId, "+                                                   " empl_lic.license_nbr licNo, "+                                                   " empl_lt.display_desc licType "+                                                                                     " from colamgr.cola_entities  ent, "+                                                 " colamgr.cola_licenses  lic, "+                                                 " colamgr.cola_lic_types lt, "+                                                 " colamgr.cola_lic_xrefs lx, "+                                                 " colamgr.cola_licenses  empl_lic, "+                                                 " colamgr.cola_lic_types empl_lt, "+                                                 " colamgr.cola_boards    empl_boa "+                                           " where (( 'E'= ? and ent.ent_id = ?) "+                                           " or ( and lic.lic_id = ? and 'L'= ? )) "+                                           " and lic.ent_id              = ent.ent_id "+                                           " and lic.lic_id              = lx.lic_id "+                                           " and lic.license_status      ='ACTIVE' "+                                           " and lx.approval_ind        = 'A' "+                                           " and lx.begin_date          is not null "+                                           " and lx.end_date            is null "+                                           " and lx.lic_id_child        = empl_lic.lic_id "+                                           " and empl_lt.lt_id          = empl_lic.lt_id "+                                           " and empl_boa.boa_id        = empl_lt.boa_id "+                                           " and empl_lic.license_status = 'ACTIVE' "+                                           " and lic.lt_id              = lt.lt_id "+                                           " and exists (select 1 "+                                                       " from colamgr.cola_lic_types lt1 "+                                                       " where lt1.lt_id = empl_lic.lt_id "+                                                       " and ((lt1.xref1_ind in ('M') "+                                                       " and  lt1.xref1_lt_id = lt.lt_id "+                                                       " and  (('E'= ? and (lt1.print_xref1_ent_addr_ind <> 'N' "+                                                       " or (lt1.print_xref1_lic_addr_ind <> 'N' and lic.addr1 is null))) "+                                                       " or    ( 'L' = ? and lt1.print_xref1_lic_addr_ind <> 'N'))) "+                                                       " or  (lt1.xref2_ind in ('M') "+                                                       " and  lt1.xref2_lt_id = lt.lt_id "+                                                       " and  (('E'= ? and (lt1.print_xref2_ent_addr_ind <> 'N' "+                                                       " or (lt1.print_xref2_lic_addr_ind <> 'N' and lic.addr1 is null))) "+                                                       " or    ( 'L' = ? and lt1.print_xref2_lic_addr_ind <> 'N'))) "+                                                       " or  (lt1.xref1_ind in ('O') "+                                                       " and  (lt1.xref1_lt_id = lt.lt_id or lt1.xref2_lt_id = lt.lt_id) "+                                                       " and  (('E'= ? and (lt1.print_xref1_ent_addr_ind <> 'N' "+                                                       " or (lt1.print_xref1_lic_addr_ind <> 'N' and lic.addr1 is null))) "+                                                       " or    ('L' = ? and lt1.print_xref1_lic_addr_ind <> 'N'))))) "+                                                       " order by 6 desc, 7 asc ";

    here is my code which works . when i replace the ? ( where i am checking strAddrtype ='L' using set string it doesn't work . i wanted to know why its not working any help is much appreciated.
    thanks .
            public ArrayList getReprintLicenses(String strEntId, String strLicId, String strAddrType)
              ArrayList alMasterLicList = new ArrayList();
               String strQuery = " select lic.lic_id   licId, "+
                                                     " lic.license_nbr licNo, "+
                                                     " lt.display_desc licType, "+
                                                     " colamgr.COLA_CHK_RENEW_STAT(lic.lic_id) renewStatus, "+
                                                     " 0, "+
                                                     " SUBSTR(lic.License_nbr,1,4), "+
                                                     " SUBSTR(lic.License_nbr,5) "+
                                              " from cola_entities ent, "+
                                                   " cola_licenses lic, "+
                                                   " cola_lic_types lt, "+
                                                   " cola_boards    boa "+
                                              " where ((?= 'E' and ent.ent_id = ? ) "+
                                              " or ("+strAddrType+" = 'L' and lic.lic_id = ?)) "+
                                              " and lic.ent_id = ent.ent_id "+
                                              " and lic.license_status ='ACTIVE' "+
                                              " and lic.lt_id = lt.lt_id "+
                                              " and boa.boa_id = lt.boa_id "+
                                              " and ((?= 'E' and (lt.print_ent_addr_ind <> 'N' "+
                                              " or (lt.print_lic_addr_ind <> 'N' and lic.addr1 is null))) "+
                                              " or   ("+strAddrType+" = 'L' and lt.print_lic_addr_ind <> 'N')) "+
                                              " UNION "+
                                              " select  empl_lic.lic_id  licId, "+
                                                      " empl_lic.license_nbr licNo, "+
                                                      " empl_lt.display_desc licType, "+
                                                      " COLA_CHK_RENEW_STAT(empl_lic.lic_id) renewStatus, "+
                                                      " 1, "+
                                                      " SUBSTR(lic.License_nbr,1,4), "+
                                                      " SUBSTR(lic.License_nbr,5) "+
                                              " from cola_entities  ent, "+
                                                   " cola_licenses  lic, "+
                                                   " cola_lic_types lt, "+
                                                   " cola_lic_xrefs lx, "+
                                                   " cola_licenses  empl_lic, "+
                                                   " cola_lic_types empl_lt, "+
                                                   " cola_boards    empl_boa "+
                                              " where ((? = 'E' and ent.ent_id =?) "+
                                              " or ("+strAddrType+" = 'L' and lic.lic_id =?)) "+
                                              " and lic.ent_id              = ent.ent_id "+
                                              " and lic.lic_id              = lx.lic_id "+
                                              " and lic.license_status      ='ACTIVE' "+
                                              " and lx.approval_ind         = 'A' "+
                                              " and lx.begin_date           is not null "+
                                              " and lx.end_date             is null "+
                                              " and lx.lic_id_child         = empl_lic.lic_id "+
                                              " and empl_lt.lt_id           = empl_lic.lt_id "+
                                              " and empl_boa.boa_id         = empl_lt.boa_id "+
                                              " and empl_lic.license_status = 'ACTIVE' "+
                                              " and lic.lt_id               = lt.lt_id "+
                                              " and exists (select 1 "+
                                                          " from cola_lic_types lt1 "+
                                                          " where lt1.lt_id = empl_lic.lt_id "+
                                                          " and ((lt1.xref1_ind in ('M') "+
                                                          " and  lt1.xref1_lt_id = lt.lt_id "+
                                                          " and  ((? = 'E' and (lt1.print_xref1_ent_addr_ind <> 'N' "+
                                                          " or (lt1.print_xref1_lic_addr_ind <> 'N' and lic.addr1 is null))) "+
                                                          " or    (?= 'L' and lt1.print_xref1_lic_addr_ind <> 'N'))) "+
                                                          " or   (lt1.xref2_ind in ('M') "+
                                                          " and  lt1.xref2_lt_id = lt.lt_id "+
                                                          " and  ((?= 'E' and (lt1.print_xref2_ent_addr_ind <> 'N' "+
                                                          " or (lt1.print_xref2_lic_addr_ind <> 'N' and lic.addr1 is null))) "+
                                                          " or    (? = 'L' and lt1.print_xref2_lic_addr_ind <> 'N'))) "+
                                                          " or   (lt1.xref1_ind in ('O') "+
                                                          " and   (lt1.xref1_lt_id = lt.lt_id or lt1.xref2_lt_id = lt.lt_id) "+
                                                          " and  ((? = 'E' and (lt1.print_xref1_ent_addr_ind <> 'N' "+
                                                          " or (lt1.print_xref1_lic_addr_ind <> 'N' and lic.addr1 is null))) "+
                                                          " or    (? = 'L' and lt1.print_xref1_lic_addr_ind <> 'N'))))) "+
                                                          " order by 6 desc, 7 asc ";
              try
                con = getDSconn();
         //  stmt = con.createStatement();
              pstmt=con.prepareStatement(strQuery);
               // rs = stmt.executeQuery(strQuery);
            pstmt.setString(1,strAddrtype);
             pstmt.setString(2,strEntId);
             pstmt.setString(3,strLicId);
             pstmt.setString(4,strAddrtype);
             pstmt.setString(5,strAddrtype);
             pstmt.setString(6,strEntId);
             pstmt.setString(7,strLicId);
             pstmt.setString(8,strAddrtype);
             pstmt.setString(9,strAddrtype);
             pstmt.setString(10,strAddrtype);
             pstmt.setString(11,strAddrtype);
    pstmt.setString(12,strAddrtype);
    pstmt.setString(13,strAddrtype);
              rs=pstmt.executeQuery();
                while (rs.next())
                  LicenseeForm licenseInfo = new LicenseeForm();
                  licenseInfo.setLicId(rs.getString(1));
                  licenseInfo.setLicNo(rs.getString(2));
                  licenseInfo.setLicType(rs.getString(3));
                  //licenseInfo.setBoard(rs.getString(4));
                  licenseInfo.setRenewStatus(rs.getString(4));
                  alMasterLicList.add(licenseInfo);
                rs.close();
                pstmt.close();
                con.close();
                con = null;
              catch (RuntimeException re)
                    throw re;
              catch(Exception e)
              { e.printStackTrace();
                try
                  rs.close();
                  pstmt.close();
                  con.close();
                  con = null;
                catch(Exception i){}
              finally
                try
                  pstmt.close();
                  con.close();
                  con = null;
                catch(Exception i){}
              return alMasterLicList;     
           

Maybe you are looking for