Help needed in designing dynamic images

Hi,
I just posted a thread before, but there is something wrong in that post.
Any ways, I am new to Java and am trying to design a GUI which has images, which change dynamically. One of the examples is on this webpage
http://images.google.com/imgres?imgurl=http://www.snapstream.com/images/blog/godzilla/overheating_max_cpu_tn.jpg&imgrefurl=http://blogs.snapstream.com/2006/01/18/godzilla-pvr/&h=516&w=683&sz=80&hl=en&start=3&tbnid=huDY6gDdtS_o-M:&tbnh=105&tbnw=139&prev=/images%3Fq%3DCPU%2Btemperature%26gbv%3D2%26svnum%3D10%26hl%3Den%26sa%3DG
I need help desperately. I would appreciate, if you can help me. What do i need to use? Can it be done by using Swing? Are there any good examples of it on web? I am basically not clear, what do I need to use...
waiting for your reply. thanks in advance.
Ankit

consider you have a JFrame called "frame"
what you can do:
JLabel lab = new JLabel("../firstPic.jpg");
frame.getContentPane().add(lab);
then, each time you will call "setIcon()" on the lab and refresh the frame it will display a new picture

Similar Messages

  • [HELP] need TX2 recovery DVD/Image

    [HELP] need TX2 recovery DVD/Image HP won't repair it b/c i dont have the original software....can someone provide me an image or i will pay $ for DVD plz full model is TX2-1024CA

    That is a notebook PC. Maybe this document will help? http://h10025.www1.hp.com/ewfrf/wc/document?docname=c00810334&cc=us&dlc=en&lc=en&jumpid=reg_R1002_US...
    ... an HP employee expressing his own opinion.
    Please post rather than send me a Message. It's good for the community and I might not be able to get back quickly. - Thank you.

  • Help needed in configuring Dynamic F4

    Hi All
    I am trying to configure Dynamic F4 help for Actvities appln.
    In Actvities Appln I have the Partners tab.In this Partner tab I have partner function and partner Id fields. When I make a search for partner Id  I need to launch  the search screen based on thepartner function selected.
    I guess we can use dynamic F4 help but how to achieve this I am not sure. If anyone has done simliar stuff please do give your inputs.
    Thanks
    Regards
    Senthil

    Hi Senthil,
    You can use Search Help Exit for your problem.
    <b>Search help exit</b> : A search help exit is a function module for making the input help process described by the search help more flexible than possible with the standard version.
    This function module must have the same interface as function module F4IF_SHLP_EXIT_EXAMPLE. The search help exit may also have further optional parameters (in particular any EXPORTING parameters).
    A search help exit is called at certain time points in the input help process.
    <b>Note:</b> The source text and long documentation of the above-specified function module (including the long documentation about the parameters) contain information about using search help exits.
    Function modules are provided in the function library for operations that are frequently executed in search help exits. The names of these function modules begin with the prefix F4UT_. These function modules can either be used directly as search help exits or used within other search help exits. You can find precise instructions for use in the long documentation for the corresponding function module.
    A search help exit is called repeatedly in connection with several
    Events during the F4 process. The relevant step of the process is passed on in the CALLCONTROL step. If the module is intended to perform only a few modifications before the step, CALLCONTROL-STEP should remain unchanged.
    However, if the step is performed completely by the module, the following step must be returned in CALLCONTROL-STEP.
    For more detailed information please refer to the documentation describing the concept of the search help exit.
    The module must react with an immediate EXIT to all steps that it does not know or does not want to handle.
    <b>Time Points</b> :
    During the input help process, a number of time points are defined that each define the beginning of an important operation of the input help process.
    If the input help process is defined with a search help having a search help exit, this search help exit is called at each of these time points. If required, the search help exit can also influence the process and even determine that the process should be continued at a different time point.
    The following time points are defined:
    <b>1. SELONE</b>
    Call before selecting an elementary search help. The possible elementary search helps are already in SHLP_TAB. This time point can be used in a search help exit of a collective search help to restrict the selection possibilities for the elementary search helps.
    Entries that are deleted from SHLP_TAB in this step are not offered in the elementary search help selection. If there is only one entry remaining in SHLP_TAB, the dialog box for selecting elementary search helps is skipped. You may not change the next time point.
    The time point is not accessed again if another elementary search help is to be selected during the dialog.
    <b>2. PRESEL1</b>
    After selecting an elementary search help. Table INTERFACE has not yet been copied to table SELOPT at this time point in the definition of the search help (type SHLP_DESCR_T). This means that you can still influence the attachment of the search help to the screen here. (Table INTERFACE contains the information about how the search help parameters are related to the screen fields).
    <b>3. PRESEL</b>
    Before sending the dialog box for restricting values.
    This time point is suitable for predefining the value restriction or for completely suppressing or copying the dialog.
    <b>4. SELECT</b>
    Before selecting the values. If you do not want the default selection, you should copy this time point with a search help exit. DISP should be set as the next time point.
    <b>5. DISP</b>
    Before displaying the hit list. This time point is suitable for restricting the values to be displayed, e.g. depending on authorizations.
    <b>6. RETURN</b> (usually as return value for the next time point)
    The RETURN time point should be returned as the next step if a single hit was selected in a search help exit.
    It can make sense to change the F4 flow at this time point if control of the process sequence of the Transaction should depend on the selected value (typical
    example: setting SET/GET parameters). However, you should note that the process will then depend on whether a value was entered manually or with an input help.
    <b>7. RETTOP</b>
    You only go to this time point if the input help is controlled by a collective search help. It directly follows the time point RETURN. The search help exit of the collective search help, however, is called at time point RETTOP.
    <b>8. EXIT</b> (only for return as next time point)
    The EXIT time point should be returned as the next step if the user had the opportunity to terminate the dialog within the search help exit.
    <b>9. CREATE</b>
    The CREATE time point is only accessed if the user selects the function "Create new values". This function is only available if field CUSTTAB of the control string CALLCONTROL was given a value not equal to SPACE earlier on.
    The name of the (customizing) table to be maintained is normally entered there. The next step returned after CREATE should be SELECT so that the newly entered value can be selected and then displayed.
    10. <b>APP1, APP2, APP3</b>
    If further pushbuttons are introduced in the hit list with function module F4UT_LIST_EXIT, these time points are introduced. They are accessed when the user presses the corresponding pushbutton.
    <b>Note:</b> If the F4 help is controlled by a collective search help, the search help exit of the collective search help is called at time points SELONE and RETTOP. (RETTOP only if the user selects a value.) At all other time points the search help exit of the selected elementary search help is called.
    If the F4 help is controlled by an elementary search help, time point RETTOP is not executed. The search help exit of the elementary search help is called at time point SELONE (at the moment). This search help exit should not do anything at this time point. Any preparatory work should be carried out at time point PRESEL1.
    <b>Steps for creating search help :</b>
    1. Run Transaction SE11
    2. Give search help name
    3. Click on Create
    4. Make selection for Elementary or Collective search
       Help
    <b>For Elementary Search Help</b>
    5. Elementary search Help screen.  
    6. Give short description.
    7. Dialog type specifies the data display in the hit
       list.
    8. Give selection method
    A] Search for database tables
    B] Search for Views
    9. Hot key specifies the letter or number displayed with every elementary search help. 
    10. Search help Exit: Specify the function module developed for the search of data for the elementary search help.
    11. Search help parameter
    A] Specify the input and output fields in the search help parameter column.
    B] IMP column is input parameter for the search help.
    C] EXP column is output parameter of the search help, to be displayed in the Hit list after selection.
    D] LPos specifies the order in which fields are displayed in the hit list.
    E] SPos specifies the order in which fields are displayed in the search help pop up screen.
    F] Specify Data element in the field.
    G] Specify the default value for any field required.
    <b>For Collective Search Help :</b>
    12. Search help exit: Specify the function module developed for the search of data for the elementary search help.
    13. Search help parameter: Specify the import and export parameters.          
    14. Search help: Specify the elementary search help and the short text.
    15. Parameter Assignment: Select the elementary search help and click on the parameter assignment. System proposes fields. User has to select the fields as per requirement, fields to be displayed in the output
    hit list. Parameter assignment has to be done compulsorily for every elementary search help designed for the collective search help.   
    <b>Please reward points if it helps.</b>
    Regards,
    Amit Mishra

  • Help needed for downloading the image from Inage URL

    Hello everyone,
    I need some help regarding setting a timeout for dowloading image from image URL
    Actually I have a hash table with set of image URL's...
    for example:
    http://z.about.com/d/politicalhumor/1/0/-/6/clinton_portrait.jpg
    which gives a image.
    for(Enumeration e = google_image_links.elements() ; e.hasMoreElements() ;) {
                                      //System.out.println("final");
                                       //System.out.println(e.nextElement());
                                       try{
                                            System.out.println("Images download started....");
                                            //System.out.println(e.nextElement());
              //imageio is the BufferedImagereader object     
                                               imageio = ImageIO.read(new URL((String) e.nextElement()));
                                            image_title = created_imagepath +"\\"+ array_words[i] + counter_image_download + "." + "jpg";
                                            img = ImageIO.write(imageio,"jpg", new File(image_title));     
                                            imageio.flush();
                                       }catch(Exception e1){
                                            System.out.print(e1);
                                       if(img){
                                            System.out.println("The image " + image_title + " has been saved to local disk succesfully.");
                                       counter_image_download++;
                                  }//end of for loopi am using the above code to download all the image from the Image URL's that r present in hashtable.
    The problem i have been encountered with is...
    Some URL's does not return any bytes, The code is not totally broken. In such cases, my code is hanging off at that particular URL and waiting to get some output data from the URL. The execution does not proceed furthur But if the URL is a totally broken link, the code is throwing an exception and I am able to handle it successfully.
    But in the case of partially broken links, I am not able to go furthur because the code keeps waiting to get some data.
    So for this reason I want to setup a timer and tell the code to wait for 5-10 min, in that time if it does not get any data, proceed furthur to download other links...
    Please tell me how can I do this.. or plzzz tell me an alternative...
    Please help me ans its a bit urgent plzzzz.
    Thank you,
    chaitanya

    Hello everyone,
    I need some help regarding setting a timeout for dowloading image from image URL
    Actually I have a hash table with set of image URL's...
    for example:
    http://z.about.com/d/politicalhumor/1/0/-/6/clinton_portrait.jpg
    which gives a image.
    for(Enumeration e = google_image_links.elements() ; e.hasMoreElements() ;) {
                                      //System.out.println("final");
                                       //System.out.println(e.nextElement());
                                       try{
                                            System.out.println("Images download started....");
                                            //System.out.println(e.nextElement());
              //imageio is the BufferedImagereader object     
                                               imageio = ImageIO.read(new URL((String) e.nextElement()));
                                            image_title = created_imagepath +"\\"+ array_words[i] + counter_image_download + "." + "jpg";
                                            img = ImageIO.write(imageio,"jpg", new File(image_title));     
                                            imageio.flush();
                                       }catch(Exception e1){
                                            System.out.print(e1);
                                       if(img){
                                            System.out.println("The image " + image_title + " has been saved to local disk succesfully.");
                                       counter_image_download++;
                                  }//end of for loopi am using the above code to download all the image from the Image URL's that r present in hashtable.
    The problem i have been encountered with is...
    Some URL's does not return any bytes, The code is not totally broken. In such cases, my code is hanging off at that particular URL and waiting to get some output data from the URL. The execution does not proceed furthur But if the URL is a totally broken link, the code is throwing an exception and I am able to handle it successfully.
    But in the case of partially broken links, I am not able to go furthur because the code keeps waiting to get some data.
    So for this reason I want to setup a timer and tell the code to wait for 5-10 min, in that time if it does not get any data, proceed furthur to download other links...
    Please tell me how can I do this.. or plzzz tell me an alternative...
    Please help me ans its a bit urgent plzzzz.
    Thank you,
    chaitanya

  • Help needed to add an image to a datagrid cell in actionscript

    Morning all,
    I am still quite new to flex development and I have an application which uses xml to populate a datagrid. One of the row columns should display a small image but I don't know how to do that.
    Can anyone show me how to add an image to a datagrid cell in actionscript?
    I've added a sample of the code I have written already below. Any help would be much appreciated.
    Thanks in advance,
    Xander
    My XM
    <?xml version="1.0" encoding="UTF-8"?>
    <dataset>
    <modules>
    <module id="1">
    <icon>assets/sample_image1.png</icon>
    <key>core</key>
    <name>Core</name>
    <description>Description of module</description>
    <installed>Wednesday, 24th June 2009 @ 15:59 UK</installed>
    </module>
    <module id="2">
    <icon>assets/sample_image2.png</icon>
    <key>webproject</key>
    <name>Web Project</name>
    <description>Description of module</description>
    <installed>Wednesday, 24th June 2009 @ 17:32 UK</installed>
    </module>
    </modules>
    </dataset>
    My Actionscript
    private function dataSetHandler(event:Event):void {
        var ds:XML = new XML(event.target.data);
        var rows:XMLList = ds.elements('modules').elements('module') as XMLList;
        var columns:Array = new Array();
        for (var i:int=0; i<rows[0].elements().length(); i++) {
            var column:DataGridColumn = new DataGridColumn();
            var tag:String = rows.*[i].name();
            column.headerText = rows.*[i].name();
            column.dataField = rows.*[i].name();
            if (tag == 'icon') {
                var img:Image = new Image();
                img.id = "iconpath";
                img.width = 23;
                img.height = 20;
                img.source = rows.*[i].name();
               column.itemRenderer = img;   <-- this line shows as an error when I try to compile
            columns[i] = column;
        mydatagrid.columns = columns;
        mydatagrid.dataProvider = rows;

    you cant just set image object to itemrenderer, you need to use classfactory.
    http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_4.html

  • Help Needed! To upload image to db2 using struts & hibernation[code inside]

    Hi all, currently i have successfully created the application for inserting text data into my db2 through the use of struts with hibernation. But i need to insert image now which seems to be different from just inserting text data.
    From my understanding, the image will be converted to bytes and store as Blob in my db2, but i need hlp in knowing how to do this, i did a search and i found the following codes posted by another guy in this forum but he did not reply his thread at all...i am feeling very puzzel about the last file which is /RegPersonalDetails.java. Did he missed out a bean file?? which is the TempPhoto bean? i really do not understand the last file, The first file is the JSP , the second is the bean and the third is the Action class. i did exactly the same as his but i do not know how to use the RegPersonalDetails.java. please help thanks.. i am using websphere studio 5 and hibernate 2.
    Below is the example i got from the guy:
    //Registration.jsp
    --Below is the script for image type validation.
    <script>
    var fileTypes=["bmp","gif","png","jpg","jpeg","tif","tiff","jif","jfif","jp2","jpx" ,"j2k","j2c","fpx","pcd" ];
    function preview(what){
    var source=what.value;
    var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
    for (var i=0; i<fileTypes.length; i++) if (fileTypes==ext) break;
    var globalPic=new Image();
    if (!(i><fileTypes.length)){
    alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
    what.fileUpload.focus();
    return false;
    else
    return true;
    </script>--You have to write relevent code for view.For browse filed i given below
    <INPUT type=file name="fileUpload" onchange="preview(this)">
    ===============================================================
    //RegistrationForm.java
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public class Regstep5Form extends ActionForm {
    private FormFile fileUpload;
    public FormFile getFileUpload() {
    return fileUpload;
    public void setFileUpload(FormFile fileUpload) {
    this.fileUpload = fileUpload;
    ===================================================================
    //RegistrationAction.java
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.upload.FormFile;
    public class Regstep5Action extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception, ServletException {
    Regstep5Form rf= (Regstep5Form)form;
    FormFile myFile = rf.getFileUpload();
    String contentType = myFile.getContentType();
    String fileName = myFile.getFileName();
    int fileSize = myFile.getFileSize();
    byte[] fileData = myFile.getFileData();
    String result=RegPersonalDetails.process(rf);
    System.out.println("result taken");
    return mapping.findForward("success");
    ===================================================================
    //RegPersonalDetails.java
    import com.model.orm.TempPhoto;
    import com.util.HibernateUtil;
    import org.hibernate.*;
    import java.io.*;
    import org.apache.struts.upload.*;
    public class RegPersonalDetails {
    public static String process(Regstep5Form rf) throws Exception {
    TempPhoto temp=new TempPhoto();
    Session session=null;
    Transaction tx=null;
    try{
    session = HibernateUtil.getSession();
    tx = session.beginTransaction();
    String uname=rf.getUserId();
    FormFile myFile=rf.getFileUpload();
    byte[] filedata=myFile.getFileData();
    temp.setUserId(uname);
    temp.setPhoto(filedata);
    session.saveOrUpdate(temp);
    tx.commit();
    }catch(Exception ex){ }
    finally{
    HibernateUtil.closeSession();
    return "success";
    --Here TempPhoto is the pojo class i.e hibernate generated class for the table in which we have to insert image...
    --You will understand this if u have idea of hibernate..
    --There may some import as statements missing...try it and configure your "struts-config.xml" file with the above files.
    Message was edited by:
    HaRou

    haha....that thread starter is my friend siting next to me....he is having problem with struts and jsp only, which you already solve the problem for him.. but i need to know how to do the same thing with hibernate...pls hlp?

  • Adobe PE8 Help needed...blocky images when in play mode.

    I have a Problem with blobby images and frame rates ( not sure if frame rates is the correct word!)
    I'm attempting to captured my DVD from disc onto the program, which i have done, It loads ok, however it seems to be all blobby, blocky squares on the screen, as soon as it run plays.  The audio runs fine.
    My system in case anyone wants to know is Dell Dimension DXP051  Intel(R) Pentuim(R) 4CPU 3.00 Ghz 2.99 Ghz 3.50 gb RAM, although there is 4gb in there, i have added the rest in the past 6 months !, why it only show 3.5 i don't know! 1 x 160 gb HDD, 1 x 500 HDD, both internal and a 1.5 TB external HDD, plenty of HDD space! although i'm not sure if the RAM is enough? i have quite a few software programs, however I never have more than 1-4 running at the same time, only have PE8 running on its own at the moment.
    Anyway going back to my issue, it seems to do this even if i put 3,4 images in the timeline, ( on a seperate project) is this an issue with my PC, graphics card to do with PE8, I have installed the updates by the way. Any help would be appreciated.
    I do not seem to have this issue with other picture programes.
    Thanks
    Andrew

    Andrew,
    Glad that things went well. One needs to read the instructions for each driver, and never trust that the procedure is exactly as it was only a month ago for the same card. Normally, it is and is only a simple download and execute, but I have seen times, where one had to first disable certain features in the card driver's console first. Always check carefully.
    The two main drivers to be aware of are the video and the audio, as they often get broken by OS updates. Next most likely is not really a driver, but the firmware in one's DVD burner. Those get replaced about every 6 mos. +/-. Many of the other drivers are provided by the OS, but there can be many exceptions.
    There are some utilities, that claim to get all necessary drivers on a system updated automatically. I have never seen one that worked very well. This is especially true with the video and audio drivers. What those utilities say is up to date is usually 9 mos. out of date and maybe 6-10 updates out. I would not trust such utilities, and would just do it by hand and get the drivers from the mfgr's. site, at the first sign of trouble.
    Good luck,
    Hunt

  • LiveCycle Designer dynamic images

    What route would i need to take to dynamically include images in a pdf page.  What i would like to do is have a user be able to upload screenshots and they be included in the pdf form.  I was able to manipulate the image field object by putting in an image in there programatically with Coldfusion, but I dont like the fact that when you click on the image field it prompts you to select a file etc.  Can this be disabled?  Also the image field wasnt dynamic.  Can i convert an image field into an image type programatically as well?
    Just trying to figure out LiveCycle.
    Thanks

    Not doable in LC 7.1 or 8.

  • Help needed; underscore in rollover image name will not validate at WC3

    GoLive CS on an Intel PC
    UTF8 encoded, HTML 4.01 Transitional
    I have several rollovers in a page created by using the GoLive palletes, and because GoLive automatically adds an underscore to an image name in a nested folder the page cannot validate at the WC3 site. What do I need to do so that the underscore will not be added automatically? I've tried adding a name/ID to the image before creating the rollover, but it disregards the name and uses what it thinks is best, adding the underscore.
    The page is located here:
    http://www.redshift.com/~lorac/sdy-55.html
    I have attached three images that show the file names used and the results in the GoLive pallete. The first is a screenshot of the folder structure, the second is the placed image pallete and the third is the rollover pallete view.GoLive is set to strip all the GoLive code from the page before uploading, so the web version will not have any GL code.
    A sample WC3 comment is:
    Line 86, Column 226:         value of attribute "ID" invalid: "_" cannot start a name
    …pg');return true" href="#"><img id="_5502" class="img_border" src="images/jhj

    It is possible that you violated the naming convention for this attribute.       For example, id and name attributes must begin with       a letter, not a digit.
    Do I need to unnest any folders with potential rollover images? That would be a real pain... considering the amount sections and images used in the site.
    Thank you in advance for any help you can give.
    Carol

    I did as you suggested and added to the beginning of the default underscored name in the "name/ID" section and it was accepted. I changed all the rollover image names and uploaded the modified page, and was then able to validate at the WC3 validation site.
    Thank you so much! It was an easy fix... a solution I had overlooked. Oddly enough this never occurs with a remote rollover, but that is probably because GL lets you name the base image without suggesting a name first.
    Carol

  • Help needed in defaulting Dynamic assignment blocks

    Hi All,
    We are trying to default assignment blocks based on the configuration saved against each object type.
    Procedure followed is as below
    Created 2 configurations, one for sold to party and the other one for ship to party in the BP_Head cpmponent for the Overview page. Two configurations of the overview page are saved against a role config key but with a variant of object type
    Created two logical link IDs one each for sold to party and ship to party
    Make these two logical link IDs available in the UI as direct link groups
    Upon clicking sold to party the configuration saved against that(Set of assignment blocks in the overview page) needs to be called (Remember we saved this configuration with a variant of object type)
    Similarly when clicking on the ship to party link corresponding configuration (Set of assignment blocks in the overview page) needs to be displayed
    Any inputs on this will be of great help.
    Regards,
    udaya

    you need to redefine the method DO_CONFIG_DETERMINATION of your controller
    there you get the role and any other needed values, and you define the OBJECT_TYPE and SUBTYPE that will be used as key fields for the configuration

  • Help needed on designing the structure of a flash game

    Hi,
    I am studying the codes from http://www.emanueleferonato.com/2009/01/16/designing-the-structure-of-a-flash-game-as3-ver sion-part-3/. What I don't get is at level_selection.as. Where does main_menu_button come from? I can't find where it has been created. I only see main_menu, not main_menu_button.
    Please help.

    The codes in level_selection.as looks like this, but the problem is I cannot find main_menu_button anywhere, except for main_menu.
    package {
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.display.SimpleButton;
        public class level_selection extends Sprite {
            public var main_class:the_game;
            private var level_thumb:level_thumbnail;
            public function level_selection(passed_class:the_game) {
                main_class = passed_class;
                for (var i:int = 1; i<=5; i++) {
                    level_thumb = new level_thumbnail(i,main_class);
                    addChild(level_thumb);
                main_menu_button.addEventListener(MouseEvent.CLICK, on_main_menu_button_clicked);
            public function on_main_menu_button_clicked(event:MouseEvent) {
                main_class.show_splash();

  • Help needed to design Greenhouse control system

    Has anyone designed a complete system with weather station, nutrient mixing etc

    Kahlid,
    I would appreciate some help with my greenhouse.  I'm just getting ready to design a small facility to learn on.  I have a lot of LV experience and want to use that to build an automated greenhouse for house plants.  Any help or info on where to obtain some help would be greatly appreciated.
    Thanks,
    Hal Curling

  • Help need for loading aligned images in JEditorpane

    Hi all,
    I need to align image with text using JEditorpane, If i load the html document with aligned image, there is no alignment for image in final display. So please suggest any ideas if u have on this topic. I am in great hurry.
    Thanks in advance,
    Nageswara Rao.V

    Hello,
    I'm also having the same problem, did anybody find any solution ?
    -sanjaymishra70

  • Help needed in debugging dynamic SQL.

    When I pass the p_deptno =30 and run the below code the refcursor returns the rows.But when I pass the dpetno =null then it goes to the condition if p_job is not null and throws an error.Can any one please help me in debugging this code.
    declare
    p_deptno number:=null;
    p_job varchar2(30):='SALESMAN';
    v_sql varchar2(4000);
    l_ename varchar2(30);
      TYPE my_cursor IS REF CURSOR;
      RC my_cursor;
    begin
      v_sql := 'select ename
                from emp
               where 1=1';
      if p_deptno is not null then
        v_sql := v_sql||' AND deptno='||p_deptno;
      else
        if p_job is not null then
          v_sql := v_sql||' AND job='||p_job;
        end if;
      end if;
      OPEN RC FOR v_sql;
      LOOP
        FETCH RC INTO l_ename;
        EXIT WHEN RC%NOTFOUND;
        dbms_output.put_line(l_ename);
      END LOOP;
      CLOSE RC;
    END;Thanks.
    Edited by: user3565577 on Mar 6, 2010 8:44 PM

    Hi
    I've mocked up a simple test and it seems to use the indexes when I try with one or the other values being supplied, I've made an assumption on the indexes you have (i.e. single column indexes on job and deptno),
    --indexes on emp table:
    p2056@dbapw01> @indexes
    Enter value for table_name: emp
    Enter value for owner: p2056
    INDEX_OWNER                    INDEX_NAME                INDEX_TYPE                  PAR COLUMN_NAME                    STATUS
    P2056                          EMPI1                     NORMAL                      NO  DEPTNO                         VALID
    P2056                          EMPI2                     NORMAL                      NO  JOB                            VALID
    2 rows selected.
    --when accessing with a job value
    p2056@dbapw01> explain plan for select *
      2  from emp
      3  where (
      4   (null is null and job = 'SALESMAN')
      5   OR
      6   ('SALESMAN' is null and deptno = null)
      7   OR
      8   ('SALESMAN' is null and null is null)
      9         );
    Explained.
    p2056@dbapw01> @xplan
    PLAN_TABLE_OUTPUT
    Plan hash value: 1888885832
    | Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |       |     2 |   154 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP   |     2 |   154 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | EMPI2 |     2 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("JOB"='SALESMAN')
    --when accessing with a deptno value
    p2056@dbapw01> explain plan for select *
      2  from emp
      3  where (
      4   (2 is null and job = null)
      5   OR
      6   (null is null and deptno = 2)
      7   OR
      8   (null is null and 2 is null)
      9         );
    Explained.
    p2056@dbapw01> @xplan
    PLAN_TABLE_OUTPUT
    Plan hash value: 1336173234
    | Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |       |     1 |    77 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP   |     1 |    77 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | EMPI1 |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("DEPTNO"=2)

  • Help needed in forming dynamic insert statement

    HI,
    I am trying to construct a insert statement as given below.
    Please help me as to how to form this and where am i going wrong?
    i want the columns names to be auto populated when a table name is given.
    output should be like:
    ==============
    insert into tablename
    col1,col2,col3..coln)
    values
    (col1, col2, col3..coln);
    declare
    v_sql varchar2(5000);
    cnt number :=0;
    col_count number;
    name varchar2(5000); 
    TYPE string_assarrtype IS TABLE OF VARCHAR2 ( 25 ) INDEX BY VARCHAR2 ( 20 );
    arr string_assarrtype;
    BEGIN
       select count(column_name) into col_count from user_tab_columns
      where
      table_name = 'PS_D_RE_BCSREGIONMAPPING';
       v_sql:='insert into tablename (' ;
         for i  in 1..arr(col_count)
          loop
           v_sql:='v_sql' ||' '||arr(i);
          DBMS_OUTPUT.PUT_lINE(v_sql);
         END LOOP;
    END;

    Below is the actual code which i am trying to write:
    Since the below trigger logic is same for around 25/30 tables i wanted to construct a generic procedure which will take input parameter as tablename and auit_table and form the insert statement which will populate the column names which are different for different tables.
    Please guide...
    CREATE OR REPLACE PROCEDURE make_trigger(  tablename  in  VARCHAR2,
                                             auditable  in   VARCHAR2                                                                                  
    AS
    v_sql varchar(10000);
    begin
    v_sql := 'DROP TRIGGER  TRD_D_AUDIT_D'||tablename;
    dbms_output.put_line (v_sql );
    v_sql:='CREATE OR REPLACE TRIGGER TRG_D_AUDIT_D_'||tablename||' '||
    'BEFORE INSERT OR UPDATE OR DELETE ON 'tablename||' '||' REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW';
    dbms_output.put_line (v_sql );
    v_sql:= 'DISABLE
    DECLARE
    v_Operator        psoprdefn.oprid%type;
    v_Sysdate        Date;
    v_Actn            varchar2(1);
    V_AUDIT_RECNAME    PSRECDEFN.RECNAME%type;
    BEGIN';
    dbms_output.put_line (v_sql );
    v_sql:= 'If (Inserting) Then
       v_Actn    :='||'''||'A'||'''||';'||
       'Insert into '||auditable||'
                        ('||
                       AUDIT_RECNAME,
                    AUDIT_ACTN,
                    AUDIT_OPRID,
                    AUDIT_STAMP,
                    D_USER_GROUP,
                    D_GROUP_DESC,
                    D_BCS_ID,
                    D_UBR_ID,
                    D_FILTER_ID,
                    D_NAME_ACCESS_TYPE,
                    D_GLOBAL_EMP_LIST
                        Values
                    V_AUDIT_RECNAME,
                    v_Actn,
                    v_Operator,
                    v_Sysdate,
                    :NEW.D_USER_GROUP,
                    :NEW.D_GROUP_DESC,
                    :NEW.D_BCS_ID,
                    :NEW.D_UBR_ID,
                    :NEW.D_FILTER_ID,
                    :NEW.D_NAME_ACCESS_TYPE,
                    :NEW.D_GLOBAL_EMP_LIST
    end if;
    end;Edited by: user11942774 on Oct 5, 2012 11:46 AM
    Edited by: user11942774 on Oct 5, 2012 8:09 PM
    Edited by: user11942774 on Oct 5, 2012 8:10 PM

Maybe you are looking for

  • IE6 and HttpSession

    My JSP's/Servlets use simple HttpSession objects that expire when the browser is closed. It is my understanding that if a browser has cookies disabled that URL rewriting is used. I've been testing in IE6 and when cookies are restricted all my session

  • Why can't I find and delete photos from my Ipads

    I have deleted all of the photos from my Ipad.  Both Itunes and "storage" on the Ipad report 1.5GB used by photos, but I can't find them or delete them.  What gives?  How do I find and delete these photos?

  • Lost media Acrobat 9.0

    I have a valid license for Acrobat 9.0 WIN AOO License 5-pack. SKU nr. 540261179TS Adobe order nr. 132408831 Where can I download the software???? I can only download 9.0 Pro. Please help! Danny

  • How can I  rotate clipped head image   in animated gif

    I am trying  a copy and paste to make  take  2 items-    A video of person  shoveling  snow  and  replace the  head. Here is  what  I came up with-- real  rough There are 2 issues here. 1.  how to edit  a head to  give a different view angle  to matc

  • JPEG changes color when I import to fcp 7

    I created this image on photoshop but when I import it to FCP, the grays become brighter. I've made sure it's already in RGB Color mode not CMYK. I've imported other pictures and there seems to be also a color change, not as drastic as this one thoug