How to prompt user to enter City & print out the Country it belongs to?

I have one table with “country“ column and “city” column. I need to prompt the user to enter the city name. Then the program should print which country it belongs to. As an example, if user enters “Paris”, program should recognize that it’s in “France” and it should print it out as follows:
Paris ------------------France
Here’s my code:
ACCEPT p_1 PROMPT 'Please enter the city name:'
DECLARE
  v_parent_name ccname.parent_name%TYPE:= '&p_1';
  v_child_name ccname.child_name%TYPE  := '&p_1';
  CURSOR reg_cur
  IS
    SELECT child_name, parent_name INTO v_child_name, v_parent_name FROM ccname;
BEGIN
  FOR reg_rec IN reg_cur
  LOOP
    DBMS_OUTPUT.PUT_LINE(UPPER(RPAD(v_child_name, 15)) || '      ' || UPPER(RPAD(v_parent_name, 15)));
    FETCH reg_cur INTO v_child_name, v_parent_name;
  END LOOP;
END;Any ideas on how I can implement that?
Thank you in advance,
Lisa.
Edited by: user13675672 on Feb 1, 2011 10:15 PM

Hi,
Do you want people to help you? Then try to help them. Post a little sample data (CREATE TABLE and INSERT statements), some parameters you might want to pass, and the results you would want from that sample data for each of the parameters.
If you can use commonly available tables, such as those in the scott or hr schemas, to show your problem, then you don't have to post any sample data; just the parameters (if any) and results.
For example, your problem is:
"I have a table with city and country columns. I want to input a city, and display the country from that same row." That's a lot like:
"The scott.emp table has ename and job columns. I want to input an ename and display the job from that same row."
So, given the name SCOTT, you would want this output:
ENAME      JOB
SCOTT      ANALYSTor, given MILLER you would want:
ENAME      JOB
MILLER     CLERKHere's one way to do that in SQL*Plus:
ACCEPT p_ename PROMPT 'Please enter the employee name: '
SELECT     ename
,     job
FROM     scott.emp
WHERE     ename     = '&p_ename'
;Don't use a meaningless name, like p_1, when you can use a helpful name, like p_ename.
As Billy pointed out, PL/SQL wasn't designed for user interaction like this. There's no point in trying to use PL/SQL to do it.
I hope that answers your question.
If not, please help me understand, so I can do a better job next time. Don't just say "This doesn't work", or "This is not what I'm trying to get", or "Any other ideas?". Those things don't help anyone understand anything. Point out where the suggested soloution is not working, explain what you are trying to get, and give specific examples.

