Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2003
    Location
    Ireland
    Posts
    10

    Unanswered: Beginner Help Wanted With PL/SQL

    Hi I was wondering if anybody could help me with this problem:

    Step 1: Create a table to store text strings entered by a database user. When a text string is entered to the database, various information about the entry should be recorded including:
    A unique identifier for the entry that will be the primary key. You must set the primary key using a constraint
    The actual text string entered by the user
    The name of the database user that entered the text string
    The date that the string was entered

    Step 2: Create a sequence that starts off with an initial value of 100 and increments by 10

    Step 3: Declare a PL/SQL block that:
    Declares four appropriately named variables using anchored datatypes that match each column in the table defined in Step 1
    Prompts the user to enter a text string
    Assign the value entered by the user to the variable defined to store the string entered
    Assign the date, user and next value in the sequence to the other variable defined previously. Note that you should use the SELECT INTO FROM DUAL method of assignment
    Within the PL/SQL Block, insert the information assigned to the variables into the table defined in Step 1

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Beginner Help Wanted With PL/SQL

    Which specific part are you having trouble with? Clearly you are not asking us to do all your homework for you!

  3. #3
    Join Date
    Nov 2003
    Location
    Ireland
    Posts
    10

    Angry

    Homework? Yeah hold on I have to go ask my mammy if I can use the computer!

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Originally posted by iknownothing
    Homework? Yeah hold on I have to go ask my mammy if I can use the computer!
    Don't forget to say "please"!

  5. #5
    Join Date
    Nov 2003
    Location
    Ireland
    Posts
    10
    Jaysus you're hilarious!!

  6. #6
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Originally posted by iknownothing
    Jaysus you're hilarious!!
    You are too kind. But seriously, is there any specific help you want with your "homework" ("class assignment", call it what you will), or did you just want someone to do it all for you? You will find that people round here are very helpful if you are prepared to put in some of the effort yourself. On the other hand, people are less inclined to help when it appears that someone just wants to pass off someone else's effort as their own.

    So: what have you come up with so far, and where are you stuck?

  7. #7
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Well, you are already using a cursor-based record! :-

    student_val c_student%ROWTYPE;

    i.e. the record type is defined in terms of the cursor c_student.

    The table-based cursor would be student%ROWTYPE.

    If you use a cursor FOR loop you can get rid of the declaration altogether, along with a lot of other code:

    Code:
    SET SERVEROUTPUT ON;
    
    
    DECLARE
    
       CURSOR c_student IS 
        SELECT * FROM student;
    
    begin
    
      open c_student;
    
      for student_val in c_student loop
    
        DBMS_OUTPUT.PUT_LINE('Student Details: ' || student_val.salutation || student_val.first_name 
    	|| student_val.last_name || student_val.phone || student_val.Registration_date );
    
      end loop;
    
    end;

  8. #8
    Join Date
    Nov 2003
    Location
    Ireland
    Posts
    10
    Yeah I figured it out later and deleted the post coz it was pointless but what I need to know now is how to change it from a cursor to a table based! Im in the process of trying but am getting nowhere!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •