Is it possible to pass an argument to the function triggered by an event handler?

Hello All,
Trying to migrate my way of thinking from AS2 to CS4/AS3.
Ok, I have 2 buttons on the stage. Each button does almost
the same thing, so I want to create a single function, and each
button calls that same function (we'll name that function
"Navigate")... however, the function will need to end up doing
something different dependant on which button was clicked.
So, previously, in AS2, I would've added some code onto the
buttons themselves with on(release) methods (see CODE EXAMPLE 1)
So, each button effectively calls the Navigate function, and
passes a different frame label to the function.
Now, I'm trying to recreate this functionality in AS3. As you
all know, on(release) has been done away with (still don't know
why), but we now have to use event handlers, so I'm trying to
figure out a way to pass a different frame label argument to the
Navigate function. Currently I can achieve that by using a switch
statement to test which button was clicked, and act accordingly
(see CODE EXAMPLE 2).
In this over-simplified example, this works fine, but in the
real world I'm going to have more than 2 buttons, and the Navigate
function would probably be much more complicated...
So, I would like to be able to pass an argument(s) (like in
the AS2 example) to the Navigate function... perhaps in the
addEventListener() method? I tried this, but got compiler errors
(see CODE EXAMPLE 3):
The Million Dollar Question:
Is it possible to dynamically pass/change an argument(s) to a
function which is triggered by an event listener? (Or is the event
that triggered the function the only argument you can have?)
If this isn't possible, I'd greatly like to hear how you
folks would handle this (other than having a switch statement with
12 cases in it)???

