Help with dynamic creation of class object names

Hi all
Wonder if you can help. I have a class player.java. I want to be able to create objects from this class depending on a int counter variable.
So, for example,
int counter = 1;
Player p+counter = new Player ("Sam","Smith");the counter increments by 1 each time the method this sits within is called. The syntax for Player name creation is incorrect. What I am looking to create is Player p1, Player p2, Player p3.... depending on value of i.
Basically I think this is just a question of syntax, but I can't quite get there.
Please help if you can.
Thanks.
Sam

here is the method:
//add member
  public void addMember() {
    String output,firstName,secondName,address1,address2,phoneNumberAsString;
    long phoneNumber;
    boolean isMember=true;
    this.memberCounter++;
    Player temp;
    //create HashMap
    HashMap memberList = new HashMap();
    output="Squash Court Booking System \n";
    output=output+"Enter Details \n\n";
    firstName=askUser("Enter First Name: ");
    secondName=askUser("Enter Second Name: ");
    address1=askUser("Enter Street Name and Number: ");
    address2=askUser("Enter Town: ");
    phoneNumberAsString=askUser("Enter Phone Number: ");
    phoneNumber=Long.parseLong(phoneNumberAsString);
    Player p = new Player(firstName,secondName,address1,address2,phoneNumber,isMember);
    //place member into HashMap
    memberList.put(new Integer(memberCounter),p);
    //JOptionPane.showMessageDialog(null,"Membercounter="+memberCounter,"Test",JOptionPane.INFORMATION_MESSAGE);
    //create iterator
    Iterator members = memberList.values().iterator();
    //create output
    output="";
    while(members.hasNext()) {
      temp = (Player)members.next();
      output=output + temp.getFirstName() + " ";
      output=output + temp.getSecondName() + "\n";
      output=output + temp.getAddress1() + "\n";
      output=output + temp.getAddress2() + "\n";
      output= output + temp.getPhoneNumber() + "\n";
      output= output + temp.getIsMember();
    //display message
    JOptionPane.showMessageDialog(null,output,"Member Listings",JOptionPane.INFORMATION_MESSAGE);
  }//end addMemberOn running this, no matter how many details are input, the HashMap only gives me the first one back....
Any ideas?
Sam

Similar Messages

  • Problem with Dynamically accessing EJB Class objects in WL 7.0 SP1

    I am trying to build a component which has the ability to instantiate and execute
    an known EJB method on the fly.
    I have managed to build the component but when I try and execute it I get a ClassNotFoundException.
    I know that the EJB I am trying to invoke is deployed and available on the server,
    as I can see it in the console, I also seen to have been able to get the remote
    interface of the object, my problem occurs when I try and access the class object
    so I can perform a create on the object and then execute my method
    The code I have written is below:
    private Object getRemoteObject(Context pCtx, String pJNDIName, String pHomeBean)
    throws Exception {
         String homeCreate = "create";
         Class []homeCreateParam = { };
         Object []homeCreateParamValues = {};           
    try {  
    //This call seems to work and doesn't throw an exception     
    Object home = pCtx.lookup(pJNDIName);
    //However this call throws a java.lang.ClassNotFoundException
    Class homeBean = Class.forName(pHomeBean);
    Method homeCreateMethod = homeBean.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    } catch (NamingException ne) {             
    logStandardErrorMessage("The client was unable to lookup the EJBHome.
    Please make sure ");
    logStandardErrorMessage("that you have deployed the ejb with the JNDI
    name "+pJNDIName+" on the WebLogic server ");
    throw ne;
    } catch (Exception e) {
    logStandardErrorMessage(e.toString());
    throw e;     
    Any advice would be really appreciated, I'm fast running out of ideas, I suspect
    it has something to do with the class loader but I'm not sure how to resolve it
    Regards
    Jo Corless

    Hello Joanne,
    Congratulations! I'm very happy that you've managed to fix your problem. It's
    always essential to understand how to package applications when deploying on BEA
    WebLogic. Usually, by throwing everything into an EAR file solves just about all
    the class loader problems. :-) Let us know if you have any further problems that
    we can assist you with.
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Joanne Corless" <[email protected]> wrote:
    >
    >
    I've fixed it!!!!!!!!
    Thanks to everyone who gave me help!!!!
    The class loader was the culprit which is what I suspected all along.
    As soon
    as I put the 2 jar files I was using into an EAR file the problem went
    away!!!!!
    Thanks again
    Jo Corless
    "Ryan LeCompte" <[email protected]> wrote:
    Hello Joanne,
    As Mr. Woollen mentioned, I also believe it's a problem with the class
    loader.
    You need to be careful how you arrange your EJBs, because WebLogic has
    a specific
    method in which it loads classes in an EAR, JAR, and WAR file(s). Please
    refer
    to http://dev2dev.bea.com/articles/musser.jsp for more information about
    BEA WebLogic
    class loading mechanisms and caveats. Also, try printing out the various
    methods
    that are available on the object that was returned to you via reflection.
    For
    example, use the getMethods() method, which returns an array of Method
    objects
    that you can subsequently cycle through and print out the various method
    names.
    This way you can discover if the class found/returned to you is indeed
    the one
    you intend to locate.
    Hope this helps,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    Rob Woollen <[email protected]> wrote:
    I believe the issue is the home interface class for this EJB is not
    available in the class loader which is doing the reflection.
    If you do:
    getClass().getClassLoader().loadClass(homeInterfaceClassName)
    I suspect it will fail. Reflection still requires that the class be
    loadable.
    -- Rob
    Joanne Corless wrote:
    Hi Slava,
    If I make my code look like you describe below I get a compliationerror telling
    me that
    home.getMethod() is not recognised (no such method)
    If I change it slightly and use
    Method homeCreateMethod =
    home.getClass().getMethod(homeCreate,homeCreateParam);
    The code will compile OK but when executed it still throws a NoSuchMethodException
    Any ideas ?
    Thanks for your help so far
    Regards
    Jo Corless
    Your code should look like
    Object home = pCtx.lookup(pJNDIName);
    Method homeCreateMethod =
    home.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    Regards,
    Slava Imeshev
    "Joanne Corless" <[email protected]> wrote in message
    news:[email protected]...
    Hi Ryan,
    I also wanted to mention that if you do a "header search" in this
    particular
    newsgroup
    with the search query as "reflection", you will see many previousmessages
    regarding
    reflection and EJBs. I believe you could learn a lot from thedifficulties
    that
    others have faced and solved.I tried that and although there was a number of similar cases noneof them
    actually
    seem to fix my issue. Thanks for the suggestion though
    Are the EJBs that you are trying to access accessible via your
    system
    classpath?
    Try to avoid having them accessible via the main system classpath,and
    only bundle
    them in your appropriate EJB jar files (contained in an EAR file,for
    example).Maybe I should have laid the problem out a little clearer.
    I have a number of EJB's bundled up in a JAR file which is hot deployedto
    the
    server. Within this first JAR file is an EJB (SSB) component that
    needs
    to
    be
    able to invoke a known method on another EJB. This second EJB may
    or
    may
    not be
    within the first JAR file but it also will be hot deployed.
    The component trying to invoke the method on the 2nd EJB has to
    be
    able to
    create
    an instance of the 2nd EJB without actually knowing anything bar
    a
    JNDI
    Name which
    is passed in at runtime.
    I can get as far as doing the
    Object home = pCtx.lookup(pJNDIName);
    This returned a class with the name
    "com.csc.edc.projects.allders.httppostoffice.postman.PostmanBean_mp8qy2_Home
    Impl_WLStub"
    My problem seems to occur when I try and invoke the create method
    Method homeCreate = home.getClass().getMethod("create", new Class[0]);
    My code throws a java.lang.NoSuchMethodException at this point so
    I
    am
    unable
    to progress to the next step of :
    Object bean = homeCreate.invoke(home, null);
    So I can return the instantiated bean back to the calling client.
    Why am I getting the NoSuchMethodException, is is because I am gettinga
    stub
    back rather than the home interface and if so how do I get the truehome
    interface
    from the bean
    Thanks in advance
    Jo Corless

  • Dynamic creation of class objects?

    I have a requirement where in at runtime I would know the class name, method name, properties, interface..and coding lines to be put into a method?
    Can anyone suggest a way to create the consumable central class object with these details, activate it and without any manual intervention create this object in backend?

    From other thread...use SEO* package

  • Is it possible to make a search help with dynamic  selection table?

    Hi Experts,
    Is it possible to create search helps with dynamic seletion tables means
    i dont know the selection table names at the time of creation of search help.
    These tables will be determined at runtime.
    if yes, Please give an idea how to create and pass the table names at runtime.
    Thanks
    Yogesh Gupta

    Hi Yogesh,
    Create and fill your itab and show it with FM F4IF_INT_TABLE_VALUE_REQUEST
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'field to return from itab'
          dynpprog        = sy-repid
          dynpnr          = sy-dynnr
          dynprofield     = 'field on your screen to be filled'
          stepl           = sy-stepl
          window_title    = 'some text'
          value_org       = 'S'
        TABLES
          value_tab       = itab
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
    Darley

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • Need help with Dynamic Excel File Name please.

    I am try to output an excel file with dynamic date. 
    Here what I done.
    I am using SQL 2012.
    Create Execute SQL Task Connect Type: Excel
    Create Data Flow Task set to DelayValidation: True
    Create OLE DB Sourc
    Create Data Converstion
    Excel Destination
    Excel Connection, Expression, select ExcelFilePath
    @[User::sXLFilePath] +  @[User::sFileName] + RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", GETDATE()), 2)+ RIGHT("0" + (DT_WSTR, 2) DATEPART("MM", GETDATE()), 2) + RIGHT((DT_WSTR,
    4) DATEPART("YYYY", GETDATE()), 2) +".csv"
    C:\ExcelOutPut\SOX_CAM_SQL_Report_010215.xls
    What I try to accomplish is output the file with each day append to it, date must be DDMMYY.
    I google it and found many samples, tested it, and none of them is work for me. 
    Any suggestions or some examples to share is greatly appreciate. 
    I am new to SSIS.  I found one poster have similar issue and inside the posted below, there was one suggestion to create variable and connection string but how do I bind that variable to Excel Connection manger.
    Please help.
    Thank you so much in advance.
    Ex: SOX_CAM_SQL_Report _020215.csv
           SOX_CAM_SQL_Report _030215.csv
    --Similar issue:
    https://social.msdn.microsoft.com/Forums/en-US/bda433aa-c8f8-47c9-9e56-efd20b8354ac/creating-a-dynamic-excel-file?forum=sqlintegrationservices
    Suggestion in the above posted but where can bind this to Excel Connection Manger. 
    Please help provide step by step.  Thanks.
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\temp\\" + "ExcelTarget" + (DT_WSTR,4)DATEPART("yyyy",GETDATE())  +
    ".xls" + ";Extended Properties=\"EXCEL 8.0;HDR=YES\";"
    And yes, as you were intimating, the delay validation on the dataflow should be set.

    Hi NguyenBL,
    According to your description, you created ssis package to export data from database to excel, when the package runs, you want to create new excel and name the file with time stamp. If that is the case, we can achieve the goal by following steps:
    Create a script task used to create excel files.
    Create a data flow task to export data from database to excel.
    Add OLE DB source to data flow task.
    Add Excel Destination to data flow task.
    Create connection manager for OLE DB and Excel.
    Click Excel Connection Manager, in Properties window, click (…) button next to Expressions, then set ExcelFilePath with expression like below:
    "C:\\ETL Lab\\CreateNewExcel\\ExportData_"+REPLACE((DT_STR, 20, 1252)(DT_DBTIMESTAMP)@[System::StartTime], ":", "")+".xls"
    For detail information, please refer to the document:
    https://sqljourney.wordpress.com/2013/01/12/ssis-create-new-excel-file-dynamically-to-export-data/
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • Dynamic Creation of Class Name

    I just want to create the class name on the fly.
    Look the example below.
    String className = "gui.Header";
    className header = new className;
    Let's assume that there is a Header class somewhere.
    Is this possible? or is there a way to do this?

    From what i understand, u wish to create an instance of a class whose name is known to you at runtime - correct me if i'm wrong - i'll answer based on my assumption. You can basically do that using Reflection in Java. I'm pasting sample code which shows how you do this:
    The following sample program creates an instance of the Rectangle class using the no-argument constructor by calling the newInstance method:
    import java.lang.reflect.*;
    import java.awt.*;
    class SampleNoArg {
    public static void main(String[] args) {
    Rectangle r = (Rectangle) createObject("java.awt.Rectangle");
    System.out.println(r.toString());
    static Object createObject(String className) {
    Object object = null;
    try {
    Class classDefinition = Class.forName(className);
    object = classDefinition.newInstance();
    } catch (InstantiationException e) {
    System.out.println(e);
    } catch (IllegalAccessException e) {
    System.out.println(e);
    } catch (ClassNotFoundException e) {
    System.out.println(e);
    return object;
    Hope the above helps.
    John Morrison

  • Please help with dynamic menu creation needs to have 5 levels

    Hi,
    I have run into a Coldfusion problem that I was hoping you
    could help me with.
    What I am trying to solve is the dynamic creation of at least
    5 levels of categories for a menu built with Coldfusion, and if
    possible an infinite amount of levels.
    Each of these also if it is at the end of the tree will have
    to have products under it aswell the category will only show up if
    there is products under it.
    To acomplish this I have created a database table called
    "Categories" which contains the fields shown in the linked
    spreadsheet. I am using the "cat_parent" to hold the value of the
    parent of the current record. When the parent is a top level menu
    item I have assigned this a cat_parent id of "0". Using this method
    I am able to do a self join on the table (where "cat_parent" =
    "cat_id") to extract the relationship between parent and child
    records throughout the table. This works fine. And I have created
    output for 5 levels of display.
    There are 3 issues left that I could not work out.
    - Firstly my coding method loops through each node of the
    tree with one query to create each category of the menu. This means
    one query per menu category and as the client could have up to 200
    categories in the menu and I am concerned that the solution that I
    have come up with is too processor intensive.
    - Secondly the way that I have created the category menu is
    hard coding in the levels needed so there is only 5 not an infinite
    amount which would be preferable but is not essential.
    - Finally I could not work out how to not create "parents" in
    the tree if there is no products for the end child category.
    Meaning that if there is for example a category > subcategory
    > subsubcategory but there is no products associated with the
    end category - "subsubsubcategory" then it's parent and so on will
    not display until one of them has products.
    Here
    is a link to a zip file that includes: the cfc that contains
    the query function (categories.cfc), the page that is creating the
    categories menu (lefnav.cfm), a simple cfc that contains a products
    query just for testing (products.cfc) along with a spreadsheet of
    the Categories table's fields.
    I would greatly appreciate any suggestions.
    Thanks for any time and help you can give me on this

    This should at least get you started in the right direction.
    http://www.sitepoint.com/article/dynamic-menu-coldfusion
    Bryan Ashcraft (remove brain to reply)
    Web Application Developer
    Wright Medical Technologies, Inc.
    =============================
    Macromedia Certified Dreamweaver Developer
    Adobe Community Expert (DW) ::
    http://www.macromedia.com/go/team
    "shunnyboy" <[email protected]> wrote in
    message
    news:e2h9hs$kp5$[email protected]..
    > Hi,
    >
    > I have run into a Coldfusion problem that I was hoping
    you could help me
    > with.
    >
    > What I am trying to solve is the dynamic creation of at
    least 5 levels of
    > categories for a menu built with Coldfusion, and if
    possible an infinite
    > amount
    > of levels.

  • Help with dynamic text and and css !

    My second question of the day.
    I'm trying to build a feature in my app in which the user can
    hide/reveal
    bolding and or
    italics and or
    underlining. The text is being loaded in from an xml file
    and I was thinking about styling it with css in order to get the
    underlining. My problem is that the only way I can think about
    pulling this off is to have a css style sheet that has a defined
    bold,italic and underline class defined- - then another one that
    just has a italic and underline class defined -- then another one
    that has just a bold and underline class defined . . . and so on
    and so on. You can see why I would prefer a much more streamlined
    system. Unfortunately my experience with dynamic text styling is
    somewhat limited. Hopefully someone can help me out here.

    Perfect. I knew it was some little snippet that I was
    forgetting. I made a temporary fix of creating a 0% alpha box over
    the button like a fake click area above the text, and that worked
    but I know that it was a half-arsed way of working around it.
    Thanks.

  • Dealing with functions not in class Object

    Hi,
    while i was working on GJ i faced the following problem, when i write a generic class i have to take into my consideration those functions that i want to define for the row type class and not included in class Object (toSting() is in class Object but print() is not). of course every time i want to call print() from the generic class the compiler gives me an error becuz it is not in class Object.. is there anyway to get rid of this problem in a simple way without having to deal with more than one row type ?
    thanks everyone

    I think I see what you're getting at...the GJ compiler substitues Object for all unconstrained type parameters, and therefore tries to call methods on parametized type objects as if they were simply of type Object.
    A solution would be to create a base class (or interface) AbstractRow that declares all the methods you need. Then constrain your parameters against AbstractRow. Eg:
    public interface AbstractRow
    public AbstractRow rowMethod();
    public class MyClass<RowType extends AbstractRow>
    public RowType doSomething(RowType rt) {
    rt.rowMethod();
    I think that should work. I'm not sure what you meant by "without having to deal with more than one row type." If you meant "without having to introduce an inheritance hierarchy," then no, this is not possible in GJ (as far as I can tell). If you meant "without having to write adapters for every single row type," then yes.
    shaun

  • Help with dynamic page layouts

    Hello JSP Gurus,
    I'm attempting to dynamically generate the page layout for my site based on the organization a user belongs to. Basically, I'd have certain resources like navigation links, graphics, etc, that are modular. Then I'd like to construct the layout using these "moduls" in a dynamic fashion. Does anyone have any suggestions on techniques or technologies that would be useful? I'm not really looking at the portal/portlet model. Is this something that Cocoon could do by storing the layout for each customer as an XML file or something? Any ideas, suggestions, experiences would be helpful.
    Thanks!

    How does Tiles differ from the JetSpeed apache
    project? They both appear to be portal-like
    frameworks, or am I incorrect about that? Which is
    preferred?Frankly, I can't give you an in-depth answer to that. Maybe someone else can help with more details.
    What I can tell you is that JetSpeed seems to be more of a real portal architecture. Emphasis is placed on the framework portion, interfacing with exisiting applications. Visual layout takes second seat to this.
    Tiles on the other hand puts more emphasis on visual layout and reuse.
    Just looking at JetSpeed's visual interfacing a little bit makes me really dislike it. You build tables and such inside of a servlet, so there's a tight coupling (or at least, much tighter than with Struts/Tiles) between the presentation and logic. (I'm basing this on a JavaWorld article at
    http://www.javaworld.com/javaworld/jw-07-2001/jw-0727-jetspeed.html )
    Based on your initial question, it would seem to me that tiles is much closer to what you're looking for (and likely easier to just pick up and use).
    Anyway, take all this with a grain of salt; I'm not exactly an expert on JetSpeed. =)

  • Help with dynamic playlist for mpd

    Hi guys,
    I use mpd with sonata for playing my music, and after trying exaile there is one thing id really like for mpd, and that is the dynamic playlist function.
    When you're playing a song in exaile with dynamic playlist enabled, it queries audioscrobbler and automatically adds similar artists/songs to your playlist (if you have them on your pc).
    I dont want to use exaile as it just feels too big and slow and bloated (not KISS ), i know a little bit of python so i thought i'll try and make my own little script/program as Sonata has audioscrobbler support, but i dont think there is anyway to query similar artists.
    I think im going to try and make this as a daemon type program that will run in the background adding songs to the playlist.
    Ive found the code from the exaile source (audioscrobbler.py) which queries lastfm e.g.
    >>> lips = AudioScrobblerQuery(artist='The Flaming Lips')
    >>> for artist in lips.similar():
    ... print artist.name, artist.mbid
    This will print a list of similar artists to the flaming lips.
    I've not done much with python so i thought this would be a good way to try and improve.
    Does anyone have any suggestions as to what the best way to go about searching and comparing the results to my mpd database, would the best way just to be to search the mpd.db?
    And if anyone else has any ideas/comments id like to hear them.
    Edit:
    I just found this too, so i may only need to change some things to integrate it with mpd rather than amarok
    http://www.kde-apps.org/content/show.php?content=31920
    Thanks
    Last edited by Kane (2008-06-05 13:24:33)

    well i just modified the patch into a little script, it does what i need
    its here if anyone wants it
    import audioscrobbler
    import mpd
    import random
    import time
    lastsong = {}
    def timer_control():
    get_similar()
    time.sleep(10)
    timer_control()
    def get_similar():
    audioscrobbler
    client = mpd.MPDClient()
    client.connect("localhost", 6600)
    mpdstatus = client.status()
    prevsonginfo = client.currentsong()
    global lastsong
    if mpdstatus['state'] == "stop": return
    if prevsonginfo == lastsong: return
    lastsong = prevsonginfo
    similarartists = ""
    song = prevsonginfo
    #if not song: break #No song, do nothing
    prevartist = song['artist']
    # Is the info already cached?
    similar_cache = {}
    if similar_cache.has_key(prevartist):
    similarartists = similar_cache[prevartist]
    else:
    #Not cached so fetch from Audioscrobbler
    try:
    similarartists = [artist.name for artist in audioscrobbler.AudioScrobblerQuery(artist=prevartist).similar()]
    # Cache search results and save some time next search
    similar_cache[prevartist] = similarartists
    except audioscrobbler.AudioScrobblerError:
    similar_cache[prevartist] = None # Empty cache
    return # Do nothing!
    if not similarartists: return # Empty list
    # Split list in half and sort upper half
    # this means good matches will have priority
    # but makes sure artist A does not always result in artist B
    half_idx = len(similarartists)/2
    upperhalf = similarartists[:half_idx]
    lowerhalf = similarartists[half_idx:]
    random.shuffle(upperhalf)
    artistlist = upperhalf
    artistlist.extend(lowerhalf)
    # Try each artist in order
    for artist in artistlist:
    try:
    print "Trying:",artist
    songs = client.search("artist", artist)
    if not songs: continue
    selected_song = random.sample(songs, 1)[0]
    client.add(selected_song['file'])
    print "Added", selected_song['title'],"by",selected_song['artist']
    # Delete old song from playlist?
    break
    except mpd.MPDError, e:
    print "MPDError", e.message
    continue
    except ValueError, e:
    print "ValueError:",e.message
    continue
    timer_control()
    Last edited by Kane (2008-06-06 16:22:49)

  • URGENT: Help with dynamic borders!

    Hello all -
    I DESPERATLY need help with this! I am using the code from
    kirupa's xml photo gallery with the thumbnails. right now the alpha
    changes on mouseover, fine...but my client is demanding that it
    draw a border instead. I have been at this for about a week and
    have NO idea how to do this...i have looked at things like API's
    and things...but my main issue is that the images and MC's are all
    created on the fly and i dont know how to code in an on mouseover
    draw a border type of function, no idea at all!
    This is my code as it sits now, PLEASE SOMEONE HELP ME!!!
    thank you in advance!

    really could use some help quick here guys

  • Help with dynamic statement returning values into collection

    Hi All
    I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
    create table t(
        pk number,
        id_batch varchar2(30),
        date_created date,
        constraint t_pk primary key ( pk )
    create or replace type num_ntt is table of number;
    create or replace type vc2_ntt is table of varchar2(30);
    create or replace
    package pkg
    as
      type rec is record(
          pk        num_ntt,    
          id_batch  vc2_ntt
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
    end pkg;
    create or replace
    package body pkg
    as
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
      is
      begin
          execute immediate '
          insert into t
          select level, ''x'' || level, sysdate
          from   dual
          connect by level <= :p_count
          returning pk, id_batch into :pk, :id_batch'
          using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
      end p;
    end pkg;
    declare
      r  pkg.rec;
    begin
      pkg.p( 5, r );
    end;
    /

    sanjeevchauhan wrote:
    but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
    By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
    Regards,
    Rob.

  • Help with dynamic SQL

    Hello,
    I have the following function that works ok:
    CREATE OR REPLACE FUNCTION Get_Partition_Name (sTable VARCHAR2, iImportIndex INTEGER)
    RETURN VARCHAR2 IS
    cursor c is select A.partition_name from (select table_name, partition_name,
    extractvalue (
    dbms_xmlgen.
    getxmltype (
    'select high_value from all_tab_partitions where table_name='''
    || table_name
    || ''' and table_owner = '''
    || table_owner
    || ''' and partition_name = '''
    || partition_name
    || ''''),
    '//text()') import_value from all_tab_partitions) A where table_name = sTable and A.import_value = iImportIndex;
    sPartitionName VARCHAR(20);
    err_num NUMBER;
    BEGIN
    open c;
    fetch c into sPartitionName;
    IF c%ISOPEN THEN
    CLOSE c;
    END IF;
    RETURN sPartitionName;
    EXCEPTION
    WHEN OTHERS THEN
    err_num := SQLCODE;
    --save error in log table
    LOG.SAVELINE(SQLCODE, SQLERRM);
    END Get_Partition_Name;
    I am trying to replace the cursor statement with dynamic SQL, something like (see below) but it doesn't work any more; I think I am missing some quotes.
    CREATE OR REPLACE FUNCTION Get_Partition_Name (sTable VARCHAR2, iImportIndex INTEGER)
    RETURN VARCHAR2 IS
    TYPE t1 IS REF CURSOR;
    c t1;
    sSql VARCHAR2(500);
    sPartitionName VARCHAR(20);
    err_num NUMBER;
    BEGIN
    sSql := 'select A.partition_name from (select table_name, partition_name,
    extractvalue (
    dbms_xmlgen.
    getxmltype (
    ''select high_value from all_tab_partitions where table_name=''''
    || table_name
    || '''' and table_owner = ''''
    || table_owner
    || '''' and partition_name = ''''
    || partition_name
    || ''''''),
    ''//text()'') import_value from all_tab_partitions) A where table_name = :a and A.import_value = :b';
    OPEN c FOR sSql USING sTable, iImportIndex;
    fetch c into sPartitionName;
    IF c%ISOPEN THEN
    CLOSE c;
    END IF;
    RETURN sPartitionName;
    EXCEPTION
    WHEN OTHERS THEN
    err_num := SQLCODE;
    --save error in log table
    LOG.SAVELINE(SQLCODE, SQLERRM);
    END Get_Partition_Name;
    Please advise,
    Regards,
    M.R.

    Assuming the requirement is to find the partition in the supplied table with the supplied high value and the issue is that dba/all_tab_partitions.high_value is a long, one alternative along the same lines as you've done already is as follows. (I've just used a cursor rather than a function for simplicity of demo).
    SQL> var r refcursor
    SQL> set autoprint on
    SQL> declare
      2   ctx dbms_xmlgen.ctxhandle;
      3   v_table_name VARCHAR2(40) := 'LOGMNR_USER$';
      4   v_value      NUMBER       := 100;
      5  begin
      6   ctx := DBMS_XMLGEN.NEWCONTEXT
      7          ('select table_name
      8            ,      partition_name
      9            ,      high_value  hi_val
    10            from   dba_tab_partitions
    11            where  table_name     = :table_name');
    12   dbms_xmlgen.setbindvalue(ctx,'TABLE_NAME',v_table_name);
    13   open:r for
    14   with x as
    15   (select xmltype(dbms_xmlgen.getxml(ctx)) myxml
    16    from   dual)
    17   select extractvalue(x.object_value,'/ROW/TABLE_NAME') table_name
    18   ,      extractvalue(x.object_value,'/ROW/PARTITION_NAME') partition_name
    19   ,      extractvalue(x.object_value,'/ROW/HI_VAL') hi_val
    20   from   x
    21   ,      TABLE(XMLSEQUENCE(EXTRACT(x.myxml,'/ROWSET/ROW'))) x
    22   where  extractvalue(x.object_value,'/ROW/HI_VAL') = v_value;
    23  end;
    24  /
    PL/SQL procedure successfully completed.
    TABLE_NAME
    PARTITION_NAME
    HI_VAL
    LOGMNR_USER$
    P_LESSTHAN100
    100
    SQL> I'm sure there are other ways as well. Especially with XML functionality, there's normally many ways to skin a cat.

Maybe you are looking for

  • Error while trying to open custom page

    Hi, I am getting error message "You have encountered an unexpected error. Please contact the System Administrator for assistance. " while trying to access the new custom page i developed. i have imported the page definition to MDS and copied all the

  • Can i get a custom home page URL with APEX ?

    My name is Srinivas and i work for a top telecom company in North Carolina and i am a Oracle DBA here. We want to move away from spreadsheets about our typical DBA information and statistics and reports and move to Oracle APEX (formerly HTML DB). I w

  • DataSource 2LIS_11_VAHDR does not exist in source system ECDCLNT100 of vers

    Hi iam working on BI 7 and ECC 6 system. When i try to install the transfer rules for 2 lis_11_vahdr in BI7 business content, it gave a message that "<b>DataSource 2LIS_11_VAHDR does not exist in source system ECDCLNT100 of version A".</b> i have don

  • Apple tv slow

    New apple customer here. Purchased a brand new apple tv yesterday and attempted to watch a movie just now. It says ready to play in 2 hours 20 mins! Surely this is wrong? Done a connection speed check and that says 11 Mbps so it's not a connection is

  • Using the imic with a midi keyboard.

    I'm trying to get my Casio to work with my mac, but the driver from Google code won't work. So I was wondering, could I connect my casio (from the midi out) to the iMic? Or is the iMic not midi compatible?