Compiled Messages: ------------------------------------------------------------ Message no. 6683 Posted by Swarna Bangaru (sbangaru) on Sunday, February 26, 2006 8:25pm Subject: Discussion Week-8 Hi regarding Ash's Question last week about Discussion-8, I think in the question for discussion-8 Dr.Liu is refefrring to the text of Chapter 5 in the course schedule, there is section 5.3 with examples in that text. ------------------------------------------------------------ Message no. 6686[Branch from no. 6683] Posted by Kelli Lemon (kmlemon) on Sunday, February 26, 2006 9:33pm Subject: Re: Discussion Week-8 However in the course textbook, PL/SQL and loops are discussed in chapter 4. ------------------------------------------------------------ Message no. 6694[Branch from no. 6683] Posted by Gwendolyn Mobley (gdmobley) on Monday, February 27, 2006 2:44am Subject: Re: Discussion Week-8 I agree, that this weeks project will use Chapter 5. There are also some examples in the Oracle 9 book we use as reference. Gwen ------------------------------------------------------------ Message no. 6696[Branch from no. 6694] Posted by Harold Harris (hjharris2) on Monday, February 27, 2006 9:05am Subject: Re: Discussion Week-8 Chapter 5 of the Course schedule is the correct chapter. I've also found that other programming text books can provide additional help for this weeks discussion. The three looping structures in PL/SQL are very similiar to those common to other programming languages. HH ------------------------------------------------------------ Message no. 6699[Branch from no. 6683] Posted by Gnaneshwar Bukka (gbukka) on Monday, February 27, 2006 11:58am Subject: Re: Discussion Week-8 yaa...this weeks discussion is related to chap05....I have to retype the whole discussion again....I lost it the first time!!!!!...dint save it while working on it in word.....anyways...bye Gnaneshwar Bukka. ------------------------------------------------------------ Message no. 6701 Posted by Rohini Shrestha (rshrestha) on Monday, February 27, 2006 1:02pm Subject: Error in code includes attachment I was trying to run PL/SQL codes provided by Dr. Liu in Chap 05. I found one error in exercise 5.2. Attached is the error messages that I got while running the script. So I slightly changed it. Hope it might be interesting. ------------------------------------------------------------ Message no. 6702[Branch from no. 6701] Posted by Krishnamurth Ashwini (kashwini) on Monday, February 27, 2006 2:43pm Subject: Re: Error in code

Rohini,

There is actually no error in the coding. "||" symbol is a concatenation character and you do not have to remove it from the script.

Did you copy and paste the script directly from the document into SQL PLUS? I assume that it when you get the following error:

outputString := ‘Hello’ ||‘World’;
                      *
ERROR at line 7: ORA-06550: line 7, column 21:
PLS-00103: Encountered the symbol "‘" when expecting one of the following:

SOlution:

Do the following-
1. First copy the script from the chapter05 document into a text editor.
2. Then go to the line that has outputstring:=‘Hello’ ||‘World’;
3. Delete the quotation marks and retype it again as 'Hello' ||'World';
4. You can observe that there is slight difference in the quotation marks now.
5. Now copy the script into sql plus. 6. you must not get this error again.

Ash