Similar Messages

  • Do u know how to prompt user to enter password and validate the password?

    hi all,anyone knows how to prompt user to enter password and validate the password as well?I do not need the GUI.Can someone post the codes here?Thanks!

    hi all,anyone knows how to prompt user to enter
    password and validate the password as well?I do not
    need the GUI.Can someone post the codes here?Thanks!Codes are
    BufferedReader
    System.in
    if
    else
    System.out.

  • How to force the user to enter a value in the prompt

    Is there a way to force the user to enter a value in the prompt before they run the report?
    We have a customer specific dashbaord. The user has to enter a customer number in Dashbaord prompt on a first page of the dashboard. We store that value in a presentation variable. That presenatation variable value is being referenced in all the other pages of the dashabord. If the user does not enter a values in the first page and directly navigates to the other pages on the dashbaord, the reports on the other pages start to run for all the customers. Is there a way to force the customer to enter a value in the prompt before running any of the reports on the dashboard?
    Thanks!

    by Answer prompts, do you mean Column prompt?
    I can not use Column prompt in this senario as the user should not have to enter the same customer number over and over again when he navigates from one page to another on the same dashboards. If there is a way to default the column prompts then this would be an acceptable solution.
    I have already defaulted the prompt to a value as suggested in hte blog, but the issues occurs when the user erases the defaulted value. Is there are way to set the default value within the report?
    Can you please explaing mroe about option 3 regarding Java Script. Also please let me know what other options there are so that I can check whether they will fit my needs.
    Thank you very much!

  • How to force user to enter supplier/customer name in captial letters in R12

    Dear all,
    Could anyone pls advise how to force user to enter supplier/customer name in captial letters in R12? Can I do it using OA framework personalization?
    HY

    Pl post exact versions of OS and EBS.
    The ability to do this exists in forms (professional user interface) using forms personalization, but does not exist in the OAF (self-service) interface, AFAIK. See related MOS Doc 399892.1 (Is It Possible To Restrict Employee Name Entry To All Upper Case in the PUI And SSHR ?) for some details.
    Pl confirm by opening an SR with Support.
    HTH
    Srini

  • How to ask user to enter value in select statement

    Hi,
    Can anyone tell me syntax of select statement where i can ask user to enter value .
    for example i am trying to use belowthing but it displaying error
    select * from emp where empname=:empname
    SP2-0552: Bind variable "empname" not declared.
    2.Is there any data dictionary table to see all pl/sql procedures and corresponding code?
    Thanks,
    sri

    user632733 wrote:
    Can anyone tell me syntax of select statement where i can ask user to enter value .None. The SQL engine resides on the server. It is incapable of prompting for data entry on the client.
    The client interacts with the user. The client is suppose to:
    a) prompt for variable values
    b) send a SQL statement to Oracle
    c) bind values to bind variables in the SQL statement
    for example i am trying to use belowthing but it displaying error
    select * from emp where empname=:empnameIn SQL*Plus, you need to create a bind variable:
    SQL> var empname varchar2(200)
    And then assign a value to it:
    SQL> exec :empname := 'John Doe';
    Note that this is still not ideal - as the assignment is also done via the server and sends a PL block to the server. This block contains non-sharable code and this can lead to fragmentation of the server's Shared Pool.
    But it does illustrate the basic principle.

  • How to force users to enter their ID and password ?

    I am considering installing AirPort Extreme at our office. We don't want guests connecting to our network. is there any option/software that will force the guest to enter an ID and password to connect to our network ? This is similar to what happens at the hotels when we try to connect to hotel's network.

    How to force users to enter their ID and password?
    is there any option/software that will force the guest to enter an ID and password to connect to our network ? This is similar to what happens at the hotels when we try to connect to hotel's network.
    The AirPort Extreme does not have the features necessary to create a "splash page" that provides basic information about the company and asks users for their identity and password....like you see at most hotels.
    Basically, with an AirPort Extreme, users would have to scan to look for the name of the wireless network to join, and then enter the password to connect.
    The best that you might be able to achieve with the AirPort Extreme is create a "hidden" network, which would require that users know both the name of the wireless network and password to connect.  However, based on experience, this might be more of a hassle than anything else.
    The bottom line.....Apple really designed the AirPort routers for home use, so that might be the best place for them in most cases.

  • How to restrict user to enter duplicate items in Purchase Order Lines?

    I have to do form personalization so that user cannot enter duplicate items in the PO.
    At when-new-item-instance in PO-Approve field, I have created a database function that is taking the count of items and returning the count value.
    In the condition I have given condition:
    1<(select func_name(parameter) from dual)
    10       message                 duplicate items in the po
    But its not working fine.
    Thanks & Regards
    Sunny

    Hi,
    The issue is resolved on my own exploration. We need to maintain the different authorization keys for the status which we did not want  a user  to access. If we leave it blank it will allow user to access.
    Regards,
    Sharath

  • How do you get word count to print at the end of a document in Pages?

    How do you get word count to print at the end of a document in Pages?

    Pages v5 does not provide a user assignable word count variable. With some AppleScript, and a paste operation from the clipboard, you can have locale punctuated word count in this format: 7,803 — anywhere in your document. The following AppleScript works with Pages '09 v4.3 through Pages v5.5.2 on Yosemite.
    I would suggest that you copy paste the following AppleScript into your [Apple] Script Editor and save it (suggestion) wordcnt.applescript. Then, follow this with an option+Save As… and this time set the File format to Script Bundle, or Application with hidden extension — saved to your Desktop. Provided you have a Pages document open, you are then a double-click from the ability to paste your current word count into Pages.
    Note: If you have Pages word count display enabled, it will automatically count your pasted value as another word which initially may deceive on true word count at the time the script was run.
    AppleScript
    --- copy below this line ---
    property locale : "en_US.UTF-8" -- In Terminal, use the locale command to see yours
    if not ApplicationIsRunning("Pages") then
         display dialog "Pages must be running to use this utility."
         return quit
    end if
    tell application "Pages"
        tell body text of front document
            set wordCnt to count words
            -- Don't want punctuated numbers? Remove the single quote from printf format
            set the clipboard to (do shell script "export LC_ALL=" & locale & "; printf \"%'d\" " & wordCnt)
        end tell
    end tell
    on ApplicationIsRunning(appName)
         tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
         return appNameIsRunning
    end ApplicationIsRunning

  • How to print out the text for Info record in ME23?

    Dear all,
    I need to print out a report of PO data. need to print out the text from Info record note (like the picture shown below) in ME23, how should I pull that field and display out?
    I need the solution urgently. Hope experts can help.
    Thank you very much.
    [http://img293.imageshack.us/img293/238/inforecordnd1.png]

    Please check below sample code:
    PARAMETERS: p_ebeln TYPE ebeln OBLIGATORY.
    TYPES: BEGIN OF ty_ekpo,
             ebeln TYPE ebeln,
             ebelp TYPE ebelp,
           END OF ty_ekpo.
    DATA: i_ekpo TYPE TABLE OF ty_ekpo,
          wa_ekpo TYPE ty_ekpo.
    DATA: l_name TYPE tdobname,
          i_tline TYPE TABLE OF tline,
          wa_tline TYPE tline.
    CONSTANTS: c_id   TYPE tdid VALUE 'F02',
               c_object TYPE tdobject VALUE 'EKPO'.
    AT SELECTION-SCREEN.
      SELECT SINGLE ebeln INTO p_ebeln
             FROM ekko
             WHERE ebeln = p_ebeln.
      IF sy-subrc NE 0.
        MESSAGE e001(00) WITH 'Enter valid PO Number'.
      ENDIF.
    START-OF-SELECTION.
      SELECT ebeln ebelp INTO TABLE i_ekpo
             FROM ekpo
             WHERE ebeln = p_ebeln.
      LOOP AT i_ekpo INTO wa_ekpo.
        CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp
           INTO l_name.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            id                      = c_id
            language                = sy-langu
            name                    = l_name
            object                  = c_object
          TABLES
            lines                   = i_tline
          EXCEPTIONS
            id                      = 1
            language                = 2
            name                    = 3
            not_found               = 4
            object                  = 5
            reference_check         = 6
            wrong_access_to_archive = 7
            OTHERS                  = 8.
        IF sy-subrc EQ 0.
          LOOP AT i_tline INTO wa_tline.
            WRITE:/ wa_tline-tdline.
            " Format wa_tline-tdline in the way you need to print out
          ENDLOOP.
        ENDIF.
      ENDLOOP.
    Regards
    Eswar

  • How can i print out the waveform chart?

      hello everybody,
    how can i print out the "waveform chart". can i do it just push the button. ( example; stop button is stop the program etc..)
    i checked the NI examples but i can't understand. i'm new to the Labview.
    pls help me.
    i added the my program
    look forward your reply
    regards from turkey...
    Message Edited by hknmkt on 05-29-2008 04:15 AM
    Attachments:
    29.05.2008_11.vi ‏37 KB

        hi jim,
    i tried the program but it's not running. When i run the program, it's print out without run the program
    i added the printed file.
    look forward your reply
    hakan
    Attachments:
    error8.JPG ‏8 KB

  • I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    Are you trying to Print to PDF or are you trying to Print a PDF file to a physical printer?

  • How do I  print out the attributes of objects from a  Vector?  Help !

    Dear Java People,
    I have created a video store with a video class.I created a vector to hold the videos and put 3 objects in the vector.
    How do I print out the attributes of each object in the vector ?
    Below is the driver and Video class
    Thank you in advance
    Norman
    import java.util.*;
    public class TryVideo
    public static void main(String[] args)
    Vector videoVector = new Vector();
    Video storeVideo1 = new Video(1,"Soap Opera", 20);
    Video storeVideo2 = new Video(2,"Action Packed Movie",25);
    Video storeVideo3 = new Video(3,"Good Drama", 10);
    videoVector.add(storeVideo1);
    videoVector.add(storeVideo2);
    videoVector.add(storeVideo3);
    Iterator i = videoVector.interator();
    while(i.hasNext())
    System.out.println(getVideoName() + getVideoID() + getVideoQuantity());
    import java.util.*;
    public class Video
    public final static int RENT_PRICE = 3;
    public final static int PURCHASE_PRICE = 20;
    private int videoID;
    private String videoName;
    private int videoQuantity;
    public Video(int videoID, String videoName, int videoQuantity)
    this.videoID = videoID;
    this.videoName = videoName;
    this.videoQuantity = videoQuantity;
    public int getVideoID()
    return videoID;
    public String getVideoName()
    return videoName;
    public int getVideoQuantity()
    return videoQuantity;
    }

    Dear Bri81,
    Thank you for your reply.
    I tried the coding as you suggested
    while(i.hasNext())
    System.out.println( i.next() );
    but the error message reads:
    "CD.java": Error #: 354 : incompatible types; found: void, required: java.lang.String at line 35
    Your help is appreciated
    Norman
    import java.util.*;
    public class TryCD
       public static void main(String[] args)
         Vector cdVector = new Vector();
         CD cd_1 = new CD("Heavy Rapper", "Joe", true);
         CD cd_2 = new CD("Country Music", "Sam", true);
         CD cd_3 = new CD("Punk Music", "Mary", true);
         cdVector.add(cd_1);
         cdVector.add(cd_2);
         cdVector.add(cd_3);
         Iterator i = cdVector.iterator();
         while(i.hasNext())
           System.out.println( i.next() );
    public class CD
       private String item;
       private boolean borrowed = false;
       private String borrower = "";
       private int totalNumberOfItems;
       private int totalNumberOfItemsBorrowed;
       public CD(String item,String borrower, boolean borrowed)
         this.item = item;
         this.borrower = borrower;
         this.borrowed = borrowed;
       public String getItem()
         return item;
       public String getBorrower()
         return borrower;
       public boolean getBorrowed()
         return borrowed;
       public String toString()
          return System.out.println( getItem() + getBorrower());

  • How do I print out the value returned by a method in main??

    I'm a total newbie at java, I want to know how I can print out the value returned by this function in the "Main" part of my class:
    public int getTotalPrice(int price)
    int totalprice=price+(price*0.08);
    return totalprice;
    I just want to know how to print out the value for total price under "public static void main(String[] args)". thanks in advance,
    Brad

    Few ways you could do it, one way would be to create an instance of the class and call the method:
    public class Test
        public double getTotalPrice(int price)
            double totalprice = price + (price * 0.08);
            return totalprice;
        public static void main(String[] args)
            Test t = new Test();
            System.out.println(t.getTotalPrice(52));
    }Or another would be to make getTotalPrice() static and you could call it directly from main.

  • HT4356 I don't have wireless printer. How can I print out the document?

    I don't have a wireless printer. How can I print out the document from regular printer?

    iOS AirPrint Printers  http://support.apple.com/kb/HT4356
    How to Print from Your iPad: Summary of Printer and Printing Options
    http://ipadacademy.com/2012/03/how-to-print-from-your-ipad-summary-of-printer-an d-printing-options
    Print from iPad / iPhone without AirPrint
    http://ipadhelp.com/ipad-help/print-from-ipad-iphone-without-airprint/
    How to Enable AirPrint on a Mac and Use Any Printer
    http://ipadhelp.com/ipad-help/how-to-use-airprint-with-any-printer/
    iPad Power: How to Print
    http://www.macworld.com/article/1160312/ipad_printing.html
    Check out these print apps for the iPad.
    Print Utility for iPad  ($3.99) http://itunes.apple.com/us/app/print-utility-for-ipad/id422858586?mt=8
    Print Agent Pro for iPad ($5.99)  http://itunes.apple.com/us/app/print-agent-pro-for-ipad/id421782942?mt=8   Print Agent Pro can print to many non-AirPrint and non-wireless printers on your network, even if they are only connected to a Mac or PC via USB.
    FingerPrint turns any printer into an AirPrint printer
    http://reviews.cnet.com/8301-19512_7-57368414-233/fingerprint-turns-any-printer- into-an-airprint-printer/
     Cheers, Tom

  • How do i print out the keyboard viewer?

    I use different languages and need to use the different special characters so am switching among different keyboard layouts frequently.  I use the (on-screen) "Keyboard Viewer", but would like to print out the "Keyboard Viewer" for each language that I frequently use.  I can't see how to do this other than with e.g. screen capture which is less than ideal.  Does anybody know where there are e.g. images of each keyboard layout (including special characters you get by hitting "shift" etc.)?

    TThis page will give you normal and shift
    How to identify keyboard localizations - Apple Support
    FFor the option and option plus shift levels, you will have to use screen capture

