You are on page 1of 3

1. Select s.first_name,s.last_name from student s, enrollement e, course c WHERE s.student_id = e.student_id AND e.course_id = c.course_id AND c.

year =2011 AND c.name = CS101 ORDER BY s.last_name; 2. SELECT STUD.FIRST_NAME, STUD.LAST_NAME FROM (SELECT STUDENT_ID FROM GRADE WHERE SCORE = (select max(g.score) from exam e, course c, grade g where c.course_id=e.course_id AND c.name = "CS202" And c.year = 2012 and e.exam_id = g.exam_id AND g.exam_id = 1) ) MAX_STUD INNER JOIN STUDENT STUD ON STUD.STUDENT_ID = MAX_STUD.STUDENT_ID

2.
use warnings; use strict; main(@ARGV);

sub main { #Declare the array to push the counter value and declare the counter variable as zero my @array; my $counter =0; my $sum = 0; #while loop always looping as long as there is input from console while(my $text = <STDIN>) { #using chomp function to neglect the new line character chomp($text); #incrementing the counter value for each input from the input device $counter = $counter+1; #adding the counter value to a sum variable $sum = $sum + $counter; print $text."\n" ; #Using regular expression to check the is digit function and negating it to check the not digit function if (not$text=~m/^[+-]?\d+/) { #printing the error message, counter value and total sum. Exiting the loop print "Input must be an integer \nCounter Value:".$counter; print "\nThe total is ".$sum; last; } } }

3.

<html> <head> <title>Body Colour Change On Click</title> <script> window.onclick = function() { setColor('body_id'); } function setColor(b_id) {

var property=document.getElementById(b_id); if (window.getComputedStyle(property).backgroundColor == 'rgb(255, 255, 255)') property.style.backgroundColor='#A0A0A0'; } else { property.style.backgroundColor = "#FFFFFF"; } } {

</script> </head>

<body id="body_id" > </body> </html>

4. 1) While connecting to the database proper error messages should be displayed if connection was not established 2) While inserting and selecting data into the table and store the result of execution in variable .
Check the value of the variable to print the correct error message if insertion or fetching data was unsuccessful.

3) The last two lines to print the maximum ID value by fetching from database should be
my $person_id = $row->{'max'}; print $firstname, $lastname . "was successfully inserted at position " .$person_id;

4) I will use a post method in the URI to send information for improving the security of the transaction

You might also like