Passing a List to a method?

Hello,
I'm having problems sending a List to a method.
To declare the list, I wrote:
List<Integer> deck = new List<Integer>();
To pass it, I wrote:
keyStream(deck);
And the keyStream method is:
*public int keyStream(List deck) {*
*          return findTop(deck);*
This is just a short snippet of my entire code, but in each case that I try to pass the method, the error has an arrow pointing to the word List. Am I forgetting something big? I just started programming again, I took a break over the summer, so it's all coming back to me.
Thanks

import java.util.ArrayList;
import java.util.List;
public class ListExample {
    public void f() {
        List < Integer > list = new ArrayList < Integer > ();
        g(list);
    public void g(List < Integer > list) {
}java.util.List is an interface. You can't instantiate an interface.

Similar Messages

  • Passing Select-Option to OO method via parameter list

    Is it possible to pass a reference to a select-option through the parameter list of a method such that the parameter can be used in a "where clause" using the conventional "IN" operator?  If so, how should the parameter be typed? 
    Thanks in advance,
    Philip Smith

    Sure, here's how.
    report zrich_0002 no standard page heading.
    tables: mara.
    *       CLASS lcl_app DEFINITION
    class lcl_app definition.
      public section.
        types: t_matnr type range of mara-matnr.
        data: imara type table of mara.
        methods: constructor importing im_matnr type t_matnr.
    endclass.
    *       CLASS lcl_app IMPLEMENTATION
    class lcl_app implementation.
      method constructor.
        select * into table imara from mara up to  100 rows
                     where matnr in im_matnr.
        check sy-subrc = 0.
      endmethod.
    endclass.
    data: myapp type ref to lcl_app.
    select-options: s_matnr for mara-matnr.
    start-of-selection.
      create object myapp
            exporting
                 im_matnr = s_matnr[].
    Welcome to SDN!.  Be sure to award points for helpful answers and mark your post as solved when solved completely.  Thanks.
    REgards,
    Rich Heilman

  • How to pass a list of parameters to a query?

    Hi,
    I use OracleXE 10 Database with JDeveloper 11g.
    In my project I use a Toplink mapping to get access to the database (Toplink Object Map file). This mapping xml file is called crmMap.xml.
    In the crmMap.xml file I define a mapping to a "User table" which has the four columns id (number), title (varchar2), firstName (varchar2) and lastName (varchar2). A title can have the four values Bachelor, Master, Doctor and Professor.
    I do define a query in crmMap.xml which has to find all the users that have a special title. I do give the query one parameter called "title" which has the type "java.util.ArrayList". The parameter "title" is a list that has for example the two values "Bachelor" and "Doctor", if I want to find all the users that are Bachelor or Doctor. The query looks like this ...
    Select * from User where title in(?title)I do use an EJB Session Bean to call the query. The code looks like this ...
    public List<User> findUserByStatus() {
        Session session = getSessionFactory().acquireSession();
        Vector params = new Vector(1);
        List stati = new ArrayList();
        stati.add("Doctor");
        stati.add("Bachelor");
        params.add(stati);
        List<User> result = (List<User>)session.executeQuery("findUserByStatus", User.class, params);
        session.release();
        return result;
    }Doing this I get an error, in the line
    List<User> result = (List<User>)session.executeQuery("findUserByStatus", User.class, params);while the app is trying to execute the query.
    Part of my log
    WARNING: ADFc: Invalid column type
    java.sql.SQLException: Invalid column type
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:116)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:177)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:233)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:407)
         at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7931)
         at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7511)
         at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8168)
         at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:8149)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:229)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.setPrimitiveParameterValue(DatabasePlatform.java:1694)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.setParameterValueInDatabaseCall(DatabasePlatform.java:1684)
         at oracle.toplink.platform.database.oracle.Oracle9Platform.setParameterValueInDatabaseCall(Oracle9Platform.java:339)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.setParameterValuesInDatabaseCall(DatabasePlatform.java:1669)
         at oracle.toplink.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:649)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:517)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:467)
         at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:447)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:179)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:250)
         at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:583)
         at oracle.toplink.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:467)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:674)
         at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
         at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:445)
         at oracle.toplink.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2260)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1074)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1058)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1032)
         at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:945)
         at de.virtual7.crmTL.model.crmFacadeBean.findUserByStatus(crmFacadeBean.java:720)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:15)
         at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
         at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:30)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:126)
         at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:114)
         at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
         at $Proxy90.findUserByStatus(Unknown Source)
         at de.virtual7.crmTL.model.crmFacade_etlagg_crmFacadeLocalImpl.findUserByStatus(crmFacade_etlagg_crmFacadeLocalImpl.java:838)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:563)
         at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2119)
         at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:2929)
         at oracle.adf.model.bean.DCBeanDataControl.invokeMethod(DCBeanDataControl.java:396)
         at oracle.adf.model.binding.DCInvokeMethod.callMethod(DCInvokeMethod.java:258)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1441)
         at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2126)
         at oracle.adf.model.bean.DCBeanDataControl.invokeOperation(DCBeanDataControl.java:414)
         at oracle.adf.model.adapter.AdapterDCService.invokeOperation(AdapterDCService.java:311)
         at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:697)
         at oracle.adf.model.binding.DCInvokeAction.refreshInternal(DCInvokeAction.java:46)
         at oracle.adf.model.binding.DCInvokeAction.refresh(DCInvokeAction.java:32)
         at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:2970)
         at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2639)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareModel(PageLifecycleImpl.java:110)
         at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.prepareModel(FacesPageLifecycle.java:77)
         at oracle.adf.controller.v2.lifecycle.Lifecycle$2.execute(Lifecycle.java:135)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:190)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.mav$executePhase(ADFPhaseListener.java:19)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.startPageLifecycle(ADFPhaseListener.java:229)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$1.after(ADFPhaseListener.java:265)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:69)
         at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:51)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:354)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:175)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:279)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:239)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:196)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:139)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:85)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:257)
         at oracle.security.jps.wls.JpsWlsSubjectResolver.runJaasMode(JpsWlsSubjectResolver.java:250)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:100)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    07.09.2009 11:50:16 oracle.adf.controller.faces.lifecycle.FacesPageLifecycle addMessage
    WARNUNG: ADFc: EJB Exception: : Lokaler Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 11g (11.1.1.0.1) (Build 081030)): oracle.toplink.exceptions.DatabaseException
    Interne Exception: java.sql.SQLException: Ungültiger Spaltentyp
    Fehlercode:17004
    Aufruf:Select * from User where title in(?title)
         bind => [[Doctor,Bachelor]]Does anyone know a way how to pass a list of parameters
    Thanks Bodhy

    Hi,
    One alternative way is to create String with , sepearted as pass the string to in clause.For example ,create a string ('Bachelor','Doctor') and pass this string to in clause.
    Session session = getSessionFactory().acquireSession();
    String params=( 'Bachelor','Doctor);
    List<User> result = (List<User>)session.executeQuery("findUserByStatus", User.class, params);
    session.release();
    This is an alternative way and workaround which can work for Strings .
    Or you can use EXpression to build the query to pass the collection as example given below.
    Expression addressExpression;
    ReadObjectQuery query = new ReadObjectQuery(Employee.class);
    ExpressionBuilder emp = query.getExpressionBuilder();
    addressExpression =
    emp.get("address").get("city").equal(
    emp.getParameter("employee").get("address").get("city"));
    query.setName("findByCity");
    query.setSelectionCriteria(addressExpression);
    query.addArgument("employee");
    Vector v = new Vector();
    v.addElement(employee);
    Employee e = (Employee) session.executeQuery(query, v);
    Hope this helps.
    Regards,
    Vinay Kumar

  • Passing argstrings[1] to another method

    Hello I want to pass argstrings[1] to another method. Other stuff is being passed there to. Before I passed argstrings[1] the other stuff worked, now it does not.
    Please tell me why I am getting compilation errors.
    Thanks
    public static void main(String[] argStrings)
            String filePath = null;
            if(argStrings.length != 0)
                 filePath = argStrings[0];
            else
                 System.out.println("Enter a directory please");// Else you have to enter a directory
                 Scanner scan = new Scanner(System.in);
                    filePath = scan.nextLine();
            String copyDate = argStrings[1];
            Date dateToLookFor = new Date(copyDate);
            listFiles(filePath);// this no longer works as of the new log(datetolookfor)
            log(dateToLookFor);// just wanna pass this to the next method
       private static void log(File[] files, Date dateToLookFor)
       {

    Well i only get one compile error, cheers.
    So please could you help me what i have to do to this mess in order for it to work:
    Or just edit the code as I dont think there is much to do:
    Thanks
    import java.lang.*;
    import java.io.*;
    import java.util.*;
    * This application identifies files which could potentially be archived
    * and copied. A file is to be archived if the last modified date is more
    * than 100 days ago. A file is to be copied if it has been modified since
    * a given time. Only nominated extensions are to be considered. The java.
    * util.Calendar class contains relevant methods for comparing times and dates.
    * For instance, a command line of: java CrawlerApp Knuth 2005-12-28 php html
    * Will nominate for archiving or copying only php or html files in the Knuth
    * directory tree. It will only nominate for copying files modified after
    * midnight on the 28th of December, 2005.
    * The output from this application is two files (called archive.txt and copy.txt)
    * containing the names of files to be archived, and those which may be copied.
    * The names will follow the convention specified in the create application.
    * These two text files must appear in the root directory (Knuth, in this example).
    public class Crawler
       public static void main(String[] argStrings)
            String name = null;
            if(argStrings.length != 0)
                 name = argStrings[0];
            else
                 System.out.println("Enter a directory please");// Else you have to enter a directory
                 Scanner scan = new Scanner(System.in);
                    name = scan.nextLine();
            String copyDate = argStrings[1];
            listFiles(name, copyDate);
       private static void log(String copyDate, File[] files)
            PrintStream archivePS = null;
            PrintStream copyPS = null;
            try
                 archivePS = new PrintStream("archive.txt");
                 copyPS = new PrintStream("copy.txt");
                 // instantiate cutoff Calendar instance to test files with
                   Calendar cutoff = Calendar.getInstance();
                   // time now
               Date now = new Date();
                   // set cutoff time with current time
                   cutoff.setTime(now);
                   // subtract 100 days from current time
                   cutoff.add(Calendar.DAY_OF_YEAR, -100);//
                 Calendar calendar = Calendar.getInstance();
                 for(int j = 0; j < files.length; j++)
                      // get last modified time of file
                      long lastModified = files[j].lastModified();
                      // convert lastModified to a date
                      Date lastMod = new Date(lastModified);
                      // set the time for the Calendar instance with lastMod
                      calendar.setTime(lastMod);
                      // test against cutoff Calendar instance variable
                     if(lastMod.before(cutoff.getTime()))
                           archivePS.println(files[j]);
                         if(lastMod.before(cutoff.getTime()))
                              copyPS.println(files[j]);
                         // I will do copy later, just want to see if this works
            catch(FileNotFoundException fnfe)
                 System.err.println("Log error: " + fnfe.getMessage());
            catch(IOException ioe)
                 System.err.println("I/O exception: " + ioe.getMessage());
       private static void listFiles(String name, String copyDate)
           File f = new File(name);// Try to get a list of files in the directory
           File[] files = f.listFiles();// Make array of all the files in that directory
           log(files, copyDate);
           if(f.isDirectory())// If the argStrings[0] is a directory then do the following
               File[] children = f.listFiles(HTMLfilter);// Make an array of html files
               System.out.println("HTML files in " + name + " directory = " + children.length);
               File[] phpFiles = f.listFiles(PHPFilter);// Make an array of php files
               System.out.println("PHP files in " + name + " directory = " + phpFiles.length);
       private static FileFilter HTMLfilter = new FileFilter()
           public boolean accept(File f)// Accept directory Knuth
               //if(f.isDirectory()) return true;
               String name = f.getName().toLowerCase();
               return name.endsWith("html");
               //if(file is 100 days old)
       private static FileFilter PHPFilter = new FileFilter()
            public boolean accept(File f)
                 //if(f.isDirectory()) return true;
                 String name = f.getName().toLowerCase();
                 return name.endsWith("php");
    }

  • Difficulty in using a variable to pass a list of names between 2 tables

    Hi All,
    I am trying to pass a list of names from one table as a variable to another table and trying to find the Highest level they exist at in the hierarchy. I am having some troubles with the variable and need some guidence and also if this should be a procedure or not.
    this is what i have now :
    Variable man_name Varchar;
    exec :man_name = (Select full_name from direct_manager_report)
    UPDATE direct_manager_report
    Set Manager_level_number =
    (Select 'Manager_Level_0' from manager_hierarchy where level_0_manager_name = man_name
    UNION
    Select 'Manager_Level_1' from manager_hierarchy where level_0_manager_name < > man_name AND level_1_manager_name = man_name
    UNION
    Select 'Manager_Level_2' from manager_hierarchy where level_1_manager_name < > man_name AND level_2_manager_name = man_name
    UNION
    Select 'Manager_Level_3' from manager_hierarchy where level_2_manager_name < > man_name AND level_3_manager_name = man_name
    Where full_name = man_name;
    Let me know what modifications have to be done for this the variable to get the name from table 1 and find the manager level from table 2 and populate it back in table 1.
    Any help is appreciated.
    Thanks

    Frank Kulash wrote:
    Hi,Thanks for your reply. I am sorry for not providing enough information.
    What's wrong with what you have now? I want to pass the manager name (about 2000) from direct_manager_report to the variable which i pass to manager_hierarchy table to find the highest level for each manager
    If it doesn't give the right results, then how is anyone except you to know what the right results are?
    Variable man_name Varchar;
    exec :man_name = (Select full_name from direct_manager_report)Does that really work for you?No thats why i said this is what i have and i am trying to see the best to past the list of manager names to get the level number.
    UPDATE direct_manager_report
    Set Manager_level_number =
    (Select 'Manager_Level_0' from manager_hierarchy where level_0_manager_name = man_name
    UNION
    Select 'Manager_Level_1' from manager_hierarchy where level_0_manager_name < > man_name AND level_1_manager_name = man_nameIt looks like something is missing on the line above. Did you mean "level_0_manager_name != man_name"?
    This site doesn't like to display the &lt;&gt; inequality operator. Always use the other (equivalent) inequality operator, !-, when posting here.
    UNION
    Select 'Manager_Level_2' from manager_hierarchy where level_1_manager_name < > man_name AND level_2_manager_name = man_name
    UNION
    Select 'Manager_Level_3' from manager_hierarchy where level_2_manager_name < > man_name AND level_3_manager_name = man_name
    Where full_name = man_name;Are you sure the UNION will never return more than 1 row?
    Let me know what modifications have to be done for this the variable to get the name from table 1 and find the manager level from table 2 and populate it back in table 1.Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data (in this case, the contents of table1 after everything is finished).
    See the forum FAQ {message:id=9360002}Sorry did not realize the missing !. Yes the union will always return one record for each manager name passed. I have tested the select part which hard coding the manager name and it does update the level number correctly. but i am struggling with passing a large list of values as a variable.
    This is the output i am looking for in the direct manager report table is :
    Manager Name | Manager Level Number
    ABC Manager Level 0
    XYZ Manager Level 1
    This is the structure of the manager hierarchy:
    Manager Level 0 Manager Level 1 Manager Level 2...Manager Level 14
    ABC ABC ABC ABC
    ABC XYZ XYZ XYZ
    Let me try the below but hopefully i am more clear on the requirement now.
    >
    You may want something like this
    MERGE INTO  direct_manager_report     dst
    USING   (
             SELECT    dmr.full_name
             ,           'Manager_Level_'
                    || MIN ( CASE  dmr.full_name
                                 WHEN  level_0_manager_name  THEN '0'
                                 WHEN  level_1_manager_name  THEN '1'
                                 WHEN  level_2_manager_name  THEN '2'
                                 WHEN  level_3_manager_name  THEN '3'
                               END
                     ) AS manager_level_number
             FROM      manager_hierarchy  dmr
             JOIN      manager_hierarchy      mh   ON   dmr.full_name IN ( level_0_manager_name
                                                                   , level_1_manager_name
                                                , level_2_manager_name
                                                , level_3_manager_name
             GROUP BY  dmr.full_name
         )                    src
    ON     ( dst.full_name  = src.full_name )
    WHEN MATCHED THEN UPDATE
    SET     dst.manager_level_number = src.manager_level_number
    Edited by: user599926 on Jun 4, 2013 9:41 PM

  • In BADi , How to pass the values between two Method

    Hi Experts,
    We have two methods in BADis. How to pass the value  between two Methods. Can you guys explain me out with one example...
    Thanks & Regards,
    Sivakumar S

    Hi Sivakumar!
    Create a function group.
    Define global data (there is a similiar menu point to jump to the top include).
    Create one or two function modules, with which you can read and write the global data.
    In your BADI methods you can access the global data with help of your function modules. It will stay in memory through the whole transaction.
    Regards,
    Christian

  • How to call a java method so I can pass a file into the method

    I want to pass a file into a java method method from the main method. Can anyone give me some help as to how I pass the file into the method - do I pass the file name ? are there any special points I need to put in the methods signature etc ?
    FileReader file = new FileReader("Scores");
    BufferedReader infile = new BufferedReader(file);
    Where am I supposed to put the above text - in the main method or the one I want to pass the file into to?
    Thanks

    It's a matter of personal preference really. I would encapsulate all of the file-parsing logic in a separate class that implements an interface so that if in the future you want to start taking the integers from another source, e.g. a db, you wouldn't need to drastically alter your main application code. Probably something like this, (with an assumption that the numbers are delimited by a comma and a realisation that my file-handling routine sucks):
    public class MyApp{
    public static void main(String[] args){
    IntegerGather g = new FileIntegerGatherer();
    Integer[] result = g.getIntegers(args[0]);
    public interface IntegerGatherer{
    public Integer[] getIntegers(String location);
    import java.io.*;
    public class FileIntegerGatherer implements IntegerGatherer{
    public Integer[] getIntegers(String location){
    FileInputStream fs=null;
    try{
    File f = new File(location);
    fs = new FileInputStream(f);
    byte[] in = new byte[1024];
    StringBuffer sb = new StringBuffer();
    while((fs.read(in))!=-1){
    sb.append(new String(in));
    StringTokenizer st = new StringTokenizer(sb.toString(),",");
    Integer[] result = new Integer[st.countTokens()];
    int count = 0;
    while(st.hasMoreTokens()){
    result[count]=Integer.valueOf(st.nextToken());
    count++;
    catch(IOException e){
    //something sensible here
    finally{
    if(fs!=null){
    try{
    fs.close();
    catch(IOException f){
    return result;
    Once compiled you could invoke it as java MyApp c:\myInts.txt
    Sorry if there are typos in there, I don't have an ide open ;->

  • How to pass a list as bind variable?

    How can I pass a list as bind variable in Oracle?
    The following query work well in SQL Developer if I set ":prmRegionID=2".
    SELECT COUNTRY_ID,
    COUNTRY_NAME
    FROM HR.COUNTRIES
    WHERE REGION_ID IN (:prmRegionID);
    The problem is that I can't find how to set ":prmRegionID=2,3".
    I know that I can replace ":prmRegionID" by a substitution variable "&prmRegionID". The above query work well with"&prmRegionID=2" and with "&prmRegionID=2,3".
    But with this solution, I lost all advantage of using binds variables (hard parse vs soft parse, SQL injection possibility, etc.).
    Can some one tell me what is the approach suggest by Oracle on that subject? My developer have work a long time too find how but didn't found any answer yet.
    Thank you in advance,
    MB

    Blais wrote:
    The problem is that I can't find how to set ":prmRegionID=2,3".Wrong problem. Setting the string bind variable to that means creating a single string that contains the text "+2,3+". THE STRING DOES NOT CONTAIN TWO VALUES.
    So the actual problem is that you are using the WRONG data type - you want a data type that can have more than a single string (or numeric) value. Which means that using the string (varchar2) data type is the wrong type - as this only contains a single value.
    You need to understand the problem first. If you do not understand the problem, you will not realise or understand the solution too.
    What do you want to compare? What does the IN clause do? It deals with, and compares with, a set of values. So it needs a set data type for the bind variable. A set data type enables you to assign multiple values to the bind variable. And use this bind variable for set operations and comparisons in SQL.
    Simple example:
    SQL> --// create a set data type
    SQL> create or replace type TStringSet is table of varchar2(4000);
      2  /
    Type created.
    SQL>
    SQL>
    SQL> var c refcursor
    SQL>
    SQL> --// use set as bind variable
    SQL> declare
      2          names   TStringSet;
      3  begin
      4          --// assign values to set
      5          names := new TStringSet('BLAKE','SCOTT','SMITH','KING');
      6 
      7          --// use set as a bind variable for creating ref cursor
      8          open :c for
      9                  'select * from emp where ename in (select column_value from TABLE(:bindvar))'
    10          using names;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> print c
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7698 BLAKE      MANAGER         7839 1981/05/01 00:00:00       2850                    30
          7788 SCOTT      ANALYST         7566 1987/04/19 00:00:00       3000                    20
          7369 SMITH      CLERK           7902 1980/12/17 00:00:00        800                    20
          7839 KING       PRESIDENT            1981/11/17 00:00:00       5000                    10
    SQL>
    SQL> --// alternative set comparison
    SQL> declare
      2          names   TStringSet;
      3  begin
      4          --// assign values to set
      5          names := new TStringSet('BLAKE','SCOTT','SMITH','KING');
      6 
      7          --// use set as a bind variable for creating ref cursor
      8          open :c for
      9                  'select * from emp where TStringSet(ename) submultiset of (:bindvar)'
    10          using names;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> print c
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 1980/12/17 00:00:00        800                    20
          7698 BLAKE      MANAGER         7839 1981/05/01 00:00:00       2850                    30
          7788 SCOTT      ANALYST         7566 1987/04/19 00:00:00       3000                    20
          7839 KING       PRESIDENT            1981/11/17 00:00:00       5000                    10
    SQL>

  • How to connect a graph to a list returned by method?

    Hi
    jdev 11.1.1.5
    How can I connect a graph to a list returned by method???

    This is my problem:
    I have a vo with several column and 2 more column that in these column I use analytic function to count (col1 and col2) .Know this vo return to many records . I want to have 2 graphs base on this column (col1 and col2) and one table base on all columns.
    after drag controler on page as graph because of repeated record with the same value in count column I have not good graph with distinct value.know I want to have a method that return a list or something can iterate and make graph on this .How Can I do ? Is it posible??
    (I use this aproach because do all transaction in one query)

  • How to pass table to in a method as a parameter

    Hi
    I need to pass one table in one method to another method as a parameter.
    ex: it_tab type zvalue(DDIC).
         send_mail( it_tab)like this i need to pass. How to do this.
    Please help me.
    Thanks & Regards
    SUN

    Hello,
    You'll need a table category that has the same structure of your internal table. Suppose you need to pass an internal table of type SCARR: you'll actually pass a parameter of type SCARR_TAB (look for it into tcode SE11).
    Remember that in a OOP scope, you cannot have header line in your internal tables.
    Regards,
    Andre

  • Pass a list of items as a parameter.

    Can I pass a list of items as a parmeter?  For example, I would like to send a list of three states, then use that parameter in my record selection to select all customers in any of the three states.
    I am using CR Developer 2008, Full version, 12.0.0.683, with Visual Studio 2008 (c# & WPF)

    found it on my own.

  • Pass a list of number values to a pl/sql function

    I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause. Ideally I would like to do the following:
    CREATE OR REPLACE FUNCTION ( dept_list in varchar2) is
    begin
    select ... where dept in (dept_list) ;
    usage: process_list ( '7730,7735,7740,7745') ;
    I can not find an example of doing this in pl/sql function but it seems feasible.
    Is there a way to do this?

    user12088323 wrote:
    I would like to pass a list of number values to a pl/sql function where the list will be used in an IN clause.
    usage: process_list ( '7730,7735,7740,7745') ;The first thing is you need an appropriate data type to store a list of numbers. A single character value that looks to you like a list of numbers, is not in fact a list of numbers but a single character value.
    This example uses the built in data type odcinumberlist in a procedure, you can do the same in function
    Re: Passing an array to an Oracle stored procedure
    If you have an old version of the database you may need to create your own type with the same definition of odcinumberlist.

  • Passing a list into a sql procedure via a unix shell.

    9.2.0.6
    for some dumb reason we cannot use java to do this task.
    anyways
    I need to build a list of all file in a particular directory. The list could be zero to very very long. I would like to be able to pass that list to a PL/SQL procedure.
    this is in unix
    I think I could do something like
    var=f1,f2,f3,f4
    sqlplus blah/blah $var
    exec my_proc(&var);
    I guess that would handle up to 32k in length. It would be up to me to parse the list.
    I am really looking for an way to do this a bit slicker.. like with a ref cursor but I seem to be getting stuck.
    Thanks

    Some examples here :
    Re: How to pass Character parameter
    Nicolas.

  • What is the use of passing String[] args in main() method?

    what is the use of passing String[] args in main() method?
    Is there any specific use for this ?

    actually my sir asked me the same question & I gave
    the same reply as given by you........but he further
    asked what is the use of this also??
    ie accepting cmd line args at runtime??is there any
    specific purpose ??Apart from the one you just mentioned? No

  • Passing select-options value in method

    How to pass select-options value in method ?
    Example:
    Select-options: carrid for spfli-carrid.
    class cl_myclass implementation.
    select  carrid connid from
    spfli where carrid in carrid.
    endclass.
    Thanks

    Hello Anee
    The coding of this functionality is quite simple:
    REPORT zmy_report.
    DATA:  go_myclass   TYPE REF TO zcl_myclass,
               gd_repid         TYPE syst-repid.
    PARAMETERS:
      p_bukrs   ...
    SELECT-OPTIONS:
      o_kunnr  ...
    START-OF-SELECTION.
      gd_repid = syst-repid.
      CREATE OBJECT go_myclass
        EXPORTING
          id_calling_program = gd_repid.
    And that's how your CONSTRUCTOR method should look like:
    METHOD constructor.  " IMPORTING parameter id_calling_program
    CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
      EXPORTING
        CURR_REPORT = id_calling_report
      TABLES
        SELECTION_TABLE = me->mt_selopts.
    " NOTE: define mt_selopts as instance attribute of table type RSPARAMS_TT
    ENDMETHOD.
    Finally you have to extract the parameter and select-options from MT_SELOPTS.
    Regards
      Uwe

Maybe you are looking for