I've found a couple solutions that I'll post below for
prosperity...
You could create a Dictionary keyed by the prospective event
targets and store any information in there you want associated with
them. Then the navigate function can check that dictionary to get
it's parameters:
// Code //
Button1.addEventListener(MouseEvent.CLICK, Navigate, false,
0, true);
Button2.addEventListener(MouseEvent.CLICK, Navigate, false,
0, true);
var buttonArgs:Dictionary = new Dictionary();
buttonArgs[Button1] = "FrameLabel1";
buttonArgs[Button2] = "FrameLabel2";
function Navigate(e:MouseEvent):void{
gotoAndStop(buttonArgs[e.target]);
This in my eyes, is about the same amount of work as writing
a long switch statement, but a little more elegant I suppose.
I had a little trouble understanding the next solution,
because I didn't quite understand an important piece of information
about event listeners. The addEventListener () requires a Function
as the 2nd argument passed to it.
It didn't quite click until someone pointed it out to me:
Navigate is a Function...
Navigate("FrameLabel1") is a Function
call...
So by writing just
Navigate, I'm not actually calling the function at the time
of the addEventListener call, I'm just supplying the event listener
with a reference to the name of the function. Then, when the
listener is triggered, the listener will call (and pass a
MouseEvent argument to) the Navigate function.
Conversely, by writing
Navigate("FrameLabel1") as the 2nd argument, the event
listener trys to execute the Navigate function at the time the
addEventListener is instantiated. And, since, in this example, the
Navigate function returned as ":void" a compile error would occur
because as I stated, an event listener requires a Function data
type as the 2nd argument. This would basically be like writing
addEventListener(MouseEvent.Click,
void, false, 0, true)
However, there is a way around this... basically, instead of
defining the Navigate function as returning a void data type, you
define it as returning a Function data type, and then nest another
function (which actually contains the actions you want to perform)
inside of it.
Button1.addEventListener(MouseEvent.CLICK,
Navigate("FrameLabel1"), false, 0, true);
Button2.addEventListener(MouseEvent.CLICK,
Navigate("FrameLabel2"), false, 0, true);
function Navigate(myLabel:String):Function{
return function(evt:MouseEvent):void{
gotoAndStop(myLabel);

Similar Messages

  • Passing a string as the name of a Mouse Event Listener function?

    Hello,
    I am trying to essentially pass a string as a function name into an event listener, but I am not sure how to approach this.  Is there a way to convert a string into a function?  I am not sure how to word my question, so I apologize.
    Here is some code I have for me to show you what I am doing.
    package{
         //some import statements
         public class changes extends MovieClip{
              var functionName:String
              var aBox:Sprite;
              public function changes(){
                       functionName = "testThis";
                       createButtonBox(16, 16, 32, 32,  functionName);
              public function createButtonBox(anX:Number, aY:Number, aWidth:Number, aHeight:Number, aFunction:String){
                   aBox = new Sprite();
                   //Some drawing box code
                   aBox.addEventListener(MouseEvent.CLICK,[aFunction]()?)
                   addChild(aBox)
              public function aFunction(event:MouseEvent){
                   trace("test");
    Am I on the right track or is this not possible?
    Anyhow, thank you in advance.

    I guess I misworded my question.  Essentially what I am trying to do is create buttons that have functions called to from an event listener, referenced by a string like this:
    public class Document{
         var functionName:String;
         public function Document(){
                 createAButton("Test Button A", 32, 32, "testThis");
                 createAButton("Test Button B", 64, 64, "testThis2");
         public function createAButton(textOnButton:String, anX:Number, aY:Number, functionToCallTo:String){
                   var aButton:Sprite = new Sprite();
                   //draw the button
                   //set a textfieldup for the button to have
                  aButton.addEventListener(MouseEvent.CLICK, functionToCallTo)
         public function testThis(event:MouseEvent){
                   trace("testA");
         public function testThis2(event:MouseEvent){
                    trace("testB");
    Unfortunately aButton.addEventListener(MouseEvent.CLICK, functionToCallTo) gives me a coercian error, which is a given.
    aButton.addEventListener(MouseEvent.CLICK, [functionToCallTo]()) gives me TypeError: Error #1006: value is not a function.
    I mean I could create a bunch of if statements, but for the number of functions I plan to call to, like about 25 or so, that is pretty tedious.

  • Is there a possibility to switch off in Firefox the functionality of quick launch key (additional key in laptop) that cause to run the homepage

    Dear Support,
    Is there a possibility to switch off in Firefox the functionality of quick launch key (additional key in laptop) that cause to run the homepage. I would like to switch this functionality off, because the key is malfunctioned and always pressed. I was able to switch off the functionality of this key in Windows system by deleting entries in registry Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey. After this change, when somebody works in system the Firefox is not running is not launching all the time. But when I open the Firefox the setting in system is overwritten and when I am using it Firefox returns to the homepage instantly. I think because of this quick launch button. I tried to change settings in about:config like browser.startup.homepage, browser.startup.homepage_override, startup.homepage_override_url,… this is for Firefox version is 10.0.2
    Thank you
    Best Regards

    Hi,
    Thank you for your interesst.
    This internet button key is one of buttons located above the keyboard near the power button. What I have achieved to this moment was to stop it functionality in the system by clearing the entries in the fields Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\17\ShellExecute and entry
    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\7\Association that was http
    After these changes in registry the behavior of the button was suppressed, the Firefox stopped to start unexpectedly all the time – so in system it works. But the problem is still when I have opened Firefox. Every time when you want to surf in internet – the homepage is activated also unexpectedly. I wrote this post with intention to ask if there is a possibility to switch off the functionality of this quick launch button in Firefox. Because I assume Firefox overrides the system setup – this I have made in registry. I tried with some option changes in about:config but without success. And I know that for older versions of firefox was some option in about:config do disable_quick launch button. But in 10.0.2 I couldn't locate it.
    Thank you
    Regards
    Lukasz

  • How to pass rowtype argument to a function from select statement?

    Hi all!
    I have function that takes mytable%rowtype as in parameter. can I pass entire row of mytable to the function from select statement? kind of
    select myfunction(mytable.*) from mytable where ....
    Thanks in advance

    The function can be used in a SQL statement only if it accepts SQL types and returns SQL type. %ROWTYPE being PL/SQL construct and not a SQL datatype, can not be used in this context.
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10743/datatype.htm#i2093

  • Passing an argument in the SQL Query of a View Object

    Hi,
    It is possible that this question has been asked before, however I have searched for a half an hour in the forums and couldn't find a solution.
    I am also new to using JDeveloper and ADF. Here's the situation:
    I am developing an application that doesn't have to do anything else then displaying data from a database. Pretty straightforward actually.
    Now I have made a vew pages with several collapsible panels (af:showDetailHeader) and have setup the datasources (or so I thought).
    All that remains is:
    - drag & drop a view object, from the application module that I created, onto the collabsible panels, so a child element gets created which displays data from the database.
    - hack the layout so it looks like I want it to.
    The problem that I have is the following:
    I am using a 'User'-class that contains values I need when quering the database.
    That User-object is part of a user-session.
    What I want, for example, is to use the 'getPersonId()' function of that User-object and pass the argument to a SQL-query of a certain view-object.
    The query would become something like:
    'SELECT * FROM people WHERE people.personId = :someNumber'.
    Now I've read some stuff about variable binding, which is complemented by something like (backing bean code):
    getDBTransaction().getRootApplicationModule().getACertainViewObject().setWhereClauseParameter(1, user.getPersonId());
    The examples I have found that might match my wishes are not using business components, but EJB's. I am having difficulty with understanding the 'how'-part of variable binding.
    Also, I do not know enough of ADF to be able to create a situation like:
    'User loads page, collapsible panel 1 is fully shown, the others are undisclosed.'
    (meaning, that for panel1 a query has been executed.)
    'User clicks on collapsible panel 2 which triggers a backingbean that somehow retrieves data from a view object'.
    I would appreciate any help that somebody can give.
    If it is not too much of a problem, please provide code snippets in case you have a solution. I am new to ADF :(.
    -edit
    I am using JDeveloper 10.1.3.3.0 in case that is of any importance.
    Message was edited by:
    Hugo Boog

    Hello Stijn,
    I didn't think about a referenced bean rule in the faces-config.
    I added it right away and I am now able to set parameters of a View-object, not using a page button and before the page loads. You made my day!
    In case anyone ever reads this post again, the summary of how to generate a table based on a View-object using dynamic parameters.:
    1a: Go to faces-config.xml -> Overview tab'
    1b: Go to the menuitem "Referenced Beans"
    1c: Click on 'new' and select the existing bean you want to access data from and input a name. In this example I use name="user"
    2: Create a View-object using the wizard.
    2a: Specify the query you want in the menuitem 'SQL Statement'.
    Add the 'parameters' you want to. You will have something like:
    "SELECT * FROM someTable WHERE table.columnname LIKE :someArgument".
    - hint: if you want the result to become something like:
    "SELECT * FROM someTable WHERE table.columnname LIKE '%someArgument%'" then you have to add the '%'-characters in your code itself (read: someClass.setParameter("%" + someArgument);).
    2b: In the menuitem 'Bind Variables' you have to add the variables you are referring to in the query. If you look at the query in 2a, then you have to add a variable with name "someArgument".
    2c: Add the View-object to a Application Module (create one if nessecairy).
    3a: Open a .jsp(x) file. Drag the View-object created in step 2 from the 'Data Controls'-pane to the page.
    3b: Click on the '+' of the View-object in the 'Data Controls'-pane and open 'Operations' and drag 'ExecuteWithParams' to your page as a button.
    3c: We do not want to use a button, the action has to be executed immediatly. So In the page source remove the lines that were created after dropping 'ExecuteWithParams'.
    3d: Right-click on the page and select "Go to Page Definition".
    3e: Go to the action id that is called 'ExecuteWithParams#', where # is a number.
    Change the id to something useful.
    3f: Change the NDValue so it corresponds with the value you want.
    Example:
    <action id="getAddressData" IterBinding="AddressesView1Iterator"
    InstanceName="MyHRServiceModuleDataControl.AddressView1"
    DataControl="MyHRServiceModuleDataControl" RequiresUpdateModel="true" Action="95">
    <NamedData NDName="someArgument" NDType="java.lang.String"
    NDValue="#{user.personId}"/>
    </action>
    Note: It is possible to use the value of a Backing Bean in NDValue.
    Note 2: user is the bean I referred to in the faces-config.xml!
    3g: Under the executables item, add an 'invokeAction' to pass the parameter to the View-object before your JSP-file loads:
    <executables>
    <invokeAction Binds="getAddressData"
    id="loadAddressDataOfPersonIdInSession"
    Refresh="prepareModel"/>
    Thank Stijn Haus for this :)

  • Is it possible to pass  a value from the list to another page..

    Hi everyone,
    I created a (list region) on a page and there is a FORM on the same page.I am trying to pass a value from that page to another page when the user selects one of the list entries.I tried with SET THESE ITEM.. WITH THESE VALUES in the list entries like
    SET THESE ITEMS--P13_TESTING_ID
    WITH THESE VALUES --&P10_ID.
    but its not working for me.I want to pass that value only when the user hits that list entry.Is it possible to do.
    Thanku
    phani

    Assuming P10_ID is an item on the FORM, I think , the form would have to be posted (submitted) for the item's vaue to be available in session state.

  • Pass an argument in a function ?

    would it be possible to do something such as :
    <h:outputText id="status" value="#{SearchManager.nbrPax("ZZZZZ"}" style="vertical-align: top;" />

    Hi !
    in fact jsf doesn't support parameters for methods binding.
    but ther is a way that i personnaly use:
    instead of using
    SearchManager.nbrPax("ZZZZZ"}You can use
    SearchManager.nbrPax().ZZZZZwhere method nbrPax on SearchManager backing bean returns a java.util.Map
    so when jsf found a Map instance it calls the method get () with the next key as parameter.
    So the code i gave you is equivalent to java code
    SearchManager.nbrPax().get("ZZZZZZ")I found this tips in jsf sources and i think it is realy usefull !
    I hope this will help you !
    bye

  • Passing String values in the Function module

    Hi
    i am using a coustom made RFC, here i am usnig input parameter 'jobnature' of string type of length 720. the values is getting from the portal,
    i send a string of length of 720 charater from portal, but inside the RFC only 132 charaters are getting .why it happeded so, what is the solution .
    regards
    Renjith

    Hi renjith,
    1. don't give any length in the FM definition.
    2. just like this.
    STR     TYPE     STRING
    (Tick the checkbox for 'Pass Value')
    (Bcos its RFC Enabled)
    regards,
    amit m.

  • Pass kernel arguments during install to force sata detection

    Is it possible to pass kernel arguments during install of the 0.7.1 noodle base iso? I want the installer to detect my harddisc (with is a pata drive but I have a sata controller in my laptop) as sata. (Needed because of this problem http://bbs.archlinux.org/viewtopic.php?t=17696)
    Update
    I managed to pass the kernel argument (just typed arch hdc=noprobe) but I have to do hdd=noprobe as well because otherwise my harddisc is not recognized at all. But as a result, I'm unable to get my dvd-drive working and for that I'm unable to use the reiserfs to format my root disc. Also my ethernet module can't be loaded so I'm still unable to install
    Solved
    Problem solved, I managed to chroot into my install with the install cd (after doing the install but not having installed bootloader) and with passing kernel arguments hdc=noprobe hdd=noprobe I was able to install lilo on sda. I edited fstab and the kernel 2.6.15 handles the disc and the dvd-station very well. So I'm happy

    Hmm, I saw that klibc before I installed to the pata drive.  I just ran pacman -Rd klibc before upgrading and had no problems.  Though, since klibc is a dependency of mkinitcpio, I should try removing the symlink rather than the package itself.

  • How to pass an argument to a standalone java class in JDeveloper

    To the experienced:
    In JDeveloper when you write a java class with a main() method that takes no argument, you just right click the java file and select Run to run the program. But suppose the main() method takes arguments, how do you pass your arguments to the program? This is especially a problem as I use the studio version of JDeveloper (Versions 10.1.3.4 and 11.1.1.3) that each uses the version of JDK bundled with it, rather than the JDK (which is yet another different version) installed at the OS level of the PC.
    Many thanks for your help!
    Newman

    Hi, Puthanampatti,
    Suppose a java class has a main() method:
    <pre>
    public class FormatTerm {
    public static void main(String[] args) {
    String year = args[0];
    String semester = args[1];
    </pre>
    What I want to know is how to pass the arguments when invoking FormatTerm within JDeveloper (i.e., without going out of JDeveloper to invoke FormatTerm on a command line in DOS). I would appreciate it very much if you know how to do that in JDeveloper 11g (I use Version 11.1.1.3) and could help me out.
    Thank you very much for your help!
    Newman

  • Argument error; the number of columns does not equal the number of parameters.

    I am using the Database Toolkit (Enterprise Connectivity) to check for a network connection and then send information from a local database to a SQL database on the network if needed.  In development of the code I continue to receive Error 1 and the Possible Reason(s) is "Argument error; the number of columns does not equal the number of parameters."  I am using the DBToolsSelectData.VI to retrieve data from the local MDB file and the DBToolsInsertData.VI to write it to the SQL file.  The collection of the data from the MDB file is successful and the connection and validation of the table and columns in the SQL file is also successful.  The error occurs when the Insert VI tries to build the query.  The number of columns being written (attempted) does match the number of columns in the data, they are both 16 string arrays.

    Ok, it's taken a bit, and I have a solution! It took a while to figure out what the DCT is doing, but it seems to be working now.
    The reason for the original error is that you were passing into the insert subVI an array of variants - which the input to the VI coerced into a single variant. You were getting the error because as far as the insert VI was concerned you were only passing it a single data value. The way to get around that was to create a cluster with one element for each column value, convert the cluster to a variant and pass the result to the insert VI - see attachment.
    In terms of the other modifications, I made a copy of the endurance.mdb file, emptied it and used it as the destination for the copy.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
    Attachments:
    NetworkCheck.vi ‏49 KB

  • Possible to catch parameters exceptions in the program ?

    Hi,
    Oracle 10g r2.
    I have some procedures/functions like :
    function insert_op (op_name in varchar2, op_date in date, op_length in number) is
    begin
    end;If I call for example :
    insert_op('test','02/05/2010','hehe')I will get an error (invalid number). Normal.
    My qyestion is, is it possible to catch that exception in the function ?
    The fact is that my function is called from an input button in my apex application, so if user enter wrong values in the form, I can't catch the error except using Javascript.
    Or should I pass all my parameters as varchar2, and then make functions to ckeck if it is valid numbers, dates, etc... :/
    Thanks.
    Yann.

    function insert_op(op_length in number) return varchar2 is
    temp number;
    begin
    temp := TO_NUMBER(op_length);
    return 'ok it is a number';
    exception
    when others then return 'not a number';
    end;Define the op_length as varchar2
    create or replace function insert_op(op_length in varchar2) return varchar2 is
    temp number;
    begin
       temp := TO_NUMBER(op_length);
       return 'ok it is a number';
    exception
    when others then return 'not a number';
    end;And further most important thing is dont use WHEN OTHERS. Use the specific exception. In this case VALUE_ERROR.
    I have done such thing in the past. Here is that code.
    create or replace function is_number(pVal in varchar2) return number
    as
       lNum number;
    begin
       lNum := to_number(pVal);
       return 1;
    exception
       when value_error then
               return 0;
    end;Edited by: Karthick_Arp on Mar 1, 2011 5:26 AM

  • How to pass input value to the IN parameter in a function

    Hi ,
    I'm new to pl/sql programming.
    The below function is used inside a package and the package is invoked in visual studio.
    The function uses 2 input parameters.
    Out of which 'in_report_parameter_id' value comes thru job processor service 's job request.
    The second IN paramter values are hard coded in the function.
    I'm not able to understand this.
    If the values are hard coded , how to make sure that only the hard coded values are the right ones?
    Please anyone could explain to me?
    I really dont have good idea about how to pass INPUT parameter to the functions or procedure
    Is there any nice document which could give me good understanding about what are the ways or types we could pass values to the input parameter in subprograms?
    thanks in advance.
    CREATE OR REPLACE FUNCTION get_class_text_str
         in_report_parameter_id IN NUMBER,
         in_which                IN VARCHAR2 DEFAULT 'SELECT'
    RETURN VARCHAR2
    IS
             end_text            VARCHAR2 (50)   := '';
             my_class_text_str  VARCHAR2(10000) := '';
             my_class_value_str VARCHAR2(10000) := '';
         CURSOR class_text(c_1_text VARCHAR2, c_2_text VARCHAR2) IS
         SELECT c_1_text || report_parameters.report_parameter_value
                               || c_2_text
                               || report_parameters.report_parameter_value
                               || '" '
          FROM report_parameters
         WHERE report_parameters.report_parameter_id     = 3690
           AND report_parameters.report_parameter_group  = 'CLASS'
           AND report_parameters.report_parameter_name   = 'CLASS'
    GROUP BY report_parameters.report_parameter_value
    ORDER BY CAST(report_parameters.report_parameter_value AS NUMBER);
    BEGIN
         IF (in_which = 'SUM') THEN     
              OPEN class_text ( 'SUM(NVL("Class ', '", 0)) "Class ' );
         ELSIF (in_which = 'PERC')THEN
              OPEN class_text ( 'ROUND((("Class ', '" / "Total") * 100), 2) "Class ' );
              end_text := ', DECODE("Total", -1, 0, 100) "Total" ';
         ELSE
              OPEN class_text ( 'SUM(DECODE(bin_id, ', ', bin_value, 0)) "Class ' );
         END IF;
         LOOP
              FETCH class_text INTO my_class_value_str;
              EXIT WHEN class_text%NOTFOUND;
              my_class_text_str := my_class_text_str || ', ' || my_class_value_str;
         END LOOP;
         CLOSE class_text;
         my_class_text_str := my_class_text_str || end_text;
         RETURN my_class_text_str;
    END get_class_text_str;
    /Edited by: user10641405 on Nov 19, 2009 8:16 AM
    Edited by: user10641405 on Nov 19, 2009 8:30 AM

    This is not a design I would use, but should work if coded properly. I would probably build a reference cursor query as text and use one open fetch and close.
    You have 2 input parameters, in_report_parameter_id and in_which. I could not find where in_report_parameter_id was used in the program, but the value passed in for in_which is being used in IF logic to decide how to open the cursor. After the cursor is open rows are being fetched and eventually the cursor is closed.
    The values in_which are compared to are hard-coded. It is the programmer's job to make sure the values listed are the right values and the actions taken are also correct. Your program is assuming that if the first 2 values are not encountered the third one listed is the one you want.
    To pass input values to a procedure you merely provide the values as a literal or variable in the call, something like
    whatever := get_class_text_str(1,'SELECT');

  • Elvis: Is It possible to use the Function Generator and the Oscilloscope simultaneously?

    Hi,
     We are using the NI Elvis to output a function or a sine wave at a certain frequency and using the oscilloscope on the same board/elvis to read a modified signal. Is this possible? Can we use both the Function Generator and the oscilloscope at the same time? Please help. The oscilloscope would be reading signal from an accelerometer. Thank you in advance. We have no VI as we do not know which to use and if they are possible.

    Hi,
    There is no problem using the Function Generator and Oscilloscope
    at the same time with NI ELVIS. Using the NI ELVIS soft front panels (Start
    >> Programs >> National Instruments >> NI ELVIS 3.0 >>
    NI ELVIS – see picture attached –‘NI ELVIS soft front panels.JPG’), you can choose
    to open more than one instrument at a time. We do this by opening one
    instrument, allowing it to begin, and then opening another. We can also program
    in LabVIEW using more than one instrument at a time by placing down multiple
    Express VI’s taken from the NI ELVIS pallet on the block diagram (see picture
    attached – ‘ELVIS Express VI's (LabVIEW).JPG’). One note when doing this,
    please see KB 41ODPHX1 
    for an example of how to program in parallel. If you do not wire the ‘stop’
    terminal of the express VI’s, you will get the error described.
    David L.
    Systems Engineering
    National Instruments
    Attachments:
    ELVIS Express VI's (LabVIEW).JPG ‏74 KB
    NI ELVIS soft front panels.JPG ‏56 KB

  • Is possible to pass array/list as parameter in TopLink StoredProcedureCall?

    Hi, We need to pass an array/List/Vector of values (each value is a 10 character string) into TopLink's StoredProcedureCall. The maximum number of elements on the list is 3,000 (3,000 * 10 = 30,000 characters).
    This exposed two questions:
    1. Is it possible to pass a Vector as a parameter in TopLink's StoredProcedureCall, such as
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("STORED_PROCEDURE_NAME");
    call.addNamedArgument("PERSON_CODE");
    Vector strVect = new Vector(3000);
    strVect.add(“ab-gthhjko”);
    strVect.add(“cd-gthhjko”);
    strVect.add(“ef-gthhjko”);
    Vector parameters = new Vector();
    parameters.addElement(strVect);
    session.executeQuery(query,parameters);
    2. If the answer on previous question is yes:
    - How this parameter has to be defined in Oracle’s Stored Procedure?
    - What is the maximum number of elements/bytes that can be passed into the vector?
    The best way that we have found so far was to use single string as a parameter. The individual values would be delimited by comma, such as "ab-gthhjko,cd-gthhjko,ef-gthhjko..."
    However, in this case concern is the size that can be 3,000 * 11 = 33, 000 characters. The maximum size of VARCHAR2 is 4000, so we would need to break calls in chunks (max 9 chunks).
    Is there any other/more optimal way to do this?
    Thanks for your help!
    Zoran

    Hello,
    No, you cannot currently pass a vector of objects as a parameter to a stored procedure. JDBC will not take a vector as an argument unless you want it to serialize it (ie a blob) .
    The Oracle database though does have support for struct types and varray types. So you could define a stored procedure to take a VARRAY of strings/varchar, and use that stored procedure through TopLink. For instance:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("STORED_PROCEDURE_NAME");
    call.addNamedArgument("PERSON_CODE");
    oracle.sql.ArrayDescriptor descriptor = new oracle.sql.ArrayDescriptor("ARRAYTYPE_NAME", dbconnection);
    oracle.sql.ARRAY dbarray = new oracle.sql.ARRAY(descriptor, dbconnection, dataArray);
    Vector parameters = new Vector();
    parameters.addElement(dbarray);
    session.executeQuery(query,parameters);This will work for any values as long as you are not going to pass in null as a value as the driver can determine the type from the object.
    dataArray is an Object array consisting of your String objects.
    For output or inoutput parameters you need to set the type and typename as well:
      sqlcall.addUnamedInOutputArgument("PERSON_CODE", "PERSON_CODE", Types.ARRAY, "ARRAYTYPE_NAME"); which will take a VARRAY and return a VARRAY type object.
    The next major release of TopLink will support taking in a vector of strings and performing the conversion to a VARRAY for you, as well as returning a vector instead of a VARRAY for out arguments.
    Check out thread
    Using VARRAYs as parameters to a Stored Procedure
    showing an example on how to get the conection to create the varray, as well as
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/varray/index.html on using Varrays in Oracle, though I'm sure the database docs might have more information.
    Best Regards,
    Chris

Maybe you are looking for

  • How do I remove an attack site warning from my domain?

    Registered a domain in December. Even before going live with website the domain was flagged as attack site. Was reviewed and cleared by StopBadware, but still being flagged by Firefox. Please remove this and allow visitors to the site! 'Disguised" ur

  • Multiple CardDav accounts, can't delete

    Hi everyone, On my MacBook Pro, iPad and Samsung phone actually I keep all the calendar and contacts sync through a same account of Gmail. With new OS X releases I usually format all my hardrive and later restore part of all the content with Time Mac

  • Problem In getting output when running JavaHelp System

    Hi I am giving my code from which i want to display my Java Help system...... Here when i run my program it will give me output as... init: deps-jar: compile: run: BUILD SUCCESSFUL (total time: 0 seconds) But it will nt show any help browser or help

  • How do I mark an imported DVD movie as explicit?

    Need to mark a few of my films as explicit so I can lock them out with Parental Controls. How do I do this?

  • "Drive is offline" message in Missing Disks window

    Hello support person, When I try to open my project I get a Missing Disks window and the message says: To preserve the integrity of the data used by Final Cut Pro HD, it is necessary to ensure the existence of the following path(s): 'Justine's Drive'