Maybe you are looking for

  • Currency Translation with a Calculate Key Figure

    Hi, Does anyone have experience with applying currency translation in BEX/Query Designer on a Calculated Key Figure?  I have a need for a calculated key figure to be converted to a target currency of USD (which is already defined via RRC1).  I also n

  • What is 'DATA_PACKAGE' now called in Transformation Routine?

    Hi BW ABAP'ers, I am trying to code a start routine in a transformation for a data target.  When I did a syntax check on my ABAP codes, I get a syntax error on 'DATA_PACKAGE'.  Does anyone know what it is now called in BW 7 ? Please let me know. Many

  • Problem in BEx.

    It is not possible to use the colour pale blue in any workbook with a BEX query in it! As this is the corporate colour for all our reporting it’s getting messy moving all presentational tables into new workbooks. thanks.

  • Mobileme gallery in iCloud

    I know that after 6/31 the MobileMe galleries go away = I assume then, if I want to "keep them up" that I have to find another host [Flickr?] or some other option?  If so, any suggestions of other places to share but control who can see?

  • Copy Undeliverable Mail To / luser_relay no worky?

    Hi everyone, I know it's a despised feature, but I just need it working until I'm confident everything has been migrated well. I'm of course referring to "Copy Undeliverable Mail To:". When I first turned it on, and tested in, mail was still bouncing