Some code I don't understand
Ok I know that the code below is a sql statement that is created as a string in a java program. What I don't understand is what the bolded portion is doing. I know that the + stands for concat in most case but I don't understand its purpose below. These items are declared as private strings what does that have to do with it?
String sql = "select stddev_samp(enteredvalue) as stddev from (" +
" select enteredvalue, " +
" row_number() over (order by m1.u_calc_no desc) AS rowcount " +
" from sdidataitem sd, s_sample s1, s_sample s2, u_melt m1, u_melt m2 "+
" where s1.s_sampleid=sd.keyid1 " +
" and sd.sdcid='Sample' " +
" and s1.sampletypeid='" + sampletype + "' " +
" and s1.samplestatus in ('Approved','Reported','Completed') " +
" and sd.paramid='" + strIParamid + "' " +
" and sd.paramtype='" + paramtype + "' " +
" and sd.enteredvalue is not null " +
" and s1.s_sampleid <> s2.s_sampleid " +
" and s2.s_sampleid = '" + sampleid + "' " +
" and s1.u_meltid = m1.u_meltid " +
" and s2.u_meltid = m2.u_meltid " +
" and m1.u_alloy_codeid = m2.u_alloy_codeid " +
" and m1.u_calc_no < m2.u_calc_no " +
" ) where rowcount<=50";+
Message was edited by:
Egyptgirl18
If you were to rewrite the sql with proper indentation as shown below,
what the sql statement is doing will be clearer for you.
String sql =
"select "+
"stddev_samp(enteredvalue) as stddev "+
"from ( " +
"select "+
"enteredvalue, " +
"row_number() over (order by m1.u_calc_no desc) AS
rowcount " +
"from "+
"sdidataitem sd, "+
"s_sample s1, "+
"s_sample s2, "+
"u_melt m1, "+
"u_melt m2 "+
"where "+
"s1.s_sampleid=sd.keyid1 and " +
"sd.sdcid='Sample' and " +
"s1.sampletypeid=" +"'" + sampletype +"'"+ " and " +
"s1.samplestatus in ('Approved','Reported','Completed') and " +
"sd.paramid='" + strIParamid + "' and " +
"sd.paramtype='" + paramtype + "' and " +
"sd.enteredvalue is not null and" +
"s1.s_sampleid <> s2.s_sampleid and " +
"s2.s_sampleid =" + "'" + sampleid + "'" + " and " +
"s1.u_meltid = m1.u_meltid and " +
"s2.u_meltid = m2.u_meltid and " +
"m1.u_alloy_codeid = m2.u_alloy_codeid and " +
"m1.u_calc_no < m2.u_calc_no " +
") "+
"where "+
"rowcount<=50 ";
Similar Messages
-
Help with a piece of code I don't understand
Hi,
I am a new commer to the world of Java development. In writing an app which connects to a MySQL database, I came across the following line of code:
Class.forName("com.mysql.jdbc.Driver").newInstance();
as far as I understand it, this line returns a new instance of the MySQL jdbc driver class, but it doesn't get assigned to anything. How does this work? How does the new object get referenced?
Any insight to this would be most useful,
Regards,
Jeffers3Dthat's explained in the javadoc, I think :
when an object that inherits from java.sql.Driver is instantiated, it automagically registers itself with the DriverManager
then, you can write :
Connection connection = DriverManager.getConnection(url, login, password); -
Some code error, don't know how to fix...
my xml is here:
http://homework.cbsd.googlepages.com/podcast.xml
and i need help with these errors:
Sorry
This feed does not validate.
guid values must not be duplicated within a feed: E3E98228-E7F2-99DF-392B5305E37F61F1 [help]
<guid isPermaLink="false">E3E98228-E7F2-99DF-392B5305E37F61F1</guid> ^
In addition, this feed has an issue that may cause problems for some users. We recommend fixing this issue.
Feeds should not be served with the "application/octet-stream" media type [help]
Source: http://homework.cbsd.googlepages.com/podcast.xmlGUID stands for Globally Unique IDentifier. It's something used to keep track of items say in a database.
Each of your episodes are contained in an <item> tag in your feed's XML. Each episode should have a <GUID> which is unique to that particular episode. The most common thing to do is just copy the link to that episodes enclosure file into a <guid> tag.
For example:
<enclosure url="http://example.com/podcasts/everything/AllAboutEverythingEpisode2.mp3" length="5650889" type="audio/mpeg" />
<guid>http://example.com/podcasts/everything/AllAboutEverythingEpisode2.mp3</guid>
Make sense?
Erik -
Would like to add some code but don't know how
Does anyone know how to add code to pages built in iweb? I would like to add googles analytics to my site.
iMAC G5 Mac OS X (10.3.9)Get MassReplaceIt
http://www.hexmonkeysoftware.com
Search for </body>
Replace with <codefromgoogle></body>
Or if you have blog or podcast pages with .Mac comments enabled, you may want to take a look at this:
http://web.mac.com/varkgirl/iWeb/Aardvarkland/Selective%20Statcounter.html
(Statcounter is the same principle as Google Analytics) -
Don't understand what this means I/O Error: import file
I'm building a website in dreamweaver cs5 with a XML doctype. When I tried to validate my css I got an error code I don't understand. This is the error: I/O Error: import file:/Volumes/Macintosh%20HD/Users/schweideltyson/Desktop/CS%2080_final%20project/gallery .html: Operation not permitted. Any suggestions? The only thing I can think of is that I imported some text for my index page from another website.
XML is used for data. This is an example of a media playlist in XML.
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track><location>file:///mp3s/song_1.mp3</location></track>
<track><location>file:///mp3s/song_2.mp3</location></track>
<track><location>file:///mp3s/song_3.mp3</location></track>
</trackList>
</playlist>
XHTML is for web pages.
http://www.w3schools.com/html/html_doctype.asp
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
http://alt-web.com/
http://twitter.com/altweb -
I can't don't understand code in netbean and it's about Jframe.
i use netbean to design 2 jframe with some buttons on both frame.
frame1 is login form, frame2 is mainform. i want to show loginform then click the button1 to show 2nd jframe.
then i click exit on 2nd jframe and it come back to loginform(frame1).
i do alot of search on the google and here. i know the basic to show a jframe using
setVisible or .show() .hide(), etc..
the problem is what is my jframe variable name in netbean?
i know i can create an jframe object
such as: JFrame frame1 = new JFrame(); etc.. (it's ok if the syntax is wrong for now).
When i use netbean, i drag the Gui components to the Jframe. The jframe is generated by netbean automatically.
When the main program runs, it calls main() method, follow by :
public void run() {
new LoginForm().setVisible(true);
new LoginForm().setVisible <--- setVisible(true) means show the form.
and is new LoginForm() create an object from LoginForm class.
public LoginForm() {
initComponents();
When it create a new object, it runs default constructor and calls iniComponoents and finally show the jframe.
my question is when you create object, you usually declare variable and use variable to hold reference to the object.
that's why i don't understand how it works here.
it only create news object, bu no variable to holding it. how do i control this Jframe to show and hide without a reference variable????????????
Edited by: roadorange on Feb 29, 2008 10:08 PMroadorange wrote:
Encephalopathic . thank your reply so much. your reply is fast. i love it and love this forum.. LOLyou're welcome
i tried hand-written code, and it looks just fine when design few buttons, labels and textfields.
The adjustment of buttons(labels) are not that good on the frame.
However, when you use IDE, you can drag the button on any spot you like in the jframe.... and in the process not learn how Swing works, and lose flexibility and power. Sorry to sound conceited, but I'll match any of your netbeans-created GUI's with one of my own, and mine will likely be better -- and I'm not all that good at this just yet.
Much luck. -
Wrong codes? or maybe I don't understand the instructions
The instructions said "Write a procedure that will retrieve an
existing record in Enrollment usiing the student and section Ids
and set the grade to a specified value. (use update instead of
insert) and write another procedure that will assign a given
student a given advisor" I tried but cause I got a lot of
errors!!! any help would be appreciated just email me at
[email protected]. thanks!
create sequence room_seq increment by 1;
create sequence faculty_seq increment by 1;
create sequence student_seq increment by 1;
create sequence section_seq increment by 1;
create sequence enrollment_seq increment by 1;
create sequence room_section_seq increment by 1;
create table course(
courseNo varchar2(10),
name varchar2(30),
credits number,
constraint course_pk primary key (courseNo));
insert into course (courseNo, name, credits) values
('CIS405','ADVANCED DATABASE', 5);
insert into course (courseNo, name, credits) values
('CIS349','INTRO TO DATABASE', 5);
COMMIT;
create table room(
roomID number,
bldg char(1) check (bldg IN ('A','B')),
roomNo varchar2(10),
maxCapacity number,
style varchar2(15) check(style IN
('LECTURE','LECTURE/LAB','LAB','OFFICE')),
constraint room_pk primary key (roomID));
insert into room (roomID, bldg, roomNo, maxCapacity, style)
values (room_seq.nextval, 'B', '151A', 50, 'LAB');
insert into room (roomID, bldg, roomNo, maxCapacity, style)
values (room_seq.nextval, 'B', '151B', 50, 'LAB');
commit;
create table faculty(
facultyID number,
lname varchar2(30) not null,
fname varchar2(20) not null,
dept varchar2(5),
officeID number,
phone varchar2(15),
email varchar2(75),
rank char(4) check(rank IN ('INST','ASOC','ASST','FULL','SENR')),
constraint faculty_pk primary key (facultyID),
constraint faculty_fk foreign key (officeID) references room
(roomID));
insert into faculty(facultyID, lname, fname, dept, officeID,
phone, email, rank) values
(faculty_seq.nextval, 'CANNON', 'AMY', 'CIS',
6, '77052149003252', '[email protected]','FULL');
commit;
create table equipment(
equipmentID varchar2(30),
roomID number,
type varchar2(20) check(type IN('OVERHEAD PROJECTOR','PORTABLE
PROJECTOR','LAPTOP CONNECTION','DESKTOP COMPUTER','INTERNET
CONNECTION')),
constraint equipment_pk primary key (equipmentID),
constraint equipment_fk foreign key (roomID) references room
(roomID));
INSERT INTO EQUIPMENT (EQUIPMENTID, ROOMID, TYPE) VALUES ('111',
5, 'DESKTOP COMPUTER');
INSERT INTO EQUIPMENT (EQUIPMENTID, ROOMID, TYPE) VALUES ('222',
5, 'OVERHEAD PROJECTOR');
commit;
create table student(
stuID number,
lname varchar2(30),
fname varchar2(20),
street varchar2(100),
city varchar2(60),
state char(2),
zip varchar2(9),
major varchar2(5) check(major IN
('ACCT','ECT','EET','BIS','BSIT','CIS','TCOM')),
standing varchar2(10) check(standing IN
('FRESHMAN','SOPHOMORE','JUNIOR','SENIOR')),
gpa number(3,2),
advisor number,
constraint student_pk primary key (stuID),
constraint student_FK foreign key (advisor) references faculty
(facultyID));
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'SMITH', 'HEATHER', 'CIS', 'JUNIOR', 3.8,
2);
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'ELLIOTT', 'DAVE', 'CIS', 'JUNIOR', 3.65,
2);
commit;
create table section(
sectionID number,
sectionNo char(1),
courseNo varchar2(10),
facultyID number,
term char(4),
curSize number,
maxSize number,
constraint section_pk primary key (sectionID),
constraint section_course_fk foreign key (courseNo) references
course(courseNo),
constraint section_faculty_fk foreign key (facultyID) references
faculty(facultyID));
INSERT INTO SECTION (SECTIONID, SECTIONNO, COURSENO, FACULTYID,
TERM, CURSIZE, MAXSIZE)
VALUES (SECTION_SEQ.NEXTVAL, 'T', 'CIS405', 1, '1001', 17, 30);
INSERT INTO SECTION (SECTIONID, SECTIONNO, COURSENO, FACULTYID,
TERM, CURSIZE, MAXSIZE)
VALUES (SECTION_SEQ.NEXTVAL, 'G', 'CIS405', 2, '1001', 24, 30);
commit;
create table enrollment(
stuSectionID number,
stuID number,
sectionID number,
grade char(1) check(grade IN('A','B','C','D','F','I','W')),
constraint enrollment_pk primary key (stuSectionID),
constraint enrollment_stu_fk foreign key (stuID) references
student(stuID),
constraint enrollment_section_fk foreign key (sectionID)
references section(sectionID));
INSERT INTO ENROLLMENT (STUSECTIONID, STUID, SECTIONID) VALUES
(ENROLLMENT_SEQ.NEXTVAL, 3, 1);
INSERT INTO ENROLLMENT (STUSECTIONID, STUID, SECTIONID) VALUES
(ENROLLMENT_SEQ.NEXTVAL, 3, 8);
commit;
create table room_section(
roomSectionID number,
sectionID number,
roomID number,
day char(3) check(day IN
('MON','TUE','WED','THU','FRI','SAT','SUN')),
hour date,
term char(4),
constraint room_section_pk primary key (roomSectionID),
constraint room_section_section_fk foreign key (sectionID)
references section(sectionID),
constraint room_section_room_fk foreign key (roomID) references
room(roomID));
INSERT INTO ROOM_SECTION (ROOMSECTIONID, SECTIONID, ROOMID, DAY,
HOUR, TERM)
VALUES (ROOM_SECTION_SEQ.NEXTVAL, 1, 3, 'MON', TO_DATE('9:30
AM', 'HH:MI AM'), '1001');
INSERT INTO ROOM_SECTION (ROOMSECTIONID, SECTIONID, ROOMID, DAY,
HOUR, TERM)
VALUES (ROOM_SECTION_SEQ.NEXTVAL, 1, 3, 'MON', TO_DATE('10:30
AM', 'HH:MI AM'), '1001');
commit;
SQL> DESC ENROLLMENT
Name Null? Type
STUSECTIONID NOT NULL NUMBER
STUID NUMBER
SECTIONID NUMBER
GRADE CHAR(1)
SQL> CREATE OR REPLACE PROCEDURE Enrollment(
2 p_grade IN CHAR(1),
3 IS
4 v_stuid NUMBER,
5 v_sectionid NUMBER;
6 BEGIN
7 SELECT student_seq.NEXTVAL
8 INTO v_stuid
9 FROM DUAL;
10 UPDATE student
11 (stuid,
12 sectionid,
13 grade,
14 SET (v_stuid,
15 v_sectionid,
16 UPPER (p_grade),
17 COMMIT;
18 DBMS_OUTPUT.PUT_LINE ('Student added');
19 EXCEPTION
20 WHEN OTHERS THEN
21 DBMS_OUTPUT.PUT_LINE ('An error occurred');
22 END AddStudent;
23 /
I got those errors like above!!! I don't understand what the
instructions said. any assistance would be appreciated!David,
I am afraid that the
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('An error occurred');
was my fault. I had intended it as an example to provide only
minimal syntax where no exception handling whatsoever previously
existed. Beau is a student and I am trying to guide him in the
right direction without just writing all of it for him. In
fact, I am afraid I may have already provided too much code
without sufficient explanation. For you and others who may wish
to help, here are the e-mails that provide the background on how
we got to this point, with the most recent on top, starting with
the last resonse I sent to him:
Things that are wrong:
The instructions say to be sure to use the sequence number for
the student's ID, so you should not have p_stuID as an input
parameter. Instead you should create a variable and select the
student_seq.nextval into the variable from the dual table and
use that value to populate the stuid column.
Your input parameters should only have the variable type, not
the size, so just use varchar2 and number.
The check constraints only belong in the script that is used to
create the table, not in your procedure with your input
parameters, so remove them from the procedure.
The order and number of your columns you are inserting into and
values you are inserting must match, so if you insert into fname
then lname, you need to insert the values p_fname then p_lname.
You must either have first name then last name in both or last
name then first name in both, not one way in one and the other
way in the other.
The idea is that when you execute the procedure you specify the
values of the input parameter variable, then use those input
parameter variables to insert the values into the table. You
should not be specifying any specific values anywhere in your
procedure. In other words don't insert 'HEATHER', instead
insert fname, and so on.
You should only have one insert statement. Each time the
procedure is executed, a different set of values will be
provided, and the same insert statement will be used.
Additional suggestions:
Although it is not required, since IN is the default, it is
generally considered to be a good programming practice to use IN
with your input parameters. It just makes the code easier to
read and understand. As you write other code, you will learn to
use OUT for output parameters and IN OUT for parameters that are
both input and output parameters.
It is generally recommended to store all data in upper case,
that is capital letters, so that it is easier to index and
search and avoid duplicates and so on. In order to ensure that
your data is input in upper case, it is a good idea to use the
UPPER function.
Different programmers and companies have different standards
that they use for capitalization, indentation, spacing,
alignment, and so forth to make their code uniform and easier to
read. You may want to look at some various styles and see what
you like or ask what your instructor recommends.
You should add some sort of exception handling section. For
example, if someone attempts to insert a value for standing that
isn't acceptable, then the procedure will fail due to the
constraints and the student will not be added. You probably
want to display some sort of message to the user. You might
also want to display a message if the input is successful.
When you attempt to compile your program and you receive a
message that says "Warning: Procedure created with compilation
errors." or some such thing, then from the SQL> prompt, type
SHOW ERRORS and it will list the error message number, a brief
description of the problem, and the line of code that the
problem occurred on. You can then type LIST and it will list
the code with line numbers, so that you can tell what line
number the error message is referring to.
In the following example, I have fixed the things that were
wrong, formatted it the way I usually do, and added minimal
exception handling and messages. There is a lot more that you
could do. I have also demonstrated how the program can be
tested and the results of proper input and improper input. In
the example below, two students are added correctly, then an
attempt to add another fails because the standing is not valid
and violates a check constraint, because graduate is not
acceptable. After each execution of the procedure, I have
queried the table, so that you can see what was added and what
was not.
SQL> CREATE OR REPLACE PROCEDURE AddStudent
2 (p_fname IN VARCHAR2,
3 p_lname IN VARCHAR2,
4 p_major IN VARCHAR2,
5 p_standing IN VARCHAR2,
6 p_gpa IN NUMBER)
7 IS
8 v_stuid NUMBER;
9 BEGIN
10 SELECT student_seq.NEXTVAL
11 INTO v_stuid
12 FROM DUAL;
13
14 INSERT INTO student
15 (stuid,
16 fname,
17 lname,
18 major,
19 standing,
20 gpa)
21 VALUES (v_stuid,
22 UPPER (p_fname),
23 UPPER (p_lname),
24 UPPER (p_major),
25 UPPER (p_standing),
26 p_gpa);
27
28 COMMIT;
29 DBMS_OUTPUT.PUT_LINE ('Student added');
30 EXCEPTION
31 WHEN OTHERS THEN
32 DBMS_OUTPUT.PUT_LINE ('An error occurred');
33 END AddStudent;
34 /
Procedure created.
SQL> COLUMN fname FORMAT A15
SQL> COLUMN lname FORMAT A15
SQL> SELECT stuid, fname, lname, major, standing, gpa
2 FROM student
3 /
no rows selected
SQL> SET SERVEROUTPUT ON
SQL> EXEC AddStudent ('HEATHER', 'SMITH', 'CIS', 'JUNIOR', 3.8)
Student added
PL/SQL procedure successfully completed.
SQL> SELECT stuid, fname, lname, major, standing, gpa
2 FROM student
3 /
STUID FNAME LNAME MAJOR
STANDING GPA
1 HEATHER SMITH CIS
JUNIOR 3.8
SQL> EXEC AddStudent ('Dave', 'Elliott', 'CIS', 'junior', 3.65)
Student added
PL/SQL procedure successfully completed.
SQL> SELECT stuid, fname, lname, major, standing, gpa
2 FROM student
3 /
STUID FNAME LNAME MAJOR
STANDING GPA
1 HEATHER SMITH CIS
JUNIOR 3.8
2 DAVE ELLIOTT CIS
JUNIOR 3.65
SQL> EXEC AddStudent ('KARL', 'WEBSTER', 'CIS', 'GRADUATE', 3.2)
An error occurred
PL/SQL procedure successfully completed.
SQL> SELECT stuid, fname, lname, major, standing, gpa
2 FROM student
3 /
STUID FNAME LNAME MAJOR
STANDING GPA
1 HEATHER SMITH CIS
JUNIOR 3.8
2 DAVE ELLIOTT CIS
JUNIOR 3.65
SQL>
I am going home now. Sometimes I get a chance to respond to my
e-mail daily and sometimes I may not get to it for a week. It
is better if you post your questions on one of the forums where
you may get more rapid responses from many people. I have
provided links to some forums that I browse below. If you have
internet access, you should be able to just click on them. Some
may require you to register, but they are all free.
The following is a link to the Oracle Technology Network forums,
hosted by Oracle Corporation, where I recommend the SQL and
PL/SQL discussions.
http://forums.oracle.com/forums/homepage.jsp
The following is a link to the PL/SQL forums of the REVEALNET
site, where noted author Steven Feuerstein is one of the SYSOPS,
where, for you, I recommend the "Beginner PL/SQL Developer
Questions" discussions.
http://PIPETALK.REVEALNET.COM/~PLSQL/LOGIN
The following is a link to another forum, where I recommend the
RDBMS, SQL, PL/SQL discussions.
http://www.orafans.com/cgi-bin/orafans/ubb/Ultimate.cgi?
action=intro
I would still like to know where you got my e-mail address, what
class you are taking, who your instructor is, and so forth.
Please do let me know.
Good luck,
Barbara
-----Original Message-----
From: bseo.ga [SMTP:[email protected]]
Sent: Wednesday, December 19, 2001 12:19 AM
To: Boehmer, Barbara A.
Subject: Re: PL/SQL
Importance: High
what is wrong with the compilation errors?
CREATE or REPLACE PROCEDURE AddStudent(
p_stuID number,
p_lname varchar2(30),
p_fname varchar2(20),
p_major varchar2(5) check(major IN
('ACCT','ECT','EET','BIS','BSIT','CIS','TCOM')),
P_standing varchar2(10) check(standing IN
('FRESHMAN','SOPHOMORE','JUNIOR','SENIOR')),
P_gpa number(3,2) IS
BEGIN
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'SMITH', 'HEATHER', 'CIS', 'JUNIOR', 3.8,
2);
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'ELLIOTT', 'DAVE', 'CIS', 'JUNIOR', 3.65,
2);
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'WEBSTER', 'KARL', 'CIS', 'SENIOR', 3.2,
2);
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'COX', 'STACEY', 'CIS', 'SENIOR', 2.7, 1);
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'HOWARD', 'BRIAN', 'CIS', 'JUNIOR', 3.18,
1);
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'DENNIS', 'KELLY', 'CIS', 'SENIOR', 4.0,
1);
COMMIT;
END;
SQL> /
Warning: Procedure created with compilation errors.
----- Original Message -----
From: Boehmer, Barbara A. <mailto:[email protected]>
To: 'bseo.ga' <mailto:[email protected]>
Sent: Tuesday, December 18, 2001 5:17 PM
Subject: RE: PL/SQL
I am not sure what part of it you don't understand.
The first section that you included is a script that you need to
copy and run, in order to create the sequences, tables, and data
that you will need to complete your assignment. You will need
to edit an empty .sql file, copy the script into the file, save
the file, then start the file. For example:
SQL> EDIT test
Type or copy the script and save the file.
SQL> START test
You should see various messages as the items are created. Then
you can use the following commands to see the tables and
sequences that you have created:
SQL> SELECT table_name FROM user_tables;
SQL> SELECT sequence_name FROM user_sequences;
To show the structure of an individual table, for example the
course table:
SQL> DESC course
To show the data in an individual table, like the course table:
SQL> SELECT * FROM course;
In the second section that you have provided, your instructor is
asking you to create three different procedures to do three
different things. To create a procedure, you edit a .sql file,
type the code to create the procedure, save the file, then start
the file. I usually make the .sql file name the same as the
procedure name. So, for example, in number 1, you are asked to
create a procedure named AddStudent, so you would:
SQL> EDIT AddStudent
Type your code.
Save the file.
SQL> START AddStudent
You should receive a message that says:
Procedure created.
Then, to execute your procedure:
SQL> EXEC AddStudent (put your parameter values here)
The basic syntax for creating a pl/sql procedure is:
CREATE OR REPLACE PROCEDURE procedure_name
(put your parameters here)
AS
put your variable declarations here;
BEGIN
put your code that you want to execute here,
like insert statements and update statements;
END procedure_name;
So, if you are trying to create a procedure to add a new student
(which means inserting a row into the student table), you will
need to accept the values (parameters) that you are going to
insert, then insert them:
CREATE OR REPLACE PROCEDURE AddStudent
(p_first .....
p_last .....
p_major .....
p_standing .....
p_GPA .....)
AS
BEGIN
INSERT INTO student .....;
END AddStudent;
I have just given you a starting format and deliberately left
out a lot, because you will learn more by doing it yourself. I
hope that makes things a little clearer.
I would like to know a little more about the class you are
taking. Please let me know where you are going to school, who
your instructor is, what is the name of the class you are
taking, and what book are you using. Also, please let me know
where you got my e-mail address (from one of the forums?)
Good luck,
Barbara
-----Original Message-----
From: bseo.ga [mailto:[email protected]]
Sent: Tuesday, December 18, 2001 5:57 PM
To: [email protected]
Subject: PL/SQL
Importance: High
I don't understand reading the following instructions from my
professor and the books. help would be apppreciated.
-------------create the sequence numbers needed to generate
primary key values
create sequence room_seq increment by 1;
create sequence faculty_seq increment by 1;
create sequence student_seq increment by 1;
create sequence section_seq increment by 1;
create sequence enrollment_seq increment by 1;
create sequence room_section_seq increment by 1;
create table course(
courseNo varchar2(10),
name varchar2(30),
credits number,
constraint course_pk primary key (courseNo));
insert into course (courseNo, name, credits) values
('CIS405','ADVANCED DATABASE', 5);
insert into course (courseNo, name, credits) values
('CIS349','INTRO TO DATABASE', 5);
COMMIT;
create table room(
roomID number,
bldg char(1) check (bldg IN ('A','B')),
roomNo varchar2(10),
maxCapacity number,
style varchar2(15) check(style IN
('LECTURE','LECTURE/LAB','LAB','OFFICE')),
constraint room_pk primary key (roomID));
insert into room (roomID, bldg, roomNo, maxCapacity, style)
values (room_seq.nextval, 'B', '151A', 50, 'LAB');
insert into room (roomID, bldg, roomNo, maxCapacity, style)
values (room_seq.nextval, 'B', '151B', 50, 'LAB');
commit;
create table faculty(
facultyID number,
lname varchar2(30) not null,
fname varchar2(20) not null,
dept varchar2(5),
officeID number,
phone varchar2(15),
email varchar2(75),
rank char(4) check(rank IN
('INST','ASOC','ASST','FULL','SENR')),
constraint faculty_pk primary key (facultyID),
constraint faculty_fk foreign key (officeID) references room
(roomID));
insert into faculty(facultyID, lname, fname, dept, officeID,
phone, email, rank) values
(faculty_seq.nextval, 'CANNON', 'AMY', 'CIS',
6, '77052149003252', '[email protected]','FULL'
<mailto:'[email protected]','FULL'>);
commit;
create table equipment(
equipmentID varchar2(30),
roomID number,
type varchar2(20) check(type IN('OVERHEAD PROJECTOR','PORTABLE
PROJECTOR','LAPTOP CONNECTION','DESKTOP COMPUTER','INTERNET
CONNECTION')),
constraint equipment_pk primary key (equipmentID),
constraint equipment_fk foreign key (roomID) references room
(roomID));
INSERT INTO EQUIPMENT (EQUIPMENTID, ROOMID, TYPE) VALUES ('111',
5, 'DESKTOP COMPUTER');
INSERT INTO EQUIPMENT (EQUIPMENTID, ROOMID, TYPE) VALUES ('222',
5, 'OVERHEAD PROJECTOR');
commit;
create table student(
stuID number,
lname varchar2(30),
fname varchar2(20),
street varchar2(100),
city varchar2(60),
state char(2),
zip varchar2(9),
major varchar2(5) check(major IN
('ACCT','ECT','EET','BIS','BSIT','CIS','TCOM')),
standing varchar2(10) check(standing IN
('FRESHMAN','SOPHOMORE','JUNIOR','SENIOR')),
gpa number(3,2),
advisor number,
constraint student_pk primary key (stuID),
constraint student_FK foreign key (advisor) references faculty
(facultyID));
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'SMITH', 'HEATHER', 'CIS', 'JUNIOR', 3.8,
2);
INSERT INTO STUDENT (STUID, LNAME, FNAME, MAJOR, STANDING, GPA,
ADVISOR) VALUES
(STUDENT_SEQ.NEXTVAL, 'ELLIOTT', 'DAVE', 'CIS', 'JUNIOR', 3.65,
2);
commit;
create table section(
sectionID number,
sectionNo char(1),
courseNo varchar2(10),
facultyID number,
term char(4),
curSize number,
maxSize number,
constraint section_pk primary key (sectionID),
constraint section_course_fk foreign key (courseNo) references
course(courseNo),
constraint section_faculty_fk foreign key (facultyID)
references faculty(facultyID));
INSERT INTO SECTION (SECTIONID, SECTIONNO, COURSENO, FACULTYID,
TERM, CURSIZE, MAXSIZE)
VALUES (SECTION_SEQ.NEXTVAL, 'T', 'CIS405', 1, '1001', 17, 30);
INSERT INTO SECTION (SECTIONID, SECTIONNO, COURSENO, FACULTYID,
TERM, CURSIZE, MAXSIZE)
VALUES (SECTION_SEQ.NEXTVAL, 'G', 'CIS405', 2, '1001', 24, 30);
commit;
create table enrollment(
stuSectionID number,
stuID number,
sectionID number,
grade char(1) check(grade IN('A','B','C','D','F','I','W')),
constraint enrollment_pk primary key (stuSectionID),
constraint enrollment_stu_fk foreign key (stuID) references
student(stuID),
constraint enrollment_section_fk foreign key (sectionID)
references section(sectionID));
INSERT INTO ENROLLMENT (STUSECTIONID, STUID, SECTIONID) VALUES
(ENROLLMENT_SEQ.NEXTVAL, 3, 1);
INSERT INTO ENROLLMENT (STUSECTIONID, STUID, SECTIONID) VALUES
(ENROLLMENT_SEQ.NEXTVAL, 3, 8);
commit;
create table room_section(
roomSectionID number,
sectionID number,
roomID number,
day char(3) check(day IN
('MON','TUE','WED','THU','FRI','SAT','SUN')),
hour date,
term char(4),
constraint room_section_pk primary key (roomSectionID),
constraint room_section_section_fk foreign key (sectionID)
references section(sectionID),
constraint room_section_room_fk foreign key (roomID)
references room(roomID));
INSERT INTO ROOM_SECTION (ROOMSECTIONID, SECTIONID, ROOMID, DAY,
HOUR, TERM)
VALUES (ROOM_SECTION_SEQ.NEXTVAL, 1, 3, 'MON', TO_DATE('9:30
AM', 'HH:MI AM'), '1001');
INSERT INTO ROOM_SECTION (ROOMSECTIONID, SECTIONID, ROOMID, DAY,
HOUR, TERM)
VALUES (ROOM_SECTION_SEQ.NEXTVAL, 1, 3, 'MON', TO_DATE('10:30
AM', 'HH:MI AM'), '1001');
commit;
The lab notes from my professor said
1. your system will often need to create a new student. Write
PL/SQL code for an object named AddStudent that will take values
for first and last name, major, standing and GPA and add a new
record in the Student table. Since advisors aren't assigned at
registration time, we'll add their advisor at a later date.
Don't worry about the student's address. Be sure to use the
sequence number for the student's ID.
2. Write a procedure that will retrieve an existing record in
Enrollment usiing the student and section Ids and set the grade
to a specified value. (use update instead of insert)
3. Write another procedure that will assign a given student a
given advisor. -
I purchased the teacher and student lightroom 5. I put in my code and uploaded my evidence to show that I am a teacher. I am guessing it was sent through to someone. How do I know when I can use the software? I don't understand what to do next.
Please refer below link for more information
Education FAQ -
I keep getting this error message when I (right-click) on a photo file on my desktop to burn to a CD. I don't understand this code...does anyone? Thanks Ariel**: The disc can’t be burned because an unexpected error occurred (error code 0x80020000).
I tried every obvious solution to this problem with different types of disc (-R; +R; -RW and +RW) and the problem persisted. Then I read about removing a hyphen in picture filenames. I renamed all the images and bingo there were no further problems. Apple should have solved this by now. This error code has been reported for several years and my MacBook Pro is quite new. Anyway, I hope this helps. It does work.
Piggywiggle -
i need help using the icloud it is not making any since to me can some one call me and help me with it please don't try to help me through email i need to talk and listen i don't understand instruction by reading.
<Phone Number Edited by Host>You aren't addressing anyone from Apple here. This is a user forum.
You might want to call a neaby Apple store to see if they have a free class you could attend. -
I don't understand why recently with the new "pages" my computer stops responding. When I go to fix some grammar all of a sudden the little colored circle begins to appear and won't go away I restart my computer.
If you have more than one user account, these instructions must be carried out as an administrator.
Launch the Console application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
Step 1
Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
View ▹ Show Log List
from the menu bar.
Enter "BOOT_TIME" (without the quotes) in the search box. Note the timestamps of those log messages, which refer to the times when the system was booted. Now clear the search box and scroll back in the log to the last boot time after you had the problem. Select the messages logged before the boot, while the system was unresponsive or was failing to shut down. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message (command-V). Please include the BOOT_TIME message at the end of the log extract.
If there are runs of repeated messages, post only one example of each. Don’t post many repetitions of the same message.
When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
Please do not indiscriminately dump thousands of lines from the log into this discussion.
Important: Some private information, such as your name, may appear in the log. Anonymize before posting.
Step 2
Still in Console, look under System Diagnostic Reports for crash or panic logs, and post the entire contents of the most recent one, if any. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if present (it may not be.) Please don’t post any other kind of report — it will be very long and not helpful. -
Help! I don't understand the frame mechanics.
Hi, I've been trying to figure out how frames work in Flash. I'm new to ActionScript, so I don't know the inner workings of the language. I tried checking the API but no Frame class is listed. The closest thing was FrameLabel and that wasn't helpful. I need to know a few things:
1) How can I tell what frame I am in? If there is a class method for this, what is the exact name?
2) How does a frame advance? I have some code with no timer, only event listeners/handlers, and I've got a hacked animation working without playing clips on the time line. The displayed pictures change whenever I press a directional button to move the character. This is not really what I want to do however, because I'm switching the visibility of many different symbols and updating their position according to the original player symbol. Very inefficient. And does that mean that the frame only advances when a button is pressed? Am I even advancing the frame at all? I don't know any frame advance method.
3) How do frames work on the time line? I have all of my symbols on a single frame. I made their visibility false in my constructor because I don't want some things to show when I first load up the .swf file. When I created a second frame, everything went crazy and things began to show up. This suggests that the visibility = false was only done in the first frame? What caused the frame to change? I don't really get it.
Ideally I want to achieve a dynamically modifiable animation because the game actions are not going to be linear. The player character will be responding to controls (which will change the animation) and the AI will be responding to the player (which will also change the animation). I don't think I can do this without understanding frames, so please help me. I'm very confused! Even pointing me in the right direction as to where I can read about frame details would be cool. I've tried Adobe tutorials, support, and documentation but it was not sufficient. Is there any place where there is a very in depth explanation about frames, or would someone be so kind as to tutor me about them?
Thanks in advance.You can find out the current frame by using the currentFrame property. There are a number of ways to change frames, where the most common would be prevFrame(), nextFrame(), play(), gotoAndPlay(), and gotoAndStop(). There are plenty of ways to make use of frames in a Flash file, from having linear animations along the timeline, to have each frame being a distinct zone of operation that contains elements having their own timelines.
One thing you may need to get a handle on are the different types of frames. There are plain frames and there are keyframes. Plain frames genrally involve a continuation of preceding frames, while keyframes mark an area of change. In your example of things going crazy when you added a second frame, I am guessing you implanted a new keyframe because had you inserted a plain frame the status of your content from frane 1 would not have been impacted.
I don't know of any resources for you to follow up with for learning more about frames--I came to learn them thru trial and error. Someone else may come along with some suggestions for reference materials. -
Multiple constraints cause exception and I don't understand why;
Hi:
I am using a 10.2.0.3 DB to look at some code that to the best of my knowledge works in 8i. The combination of constraints they put on the table end up preventing a user from inserting records in 10g due to a constraint violation.
Caveats: NOT MY CODE! They are using CHAR strings for times. Yes it's scary. Yes it's a problem in its own right. NOT the problem I care about right now. I care about the bigger question of why do the two constraints that (to me) appear to be non-conflicting cause a violation.
Here's the code to recreate the situation:
create table timeConstraintTest
MY_KEY NUMBER(11) NOT NULL,
SOME_NBR NUMBER(3) NOT NULL,
SOME_DATE DATE NOT NULL,
CHAR_TIME_IN VARCHAR2(5 BYTE) NOT NULL,
CHAR_TIME_OUT VARCHAR2(5 BYTE) NOT NULL
ALTER TABLE timeConstraintTest ADD (
CONSTRAINT TCT_CPK
PRIMARY KEY
(MY_KEY));
ALTER TABLE timeConstraintTest ADD (
CONSTRAINT TIME_IN_CCK
CHECK (LENGTH(CHAR_TIME_IN) = 4 AND
LTRIM(char_time_in,'0123456789') IS NULL AND
SUBSTR(char_time_in, 1, 2) BETWEEN 0 AND 24 AND
SUBSTR(char_time_in, 3, 2) BETWEEN 0 AND 59));Now, if I try and insert a record with the following :
insert into timeConstraintTest values(1,1,sysdate,'1234','1245');I get
ORA-02290: check constraint (GAFF.TIME_IN_CCK) violated
Now if I disable the NOT NULL constraint on the CHAR_TIME_IN column (yeah I should have created it explicitly and named it)
alter table timeConstraintTest disable constraint SYS_C0056162;the insert will work.
This may be correct, it may be a bug. I don't know. I just want to understand it. Does anyone know why this violation is being thrown?
ThanksFailed in my case.
10.2.0.3 on Solaris 64 bit.
SQL> create table timeConstraintTest
2 (
3 MY_KEY NUMBER(11) NOT NULL,
4 SOME_NBR NUMBER(3) NOT NULL,
5 SOME_DATE DATE NOT NULL,
6 CHAR_TIME_IN VARCHAR2(5 BYTE) NOT NULL,
7 CHAR_TIME_OUT VARCHAR2(5 BYTE) NOT NULL
8 );
Table created.
SQL>
SQL>
SQL> ALTER TABLE timeConstraintTest ADD (
2 CONSTRAINT TCT_CPK
3 PRIMARY KEY
4 (MY_KEY));
Table altered.
SQL>
SQL>
SQL> ALTER TABLE timeConstraintTest ADD (
2 CONSTRAINT TIME_IN_CCK
3 CHECK (LENGTH(CHAR_TIME_IN) = 4 AND
4 LTRIM(char_time_in,'0123456789') IS NULL AND
5 SUBSTR(char_time_in, 1, 2) BETWEEN 0 AND 24 AND
6 SUBSTR(char_time_in, 3, 2) BETWEEN 0 AND 59));
Table altered.
SQL>
SQL> insert into timeConstraintTest values(1,1,sysdate,'1234','1245');
insert into timeConstraintTest values(1,1,sysdate,'1234','1245')
ERROR at line 1:
ORA-02290: check constraint (ETL_IMPORT.TIME_IN_CCK) violated
SQL>
SQL> select * from v$version
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Solaris: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL>Cheers
Sarma. -
Friends, please shed some light. I don't understand. Can I use code hint feature on symbols , that I simply drag on stage from the library and instantiate via property panel (not from 'new 'operator). As you guess, when I hit F9 (i.e. invoke Actions window) and write name of the object then put period ('.') code hint window don't popup. There are many topics in this forum dedicated this issue, but all don't work.
I have Adobe Flash CC professional and OS - Windows 8.kglad wrote:
var mc:MovieClip; // where mc is the instance you named in the properties panel.
Thanks a lot. This right . But , why code hint window don't popup automatically. Edit -> Preferences -> Code editor
-> Code Hints............. property is checked. Code hint work only when ctrl + space is hited.
P.S.
I had try this suggestion. Unsuccessfully.
Hi ,
After ensuring that the "Code Hints" checkbox in the Actionscript section of the Flash Preferences dialog is turned on , please try resetting your code-hint cache as follows:
1. Quit Flash
2. Delete your code-hint cache folder
Win XP:
C:\Documents and Settings\<user>\Local Settings\Application Data\Adobe\Flash CS6\<language>\Configuration\CodeModel
Win Vista/Win7:
C:\Users\<user>\AppData\Local\Adobe\Flash CS6\<language>\Configuration\CodeModel
Mac:
/Users/<user>/Library/Application Support/Adobe/Flash CS6/<language>/Configuration/CodeModel
3. Re-start Flash and try again.
Let me know if this helps.
Thanks and regards,
Sudeshna Sarkar
Adobe Flash Professional Team. -
[SOLVED] Apparently, I don't understand mount
Hey there!
I'm having some problems with automounting and other things, so I started working on fixing that, but first I at least want to get a few things sorted out.
For example, when I want to mount a CD-ROM, what I currently do is this:
1) start thunar in _root_ mode, if I don't do it in root it complains with a HAL error that it can't do it
2) click the CD icon in left pane
3) do my stuff (usually start smplayer )
To unmount, I just type "sudo umount /media/dvd"
Now, I was going to check on this HAL issue, but then a friend of mine alerted me to the fact that I shouldn't even be using sudo to mount.
I was curious as to why, it seems logical to need root privileges for something like that.
But then he told me about executable permissions, my mount had "-rwxr-xr-x", his had "-rwsr-xr-x". He told me about the "s" flag and how it makes the system think that you're root
when you execute it without sudo, even if you're not. So I changed the permissions on my /bin/mount. It still wouldn't work, it told me I needed to be root to mount. Then I changed the group of the
executable to "storage" instead of "root". Still no dice (even though my user is a member of storage).
I'd like to get this minor niggle fixed first before I try to even contemplate tackling the horrible mess that is udev/hal (I don't understand anything about it).
Thanks in advance!
Last edited by Aktau (2009-05-25 16:03:49)Mr.Elendig wrote:
Aktau wrote:
Thanks for your replies!
Do you perhaps know why my mount just will not work without sudo? even though I have the "s" flag in user en the "x" flag in group and user? I'd really like to understand the fundamental issue here.
Once again, thanks for your swift and helpful replies, it's much appreciated.
You can only use mount and umount on a mount point, as a user, if it's in fstab with the 'user' or 'users' option. This is a security feature to prevent users from doing nasty things.
Hmmm, it makes sense from a security point of view.
I've also been digging around in the mount source code, some of the strange things I've encountered while using it that are in the source:
LINE: 918 in mount.c
switch (mnt_err) {
case EPERM:
if (geteuid() == 0) {
if (stat (node, &statbuf) || !S_ISDIR(statbuf.st_mode))
error (_("mount: mount point %s is not a directory"), node);
else
error (_("mount: permission denied"));
} else {
error (_("mount: must be superuser to use mount"));
break;
I've gotten the "mount: must be superuser to use mount" error at least once. This is really strange, as now it's checking on effective uid, which should be root for me
LINE: 1616 in mount.c
if (getuid () != geteuid ()) {
suid = 1;
if (types || options || readwrite || nomtab || mount_all ||
fake || mounttype || (argc + specseen) != 1)
die (EX_USAGE, _("mount: only root can do that"));
Look at those conditions, that's just damn weird. These are both single occurences btw, so I know I've made it that far in the code path
Last edited by Aktau (2009-05-25 15:22:31)
Maybe you are looking for
-
JSR 172 XML parser in WTK 2.5: problems compared to 2.2
Hi, I'm experiencing 2 problems with the WTK 2.5 JSR 172 XML parser that do not occur with: -WTK 2.2 -Sony-Ericsson Emulator WTK2 -Sony-Ericsson devices. They are: - attributes.getLocalName(i) always returns an empty string - documents with multiple
-
Why apple is not adding tweaks like activator,volume slider in multitasking bar and a blacklist app?
-
Hi Guru, My SAP version is 4.5B. I would like to check is there any standard SAP program I can use to generate Average Daily Balance(ADB) in this version ? Hope to hear from you. Regards Andrew Tay
-
Hi Gurus; I am using BI 7.0. My client wants a customized variable for 0CALMONTH with 2 dialog boxes in the selection screen saying "From month" and "To Month". When you input months, say; 06.2008 in "From Month" and 08.2008 in "To Month", the output
-
Steps To create workflow for HR module
hi experts, i have a requirment in HR module to create a workflow, requirment is when an employee is transferred to any other stores or departments automatically a mail has to be trigeered to xxxx mail id. as im new to workflow can any one kindl