Arrays of arrays or list of arrays?

Hi!
I've spent 2+ hours now trying to figure this out/browsing the web.
I have x number of rows in db, and now I'm trying to convert this data to an array.
Like this:
String foo[] = null;
Array unordered[];
int i=0;       
while(ResultSet.next()){
   foo = new String[]{  ResultSet.getString("osa_id"),
                        ResultSet.getString("k_teksti"),
                        ResultSet.getString("linkki"),
                        ResultSet.getString("taso"),
                        ResultSet.getString("k_alaisuus")};
   unordered[i] = valiaikainen;
   i++;
}Compiles, but gives errors during run. In PHP this is annoyingly easy. (Grin.) Also I have to manipulate the order of the unordered, depending the data that arrays it contain holds. Is there easier way? Any help welcome, as I'm out of ideas.
Thanks
-9902468

OOps. Stopid question.
Figured it out right after posting the question...
Well newbies are newbies, eh?
-9902468

Similar Messages

  • Is there an example vi for converting an array of boolean to list an array of Int based on a selected T/F state?

    I would like to use arrays to minimize code.
    I am trying to generate an array of int base on an array of boolean randomly selected.

    You can try using 'Boolean to 0,1.vi', found in the Boolean palette: this vi converts a scalar, array or cluster of booleans to a scalar, array or cluster of word (I16 integers).
    To use it, simply wire an array of booleans (indicator) to its left, and an array of integers (control) to its right et voilà.
    Roberto
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How do I populate an array with a directory listing.

    I have a web site that has its photos updated by another person using a content management system that I have written. As Dreamweaver does not know about these extra photos, if I try to
    syncronise the site on my machine for backup purposes, Dreamweaver downloads all 5000+ photos, and this can take upwards of 12 hours if there are no breaks in the connection.
    So I am trying to write a page that creates an array of the existing files on the remote site. It will then do the same on my local site, and by comparing the arrays, will make a list of the new files, and then download these, which will save a lot of time and bandwith charges.
    First I have to read the directory list, using the code below which reads and echos it on screen.
    However, I cannot work out how to populate the required array.
    <?php
        try
        {          /***photo directory ***/
            $it = new directoryIterator('../web/thumbs');
            while( $it->valid())
                  /*** echo if not a dot directory ***/
                if( !$it->isDot() )
    /**** Array creation code needs to go here I think.***/
    echo $it->current()."<br />";
         /*** move to the next element ***/
                      $it->next();
        catch(Exception $e)
            /*** echo the error message ***/
            echo $e->getMessage();
    ?>
    This creates a list of files and displays it on the page.
    How do I store it in an array?
    Howard Walker

    Although not the solution you were looking for, consider the following:
    Click the icon in DW for "Expand to show local and remote sites."  Arrange the remote image directory by "Modified date," Then select all the recent images and GET them.
    I find the above method good enough for occassional synchronization. I also simply ignore broken image links on the testing system.
    If the above is not a solid enough solution, perhaps someone else will write your array function for you. I don't have the time.

  • What is the proper and best way to destroy a java.util.List or Array for GC

    Hi,
    If I have a java.util.List of objects lets say:
    List<File> files = new ArrayList();The List contains 1000 file objects. When my class finishes, is it enough to do
    files = null;to make GC able to release it from memory?
    Cause it seems like I can't do the following:
    for(int i = 0; i < extracted_files.size(); i++){
                extracted_files.get(i) = null;
    }Or should I use this one:
    files.clear()What is the proper and best way to do this in order to avoid memory leaks? How about normal Arrays like File[]?
    Edited by: TolvanTolvanTolvan on 2009-sep-10 16:58

    TolvanTolvanTolvan wrote:
    Thanks for the info!
    But what if the List is a class variable running in a Web Service for like months without terminating?You mean if the List variable is a member variable of a long-lived object? Then presumably the list needs to live as long as the object does. In the unlikely scenario that the object needs to live on but its list member variable does not, then yes, setting the member to null will be needed to make the list eligible for GC. But I highly doubt this is your situation, and if it is, you probably have a design flaw.
    And if the list is referenced only by a local variable, then, as I already said, when the method ends, the variable goes out of scope, and the List is eligible for GC.
    Now, a slightly different situation is when the List needs to live a long time, and at some point during its life, you're done using some object that it refers to. In that situation, simply remove the element from the list (or set the element to null if it's an array rather than a list), and then if it's not referenced anywhere else, it can be GCed.
    How about Arrays like File[]? Do I need to iterate through the array and null all the objects or is it enough to just null the Array?YOU. DON'T. NEED. TO. HELP. GC. You don't need to set the elements to null, and you most likely don't even need to set the array variable to null.
    Also note that only references can be null, not objects.

  • Casting List to Array of Unknown SubClass

    How do I cast a java.util.List to an array of a unknown subclass of a known parent class?
    Parent[] parents = someMethod();
    // someMethod returns ChildA[] or ChildB[] both extends Parent and are unknown to this method
    List list = new Vector();
    for (int i=0;i<parents.length;i++) {
      if (parents.someBoolean)
        list.add(parents[ i ]);
    return (Parent[])list.toArray(?????);
    // return (Parent[])list.toArray(new Parent[]{});
    // Not of the child type, will cause ClassCastException
    // return (Parent[])list.toArray(parents);
    // Correct type, but uses size of parents which is potentially too big.Any way to do this without reflection?

    But is is that at any given time, the array contains all elements of
    either ChildA or ChildB? If not, I'm not sure how can you cast the
    entire array. If so, why not check for one of the elements in the list
    for its type using instanceof operator and then cast the entire array
    appropriately.
    I'm actually getting confused as to what exactly you are looking for.I should have been more clear on that point. Yes all elements will be of the same type, i.e., all of type ChildA or all of type ChildB.
    The problem comes in the fact that even though one has an Object[] array where all Objects are of type ChildA, a ClassCastException will still be thrown when casting to ChildA[]
    I have no idea what you're looking to do, but, regardless of what
    parent class you cast some instance as, the current implementation
    of each method is still going to execute. In other words, the
    toString method of some instance always returns the same String,
    whether you have it casted as a Parent or Child because it just
    returns the implemetnation of the current classTrue, except of course for methods that only exist on the child objects.
    A friend has given me a solution that I suspect will work:
    import java.lang.reflect.*;
    return (Parent[])list.toArray(Array.newInstance(parents[0].getClass(),0));

  • UISelectMany :  must be of type List or Array (ERROR with rich:pickLisT )

    Hi
    I have a problem with my <rich:pickList> I can't display the items. When executing the application I got the following error:
    java.lang.IllegalArgumentException: ValueBinding for UISelectMany :  must be of type List or Array
            at org.richfaces.utils.PickListUtils.findUISelectManyConverter(PickListUtils.java:59)
            at org.richfaces.utils.PickListUtils.findUISelectManyConverterFailsafe(PickListUtils.java:79)as the error message the selectItems is not a List but it is I can't understand.
    I transmit to you my backing bean
    @Stateful
    @Name("adminAction")
    @Scope(ScopeType.SESSION)
    public class AdminActionBean implements AdminActionLocal {
    @In(required=false)
       private List<String> customersChoice;
    @Out(required=false)
       private List<String> companyNames;
    @Factory("companyNames")
       public void selectCompanyNames(){
           setCompanyNames((List<String>) getEm().createQuery("select c.companyName from Customer c")
                        .getResultList());
    //getter() and settter...... my .xhtml page
    <rich:pickList id="customersChoice" value="#{customersChoice}">
                        <f:selectItems  id="companyNames" value="#{companyNames}" />
              </rich:pickList>Have you got any Idea. thanks for help
    regards
    bibou

    You might look up the SelectItem, as the value parameter for a f:selectItems must be a List<SelectItem>. Each SelectItem has both a value and a label.
    Or, you could use Tomahawk's t:selectItems which uses a more dataList-style attribute set to allow you to have the value be any List, and you can select items in the List's node to be the Label and the Value of the select option.
    Look em up, they're useful.

  • List to array question

    I have a list stored in mysql database that looks like this:
    12, 45, A, 87, B, 98
    I need to use coldfusion to retreive the list and convert
    each item to an element of an array. i.e.:
    tempArray [0] = 12;
    tempArray [1] = 45;
    and so on. I need to do this because I'm returning the
    created array to flash.
    Thanks for your help!

    If you literally want to return 12, 45, A, 87, B, 98, then
    understand that is not an array, it's a list. The example in your
    first post indicated you wanted an array - tempArray[1] = 12,
    tempArray[2] = 45, etc. Which is it, or am I confused?
    BTW, you don't need the [,] in the ListToArray function - I'm
    surprised it did not throw a compile error. Just do this: <cfset
    tempArray = ListToArray(detailsList)>

  • Need help on creating a linked list with array...

    I want to create a linked listed using array method. Any suggestion on how would I start it.
    thanks

    That means I want to implement linked list using an
    array.I believe you mean you want to implement list using an array. Linked list is a very different implementation of a list, which can be combined with arrays for a niche implementation of list, but I don't think this is what you're talking about.
    Do you mind if we ask why you don't want to use ArrayList? It does exactly what you specify, plus it will increase the size of the internal array as necessary to ensure it can store the required elements.
    If you really want to make your own, have a look at the source for ArrayList (in src.jar in your JDK installation folder) - it will answer any questions you have. If you don't understand any of the code, feel free to post the relevant code here and ask for clarification.

  • Put list in array

    Hi all,
    How to put list in array?? Is it true or not??
    What I mean is&#8230;I have list data like
    List 1 : 1 2 3 4
    List 2 : 2 3 4 5
    I want to put the list in array like
    [[1 2 3 4], [2 3 4 5]]
    Actually, can we do like this?
    Thank you very much.

    Hi jverd...
    Thank you very much....you help me a lot...I have another problem after settle the problem before...
    My problem is how to pass the list to another method??? I try to code but I get the object after I pass the list...My goals is want to compare line by line each other....
    Below is some of my code:      public static void hantarEquivalantClass(ArrayList s) {
              String[] s2 = (String[]) s.toArray(new String[0]);
              System.out.println("List Equivalance Class");
              System.out.println();
              for (int index = 0; index < s2.length; index++)
                        System.out.println(s2[index]);
              gunaStringTokenizer(s2);
             public static void gunaStringTokenizer(String[] s2) {
              List list = new LinkedList();
              for (int i = 0; i < s2.length; i++){
                   List list2 = new LinkedList();
                   StringTokenizer token = new StringTokenizer(s2, ",");
                   while (token.hasMoreTokens())
                        list2.add(token.nextToken());
                   list.add(list2);
              for (int i=0; i < list.size(); i++){
                   for (int j=0; j < list.size(); j++)
                        discernibility(list.get(i), list.get(j));
    //Here is problem....the object will pass not the list
    public static Set discernibility(List sRow, List sRowR) {
              Set s = new TreeSet();
              Iterator it = sRow.iterator();
                   while (it.hasNext()){
                        Object o = it.next();
                        if(!sRowR.contains( o ))
                        s.add( o );
              Iterator it2 = sRowR.iterator();
                   while (it2.hasNext()){
                        Object o2 = it2.next();
                        if(!sRow.contains( o2 ))
                        s.add( o2 );
              return s;

  • Search given string array and replace with another string array using Regex

    Hi All,
    I want to search the given string array and replace with another string array using regex in java
    for example,
    String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
    String fromValue[] = {"you", "search", "for", "any"}
    String toValue[] = {"me", "dont search", "never", "trip"}
    so the string "you" needs to be converted to "me" i.e you --> me. Similarly
    you --> me
    search --> don't search
    for --> never
    any --> trip
    I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
    I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
    One Single regular expression which matches the pattern and solve the issue.
    the output should be as:
    If me wish to don't search never trip etc...,
    Please help me to resolve this.
    Thanks In Advance,
    Kathir

    As stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
    import java.util.regex.*;
    public class Test
      static final List<String> oldWords =
          Arrays.asList("you", "search", "for", "any");
      static final List<String> newWords =
          Arrays.asList("me", "dont search", "never", "trip");
      public static void main(String[] args) throws Exception
        String str = "If you wish to search for any of these characters, "
            + "they must be preceded by the character to be interpreted";
        System.out.println(doReplace(str));
      public static String doReplace(String str)
        Pattern p = Pattern.compile("\\b\\w+\\b");
        Matcher m = p.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
          int pos = oldWords.indexOf(m.group());
          if (pos > -1)
            m.appendReplacement(sb, "");
            sb.append(newWords.get(pos));
        m.appendTail(sb);
        return sb.toString();
    } This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).

  • Programmatically create array from common cluster items inside array of clusters

    I have seen many questions and responses on dealing with arrays of clusters, but none that discuss quite what I am looking for. I am trying to programmatically create an array from common cluster items inside array of clusters. I have a working solution but looking for a cleaner approach.  I have an array of clusters representing channels of data.  Each cluster contains a mixture of control data types, i.e.. names, types, range, values, units, etc. The entire cluster is a typedef made up of other typedefs such as the type, range and units and native controls like numeric and boolean. One array is a “block” or module. One cluster is a channel of data. I wrote a small vi to extract all the data with the same units and “pipe” them into another array so that I can process all the data from all the channels of the same units together.  It consists of a loop to iterate through the array, in which there is an unbundle by name and a case structure with a case for each unit.  Within a specific case, there is a build array for that unit and all the other non-relevant shift registers pass through.  As you can see from the attached snapshots, the effort to add an additional unit grows as each non-relevant case must be wired through.  It is important to note that there is no default case.  My question:  Is there a cleaner, more efficient and elegant way to do this?
    Thanks in advance!
    Solved!
    Go to Solution.
    Attachments:
    NI_Chan units to array_1.png ‏35 KB
    NI_Chan units to array_2.png ‏50 KB

    nathand wrote:
    Your comments made me curious, so I put together a quick test. Maybe there's an error in the code (below as a snippet, and attached as a VI) or maybe it's been fixed in LabVIEW 2013, but I'm consistently getting faster times from the IPE (2-3 ms versus 5-6ms for unbundle/index). See if you get the same results. For fun I flipped the order of the test and got the same results (this is why the snippet and the VI execute the tests in opposite order).
    This seems like a poster child for using the IPES!  We can look at the index array + replace subset and recognize that it is in place, but the compiler is not so clever (yet!).  The bundle/unbundle is a well-known "magic pattern" so it should be roughly equivalent to the IPES, with a tiny penalty due to overhead.
    Replace only the array operation with an IPES and leave the bundle/unbundle alone and I wager the times will be roughly the same as using the nested IPES.  Maybe even a slight lean toward the magic pattern now if I recall correctly.
    If you instantly recognize all combinations which the compiler will optimize and not optimize, or you want to exhaustively benchmark all of your code then pick and choose between the two to avoid the slight overhead.  Otherwise I think the IPES looks better, at best works MUCH better, and at worst works ever-so-slightly worse.  And as a not-so-gentle reminder to all:  if you really care about performance at this level of detail: TURN OFF DEBUGGING!

  • Array-elem​ents depending on which array-elem​ent one choose before

    Hello!
    Now we have perhaps an easy problem... we have from the beginning a text-file that we pick out some of the columns that we display on the frontpanel. This forms an array of cluster with the different columns in. Then one is able to choose one of these elements of the array. There are moore values that belongs to each elements but these we do not want to display, so that is why we picked them out from the array and put them in another array that we thought we could connect in some way to the first array... now the problem: when one choose an element of the first array we want the other array to pick out the value with the same index. I should mension that we build an array of the choosen elements too...
    Any tip or help would be nice :-) best regards!

    First, you must change your K-value array to a control so you can read from it. Then you must make your Array of Signals into a 2D array to hold the signal and the value in separate columns. Now look at the attached vi. It will put the signal in column 0 and the K-value in column 1 for each signal selected from Signallist.
    - tbob
    Inventor of the WORM Global
    Attachments:
    array-element[1].vi ‏47 KB

  • Can you parse an array of string characters into separate arrays?

    Hello,
    I didn't see anything directly related to my question, so I'll go ahead and post it.  I'm looking to parse an array of hex characters into three separate arrays for parallel Color to RGB conversion in LabView.  Ideally, after importing an image, I would have liked to use the Color to RGB conversion for the 24-bit pixmap (in hex digit format), but apparently, you can only do this for single number conversions...not arrays.  Another way is what I have mentioned above, which would be to parse each element's red, green, and blue # into three separate arrays as shown below:
    Original Array:   aa11ff     225599
                              cc4488   bbcc11
    Array 1: aa  22
                 cc   bb
    Array 2: 11   55
                  44   cc
    Array 3:  ff    99
                  88   11
    I could then do a parallel conversion of these arrays from hex to numeric and get the desired result.  However, I'm having trouble finding a function that will do this.  So I would like to ask if a function like this does exist and if so, what is it?  I should note that I'm trying to avoid using two while loops because of time constraints (using the program for in-situ measurements), and we do not own, nor are we looking to purchase the $$$ vision/video package that NI makes.

    Nevermind.  I found an adequate way.

  • Array of variable-length lists in Action Engine

    I'm starting work on a application that consists of multiple sub-panels which each present a specific subset of the hardware functionality.  The hardware appears to the host mostly as memory-mapped registers.  I'm considering implementing the hardware interface in an Action Engine (AE) so that LV will automatically arbitrate among the hardware access requests from the sub-panels and because it (seems to me) to make the data flow more clear than the current implementation that uses a veritable plethora of queues, notifiers, and rendezvous to send requests and results between the sub-panels and the hardware interface at the top-level.
    The challenge is this, though:  Certain hardware addresses need to be modeled in multiple sub-panels -- maybe data at a certain address changes the functionality of some other addresses, or maybe different bit-fields within an address are part of different functional groups.   
    So any of sub-panel can request a read or write to the hardware, but often several of them need to see the resulting data.
    In order to keep the design modular and expandable I don't want to hard-code anything in the hardware AE that is specific to the sub-panels.   Instead, I intend to have the sub-panels "register" with the hardware AE indicating for which addresses they need to receive updates when some hardware address is read or written to.  This means the AE will have to keep the "registration" data in an un-initialized shift-register (USR).  But I want the hardware accesses to run as fast as possible, so I would like to ask for some suggestions how to implement this as efficiently as possible (avoiding, for example, clusters of arrays...)
    I imagine the sub-panel registration info might consist of a user-defined event reference (created inside the sub-panel VI) and a list of hardware addresses that the sub-panel is modeling.   Then when the hardware AE gets a request to read or write at some address it will also generate events to broadcast the data to the sub-panels that have registered for that address.   This will probably include 20-25 subpanels registering for a collective total of about 700 hardware addresses.  
    I'm less concerned about memory than speed.
    So, a few possibilities come to mind for how to implement the registration data in the AE USR:
    A) Have one 2-D array where the array contains one row per hardware address (~320), and columns contain the event refs for all the sub-panels registered for that address.   The width of the array would depend on whichever address has the greatest number of sub-panels registered for it (maybe 4-5?), but that still means the array would be pretty large (about 6.5 kbytes if a reference is a 32-bit value?)
    On the other hand, indexing into this array to look up the sub-panel references for the current address would be relatively quick and easy since the hardware address is the row number.
    B) Have two arrays where the array size is the number of sub-panels:  One 1D array for the registered event refs and one 2-D array for the addresses.  But different sub-panels will have different quantity of addresses registered, so that means the "width" of the address array would be as big as the largest number of addresses registered by one sub-panel (maybe 20?).   This would use a total of only about 1.5 kbytes, but I would have to search through all 25 address arrays to see if the current address is registered.
    C) or, some other way that I have not though of.   
    Once the "registration" data is received from the sub-panels during program initialization it is never changed, only read.   So at first glance it would seem (A) would be the faster implementation.  But I don't know what, if any, performance hit there would be from having such a large array in a USR, which is why I'm asking here.
    Any thoughts or suggestions would be greatly appreciated.
    Thank you and Best Regards,
    -- J.

    JeffBuckles wrote:
    Any thoughts or suggestions would be greatly appreciated.
    Thank you and Best Regards,
    -- J.
    Quick thought (hardly!)...
    I have used a "Self-Addressed Stamped Envelope" architectrure for those type os apps.
    DAQ device has a queue it monitors for subscription requests (Think of a in-box for Marketing deparetment).
    When client is created it submits a request via the queue for the subscription request that included a ref to its update queue and a list of teh channels it wants to watch. The clients then wait for updates.
    The Marketing department pass the request for updates (in-box of marketing department) to the production department (I used an AE to pass the mailing list) who picks through the acquired data and passes updates as requested to all of teh subscribing clients.
    Just sharing ideas,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Need help with ouput of a list or array of numbers input from user

    I'm only a few weeks into learning java, so this may seem simple to some, but...
    I am trying to write a program that will receive numbers from a user,
    and then list, add, average those numbers. I've got the program to
    work except for listing the numbers that were input.
    Can someone help guide me????
    i've left the code I've tried in as comments.
    Enter an integer value, the program exits if the input is 0:
    20
    Enter an integer value, the program exits if the input is 0:
    40
    Enter an integer value, the program exits if the input is 0:
    60
    Enter an integer value, the program exits if the input is 0:
    80
    Enter an integer value, the program exits if the input is 0:
    0
    Total numbers entered: 4
    The array of numbers is: 0 0 0 0
    The sum is 200
    The average is 50
    The maximum number is 0
    The minimum is 0
    Here is my code:
    * Title:        Reads integers and finds the total, average, maximum of the input values
    * Description:
    * Copyright:    Copyright (c) 2002
    * Company:      Duke Court.
    * @author Mary Davenport
    * @version 1.0
    public class part3page6
      public static void main(String[] args)
      int data = 0;
      int sum = 0;
      int countnum = -1;
      int maximum = 0;
      int minimum = 0;
      int average = (countnum - 1);
      do
          System.out.println("Enter an integer value, " +
            " the program exits if the input is 0:  ");
          data = MyInput.readInt();
          sum += data;
          countnum++;
        } while (data != 0);
          //in order to figure the max & the min it appears that the
        //program will need to utilize arrays to store the individual numbers
        //that are input from the user.
        //create an array of the input data
        int[] number = new int[countnum];
        //creat a list of the input data
        int []myList = {data};
        //lists how many numbers entered
        System.out.println("Total numbers entered:  " + number.length);
        //list array of numbers -- this is giving me [I@3179c3,
        //instead of 20, 40, 60, 80 when I use "new int[countnum]"
    //     System.out.print("The array of numbers is: "
    //      + new int[countnum]);
        //list array of numbers:  this is giving me " 0 0 0 0 "
           //instead of 20, 40, 60, 80  with the following for statement
           // (number[i] + " ")
        System.out.print("The array of numbers is: ");
          for(int i=0; i<number.length; i++)
            System.out.print(number[i] + "  ");
      //list mylist of numbers from input, 20, 40, 60, 80
      //output is The list of numbers is: [I@3179c3
    //  System.out.print("The list of numbers is: " + myList);
        System.out.println();
        System.out.println("The sum is " +  sum);
        average = sum/countnum;
        System.out.println("The average is " + average);
        System.out.println("The maximum number is " +  maximum);
        System.out.println("The minimum is " +  minimum);

    When you input the data you need to save it to the array. Currently you are not saving the value you are just adding it
    ArrayList nums = new ArrayList();
       do
           System.out.println("Enter an integer value, " +
             " the program exits if the input is 0:  ");
           data = MyInput.readInt();
    nums.add(new Integer(data));
           sum += data;
           countnum++;
         } while (data != 0);

  • Execute a procedure with a list of array in sql server 2008

    HI all,
    I have a procedure which has a list of values passed as an array . How can i execute my procedure with array list? how to implement this?Please help me.
    Thanks in advance
    Deepa

    Hi Deepa,
    basically Microsoft SQL Server does not support arrays as data types for procedures. What you can do is creating a type which represents a table definition. This type can than be used in a procedure as the following demo will show:
    The first script creates the environment which will be used for the execution
    -- 1. create the table as a type in the database
    CREATE TYPE OrderItems AS TABLE
    ItemId int PRIMARY KEY CLUSTERED
    GO
    -- 2. demo table for demonstration of results
    CREATE TABLE dbo.CustomerOrders
    Id int NOT NULL IDENTITY (1, 1) PRIMARY KEY CLUSTERED,
    CustomerId int NOT NULL,
    ItemId int
    GO
    -- 3. Insert a few records in demo table
    INSERT INTO dbo.CustomerOrders
    (CustomerId, ItemId)
    VALUES
    (1, 1),
    (2, 1),
    (3, 3),
    (1, 3);
    GO
    -- 4. Create the procedure which accepts the table variable
    CREATE PROC dbo.OrderedItemsList
    @Orders AS OrderItems READONLY
    AS
    SET NOCOUNT ON;
    SELECT o.*
    FROM dbo.CustomerOrders AS O INNER JOIN @Orders AS T_O
    ON (o.ItemId = T_O.ItemId);
    SET NOCOUNT OFF;
    GO
    The above script creates the table data type and a demo table with a few demo data. The procedure will accept the table data type as parameter. Keep in mind that table variable parameters have to be READONLY as parameter for procedures!
    The second script demonstrates the usage of the above scenario
    When the environment has been created the usage is a very simple one as you can see from the next script...
    -- 1. Fill the variable table with item ids
    DECLARE @o AS OrderItems;
    INSERT INTO @o (ItemId)
    VALUES
    (1), (3);
    -- 2. Get the list of customers who bought these items
    EXEC dbo.OrderedItemsList @Orders = @o;
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

Maybe you are looking for