If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Beginner Help Wanted With PL/SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-12-03, 09:32
iknownothing iknownothing is offline
Registered User
 
Join Date: Nov 2003
Location: Ireland
Posts: 10
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
Reply With Quote
  #2 (permalink)  
Old 11-12-03, 09:42
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
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!
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 11-12-03, 10:01
iknownothing iknownothing is offline
Registered User
 
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!
Reply With Quote
  #4 (permalink)  
Old 11-12-03, 10:21
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
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"!
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #5 (permalink)  
Old 11-12-03, 12:48
iknownothing iknownothing is offline
Registered User
 
Join Date: Nov 2003
Location: Ireland
Posts: 10
Jaysus you're hilarious!!
Reply With Quote
  #6 (permalink)  
Old 11-12-03, 13:00
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
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?
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #7 (permalink)  
Old 11-20-03, 12:58
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
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;
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #8 (permalink)  
Old 11-20-03, 13:05
iknownothing iknownothing is offline
Registered User
 
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!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On