------------------------------------------------------------ Message no. 6703[Branch from no. 6702] Posted by Rohini Shrestha (rshrestha) on Monday, February 27, 2006 4:04pm Subject: Re: Error in code Hi Ash, I realized that and tried by editing and I got the result. Thankx for information though. Rohini ------------------------------------------------------------ Message no. 6704[Branch from no. 6696] Posted by Bikash Adhikari (badhikari) on Monday, February 27, 2006 5:05pm Subject: Re: Discussion Week-8 I will also agree with you on that HH. BIkash ------------------------------------------------------------ Message no. 6705[Branch from no. 6702] Posted by Bikash Adhikari (badhikari) on Monday, February 27, 2006 5:08pm Subject: Re: Error in code I ran the script perfectly fine. I will run if you follow Ash's instruction. BIkash ------------------------------------------------------------ Message no. 6706[Branch from no. 6705] Posted by Rohini Shrestha (rshrestha) on Monday, February 27, 2006 5:19pm Subject: Re: Error in code I already did...thank you though Rohini ------------------------------------------------------------ Message no. 6707[Branch from no. 6705] Posted by Rohini Shrestha (rshrestha) on Monday, February 27, 2006 5:23pm Subject: Re: Error in code whenever I run scripts provided by Dr. Lui regarding trigger, I got this message. Warning: Trigger created with compilation errors. What does this mean? Am I the only one who got this message or everyone got same? Rohini ------------------------------------------------------------ Message no. 6708[Branch from no. 6707] Posted by Krishnamurth Ashwini (kashwini) on Monday, February 27, 2006 5:49pm Subject: Re: Error in code Rohini, Yes I too got the same error message. Type the following command at the SQL prompt to see the details of the compilation errors. SQL>SHO ERR This command is a short form for 'Show error' You can see the list of most recent compilation errors. Ash ------------------------------------------------------------ Message no. 6709[Branch from no. 6707] Posted by Krishnamurth Ashwini (kashwini) on Monday, February 27, 2006 6:26pm Subject: Re: Error in code The script in page 39 has one error that I observed. Though it may seem to be a small error, it does show as a compilation error.It is in the line 7 of the script i.e Instead of statementType ;= ‘I’; It should be statementType := ‘I’; (It is colon after statementType and NOT a semicolon) Ash ------------------------------------------------------------ Message no. 6710[Branch from no. 6709] Posted by Rohini Shrestha (rshrestha) on Monday, February 27, 2006 9:24pm Subject: Re: Error in code Ash, Ya, even I tried that command "show error", but it said that there is no error. Then I post the problem. Did you get compilation error after you remove the semicolon? Rohini ------------------------------------------------------------ Message no. 6713[Branch from no. 6710] Posted by Krishnamurth Ashwini (kashwini) on Monday, February 27, 2006 9:53pm Subject: Re: Error in code Rohini, As far as I know you should get the list of errors with this command(SHO ERR). I got it and could rectify one error by changing the semicolon to colon. Ash ------------------------------------------------------------ Message no. 6714[Branch from no. 6713] Posted by Krishnamurth Ashwini (kashwini) on Monday, February 27, 2006 10:25pm Subject: Re: Error in code I got to create the trigger without any compilation errors by using the following script(Page 39). CREATE OR REPLACE TRIGGER logPartchanges AFTER INSERT OR UPDATE OR DELETE ON Parts DECLARE statementType CHAR(1); BEGIN IF INSERTING THEN statementType := 'I'; ------------------------------Error found in this line ELSIF UPDATING THEN statementType := 'U'; ELSE statementType := 'D'; END IF; INSERT INTO partsLog VALUES (SYSDATE, statementType, USER); END; ------------------------------------------------Error found in this line / Ash ------------------------------------------------------------ Message no. 6718[Branch from no. 6701] Posted by Sagun Piya (srpiya2) on Tuesday, February 28, 2006 1:29am Subject: Re: Error in code Hi Rohini, I did not find error in that code but I found error while executing for loop Sagun ------------------------------------------------------------ Message no. 6721[Branch from no. 6718] Posted by Rohini Shrestha (rshrestha) on Tuesday, February 28, 2006 10:28am Subject: Re: Error in code Hi Sagun, There isn't any error in any of the codes provided by Dr. Liu. We have to edit before executing. I didn't realize that when I first did. Later, I found the solution and I am ok now. Thank you though Rohini ------------------------------------------------------------ Message no. 6724[Branch from no. 6699] Posted by Muhammad Latif (mlatif) on Tuesday, February 28, 2006 12:18pm Subject: Re: Discussion Week-8 Hi: I agree with HH, Arsal ------------------------------------------------------------ Message no. 6728[Branch from no. 6724] Posted by Venkat Munagala (vrmunagala) on Tuesday, February 28, 2006 2:20pm Subject: Re: Discussion Week-8 I too agree with HH Rohit ------------------------------------------------------------ Message no. 6731 Posted by Bikash Adhikari (badhikari) on Tuesday, February 28, 2006 3:59pm Subject: Project IV As Dr. Liu mentioned that most of us got the project wrong in using the where clause. Most of us used where items.id = parts.id, which is a major logical problem when it should have been where items.p_id = parts.id. Are these two same or as Dr. Liu puts it they are different sa apples are form oranges. If so why are the two different? Bikash ------------------------------------------------------------ Message no. 6732[Branch from no. 6731] Posted by Waseem Manzoor (wmanzoor) on Tuesday, February 28, 2006 4:12pm Subject: Re: Project IV Hey Bikash I have the same doubts and I think we did it right because there is not mentioned this P_ID is a foreign key of parts table. So how we can know this that P_ID was foreign key in Item table. If it was foreign key then the name of primary key and foreign key should be same. As I notice parts table primary key name is ID and in Items table the key we are using as foreign has name P_ID, so as I know it does not follow the relational database rules. But May be I wrong. Even that ID is also not primary key but we can suppose this will be the primary key bcos there is no key mentioned in that table as a primary key. Waseem Manzoor ------------------------------------------------------------ Message no. 6733[Branch from no. 6683] Posted by Waseem Manzoor (wmanzoor) on Tuesday, February 28, 2006 4:14pm Subject: Re: Discussion Week-8 As most of us hv mentioned Discussion topic is related to chapter 5 of Notes provided by Dr. LIU. Waseem manzoor ------------------------------------------------------------ Message no. 6734[Branch from no. 6732] Posted by Krishnamurth Ashwini (kashwini) on Tuesday, February 28, 2006 4:35pm Subject: Re: Project IV This is how I understood this project. Below are the fields from the corresponding tables : PARTS TABLE: ID DESCRIPTION UNITPRICE ONHAND ---------- --------------- ---------- ---------- REORDER ---------------------------------------- 1 Fax Machine 299 277 50 ORDERS TABLE: ID C_ID ORDERDATE SHIPDATE PAIDDATE STATUS ---- ---------- --------- --------- --------- ------- 1 1 18-JUN-99 18-JUN-99 30-JUN-99 F ITEMS TABLE: O_ID ID P_ID QUANTITY ----- ---------- ---------- ---------- 1 1 3 1 The items table has 4 columns: O_ID, ID, P_ID and QUANTITY. Here O_ID and P_ID are foreign keys which are also primary keys in orders and parts tables respectively. If you do not know which field is a foreign key in a table, you can always go to the CREATE TABLE script that is in the sql file of the chapter that you use to run before working on the project. Foreign keys and primarykeys of every table has to be mentioned in the original script. Scan the original script once before doing any project in order to recgnise foreign and primary keys. SELECT i.o_id AS order_id,p.description, 2 i.quantity,p.unitprice, i.quantity * p.unitprice AS extend 3 FROM items i, parts p 4 WHERE p.id=i.p_id 5 ORDER BY order_id ASC; Line -1 : Selecting required fields from corresponding tables and renaming certain fields using "AS". Line- 3 : i represents items table and p represents parts table. Line -4 :In the above script p.id is the id in the parts table and i.p_id is the foreign key in the items table (in the convention i.p_id, i represents the items tables and p_id represents the foreign key field in items table). A WHERE clause is used in the script to create an "inner- join" of two tables i.e. items and parts. Ash ------------------------------------------------------------ Message no. 6735[Branch from no. 6731] Posted by Waseem Manzoor (wmanzoor) on Tuesday, February 28, 2006 4:40pm Subject: Re: Project IV But Ash the problem is there is not mentioned these are the foreign keys and these are primary keys. And the other question is I think primary key and foreign key should have the same name. what do u think? Waseem ------------------------------------------------------------ Message no. 6736[Branch from no. 6735] Posted by Krishnamurth Ashwini (kashwini) on Tuesday, February 28, 2006 4:48pm Subject: Re: Project IV Waseem, That is exactly why I said in my previous mail that skim the chapter.04.sql file once. We have already read in the initial chapters that we need to specify the primary keys and foreign keys while building a table. These files that we run before starting with our projects does everything for us (like building all the tables). What we are doing is just extracting values from these tables. If you open the chapter04.sql file you will see that the script references P_ID and O_ID as the foreign keys in the items table. Let me know if can't find it in the script. I will be glad to help you out. Ash ------------------------------------------------------------ Message no. 6737[Branch from no. 6736] Posted by Waseem Manzoor (wmanzoor) on Tuesday, February 28, 2006 4:57pm Subject: Re: Project IV yes Thanks Ass for helping it out. Actually Before that I was just seeing the creating table section. Now I saw the full script and in the bottom Dr. Liu did it through Alter Command. Waseem Manzoor ------------------------------------------------------------ Message no. 6738[Branch from no. 6737] Posted by Krishnamurth Ashwini (kashwini) on Tuesday, February 28, 2006 5:01pm Subject: Re: Project IV Exactly....It is specified using ALTER command. Glad you could get it:-) Ash ------------------------------------------------------------ Message no. 6742[Branch from no. 6702] Posted by Imran Pathan (ipathan) on Tuesday, February 28, 2006 6:10pm Subject: Re: Error in code Thank you ash for through explanation. That was really helpful Imran ------------------------------------------------------------ Message no. 6744[Branch from no. 6702] Posted by Antoinette Lockett (arlockett) on Wednesday, March 1, 2006 12:23am Subject: Re: Error in code Ash thank you very much for your help you seem like you have a good knowledge of Oracle. Antoinette Lockett ------------------------------------------------------------ Message no. 6745[Branch from no. 6744] Posted by Krishnamurth Ashwini (kashwini) on Wednesday, March 1, 2006 12:30am Subject: Re: Error in code Antoinette, I am glad that I could be of some help. Actually, I come from an electrical background and I haven't studied database/Oracle 'ever' before. I hope to learn a lot from this program. Ash ------------------------------------------------------------ Message no. 6748[Branch from no. 6738] Posted by Krupa Kandavalli (kkandavalli) on Wednesday, March 1, 2006 5:41pm Subject: Re: Project IV Thank you for the information Ash, I had the same doubt as waseem, now its cleared after going through the script file. ------------------------------------------------------------ Message no. 6749[Branch from no. 6731] Posted by Sagun Piya (srpiya2) on Wednesday, March 1, 2006 5:57pm Subject: Re: Project IV As far as I am concerned for the last project we should know the two common fields before we join two tables.Where id in the parts table is p_id in the items table. So we join two tables using these two fields. Sagun ------------------------------------------------------------ Message no. 6751[Branch from no. 6731] Posted by Venkat Munagala (vrmunagala) on Wednesday, March 1, 2006 6:36pm Subject: Re: Project IV I also got the comment from Dr. Liu regarding the logical problem, comparision of oranges and apples. Now after going through the discussion my doubt has been cleared. Thank u Ash for clarifying. Rohit ------------------------------------------------------------ Message no. 6753[Branch from no. 6683] Posted by Sagun Piya (srpiya2) on Wednesday, March 1, 2006 9:02pm Subject: Re: Discussion Week-8 we are referring chap 5 for this week's discussion Sagun ------------------------------------------------------------ Message no. 6754[Branch from no. 6734] Posted by Gnaneshwar Bukka (gbukka) on Wednesday, March 1, 2006 9:21pm Subject: Re: Project IV Hey Ash, very clarified explanation, thk u. Gnaneshwar Bukka. ------------------------------------------------------------ Message no. 6755[Branch from no. 6754] Posted by Krishnamurth Ashwini (kashwini) on Wednesday, March 1, 2006 9:24pm Subject: Re: Project IV You are welcome guys..I am glad I could clarify your doubts:-). Ash ------------------------------------------------------------ Message no. 6756[Branch from no. 6734] Posted by Bikash Adhikari (badhikari) on Wednesday, March 1, 2006 9:57pm Subject: Re: Project IV I think I have some idea whtas going on now!!! Thank you guys..... BIkash ------------------------------------------------------------ Message no. 6762[Branch from no. 6738] Posted by Muhammad Latif (mlatif) on Thursday, March 2, 2006 11:47am Subject: Re: Project IV Hey Ash: Very interesting information. I commend your knowledge :-) thanks for sharing Arsal ------------------------------------------------------------ Message no. 6763[Branch from no. 6751] Posted by Muhammad Latif (mlatif) on Thursday, March 2, 2006 12:55pm Subject: Re: Project IV Hi everyone: I was wondering if there is any SQL statement that shows us the primary key and foreign keys in a table? Arsal ------------------------------------------------------------ Message no. 6764[Branch from no. 6763] Posted by Krishnamurth Ashwini (kashwini) on Thursday, March 2, 2006 9:38pm Subject: Re: Project IV Arsal, Your question: I was wondering if there is any SQL statement that shows us the primary key and foreign keys in a table? The answer is: Yes, there is. Try out the following script and it shows all the constraint types in a table SQL> SELECT constraint_name, constraint_type 2 FROM user_constraints 3 WHERE table_name = 'ITEMS'; OUTPUT: CONSTRAINT_NAME C ------------------------------ - SYS_C005841 C SYS_C005842 C O_I_ID P PARTS_FK R ORDERS_FK R As per Oracle convention, C - stands for Check condition P - stands for primary key R - stands for foreign key. SOURCE: Refer chapter 2 of Oracle text book. Ash ------------------------------------------------------------ Message no. 6769[Branch from no. 6721] Posted by Abhash Bhandary (abhandary) on Friday, March 3, 2006 10:22am Subject: Re: Error in code thankyou for all the explanation Aswini, it was good help abhash ------------------------------------------------------------ Message no. 6770[Branch from no. 6764] Posted by Abhash Bhandary (abhandary) on Friday, March 3, 2006 10:27am Subject: Re: Project IV thanx Aswini , your explanation helped me as well to understand this stuff , i had the same comment from Dr. Liu comparing apples with oranges...hehehe...now i got that cleared. Abhash ------------------------------------------------------------ Message no. 6778[Branch from no. 6707] Posted by Alex Auffenorde (aaauffenorde) on Friday, March 3, 2006 8:58pm Subject: Re: Error in code No I do not get this error. ------------------------------------------------------------ Message no. 6779[Branch from no. 6731] Posted by Alex Auffenorde (aaauffenorde) on Friday, March 3, 2006 9:12pm Subject: Re: Project IV They are different because items.id is the primary key for the items table. The parts.id is the primary key for the parts table. These two are unique to that table. If you want to compare these two tables you would have to compare the foreign key on the items table that references the parts table, that would be items.p_id. items.p_id is the exact same as parts.id so that means they can be compared. Hence the correct answer: items.p_id = parts.id ------------------------------------------------------------ Message no. 6783[Branch from no. 6734] Posted by Imran Pathan (ipathan) on Saturday, March 4, 2006 7:11am Subject: Re: Project IV Thank you ash for the explaination. Imran ------------------------------------------------------------ Message no. 6784[Branch from no. 6731] Posted by Imran Pathan (ipathan) on Saturday, March 4, 2006 7:17am Subject: Re: Project IV To join items.id and parts.id we have to use a foreign key and that is using p_id. As the above two are different from one another we need to compare using a FOREIGN KEY. Imran ------------------------------------------------------------ Message no. 6787[Branch from no. 6769] Posted by Rhonda Nichols (renichols2) on Saturday, March 4, 2006 7:51am Subject: Re: Error in code Good catch guys. Simple things like a ; (semicolon) insead of a : (colon) can keep programmers at bay for many frustrating minutes/hours. ------------------------------------------------------------ Message no. 6788[Branch from no. 6731] Posted by Rhonda Nichols (renichols2) on Saturday, March 4, 2006 7:58am Subject: Re: Project IV Ash--great knowledge and understanding. Thanks for helping us. It is so easy to assume (like most of us did) that joining the two tables on fields of the same name would be the same thing. However, it is important to take the time to understand if we are really comparing apples to apples. I found this example to be a little more difficult because there were so many fields with "ID" as part of the name that it was hard to keep straight. ------------------------------------------------------------ Message no. 6789 Posted by Rhonda Nichols (renichols2) on Saturday, March 4, 2006 8:04am Subject: Try This How Smart Is Your Right Foot? This is so funny that it will boggle your mind. And you will keep trying it at least 50 more times to see if you can outsmart your foot. But you can't!!! 1. While sitting at your desk, lift your right foot off the floor and make clockwise circles with it. 2. Now, while doing this, draw the number "6" in the air with your right hand. Your foot will change direction!!! I told you so... And there is nothing you can do about it. ------------------------------------------------------------ Message no. 6790[Branch from no. 6789] Posted by Venkat Munagala (vrmunagala) on Saturday, March 4, 2006 12:28pm Subject: Re: Try This You are absolutely right Rhonda. I was unable to do a circle with my right leg. The leg was performing the action in clockwise direction while the hand was doing action in anticlockwise direction. I felt the impact of hand on the leg, so the leg also started rotating in anti-clockwise direction. Rohit ------------------------------------------------------------ Message no. 6791[Branch from no. 6683] Posted by Phanindra Maddhi (pmaddhi) on Saturday, March 4, 2006 1:31pm Subject: Re: Discussion Week-8 In the text loops r discussed in chapter 4 ------------------------------------------------------------ Message no. 6792[Branch from no. 6701] Posted by Phanindra Maddhi (pmaddhi) on Saturday, March 4, 2006 1:33pm Subject: Re: Error in code yaa when i run the code it is gving error with a symbol ------------------------------------------------------------ Message no. 6793[Branch from no. 6789] Posted by Phanindra Maddhi (pmaddhi) on Saturday, March 4, 2006 1:34pm Subject: Re: Try This yaa it is so funny ....phanindra ------------------------------------------------------------ Message no. 6795[Branch from no. 6789] Posted by Sagun Piya (srpiya2) on Saturday, March 4, 2006 6:05pm Subject: Re: Try This I tried several times but I can't write the number 6 in air. May be our mind do not perform two actions at one time. Sagun ------------------------------------------------------------ Message no. 6798[Branch from no. 6789] Posted by Imran Pathan (ipathan) on Saturday, March 4, 2006 7:17pm Subject: Re: Try This Yaaa its very difficult to do. I think its a matter of concentration. Only one thing is done at a time by the brain. Imran ------------------------------------------------------------ Message no. 6800[Branch from no. 6788] Posted by Kelsey Pooley (kjpooley) on Saturday, March 4, 2006 9:52pm Subject: Re: Project IV I agree with Rhonda. It is so hard to keep them all straight. I just assumed that if the field name was the same it was for the same thing (apples to apples). There are case study databases in the text starting on page 18 that are really useful. They contain diagrams of the tables and work like a map. It is much easier to see how the tables relate. If I was doing extensive work on a database, I would probably create something like this to reference. ------------------------------------------------------------ Message no. 6808[Branch from no. 6789] Posted by Gnaneshwar Bukka (gbukka) on Saturday, March 4, 2006 11:41pm Subject: Re: Try This Hey Rhonda, I tried to do that and to be frank, it was a success few times (NOT most of the time). Gnaneshwar Bukka. ------------------------------------------------------------ Message no. 6811[Branch from no. 6764] Posted by Bikash Adhikari (badhikari) on Sunday, March 5, 2006 12:46pm Subject: Re: Project IV As always thank you for the information. BIkash ------------------------------------------------------------ Message no. 6814[Branch from no. 6789] Posted by Harold Harris (hjharris2) on Sunday, March 5, 2006 6:38pm Subject: Re: Try This Good one Rhonda. I think I'll draw the number 6 with my left hand instead. :-) ------------------------------------------------------------ Message no. 6816[Branch from no. 6814] Posted by Abhash Bhandary (abhandary) on Sunday, March 5, 2006 6:55pm Subject: Re: Try This heheheheheheheh....so funny...i tried it too but in vain ...but its funny abhash ------------------------------------------------------------