TAILIEUCHUNG - Teach Yourself PL/SQL in 21 Days- P14

Teach Yourself PL/SQL in 21 Days- P14: Welcome to Sams Teach Yourself PL/SQL in 21 Days, Second Edition. The fact that you purchased this book indicates that you have an interest in learning the PL/SQL language, which is Oracle’s relational database procedural programming language. It allows you to develop powerful and complex programs to access and manipulate data in the Oracle8i database. We have attempted to include as many examples of PL/SQL code as possible to illustrate PL/SQL features | Answers 627 2. What function do I use to combine two strings together You use the CONCAT function however you can still rely on to concatenate strings. 3. What function converts 11 28 99 to an Oracle DATE The TO_DATE function gives you this flexibility. 4. You can use the TRUNC and ROUND functions with what data types Both NUMBER and DATE include the ROUND and TRUNC functions. Exercises 1. Create a PL SQL block that reads in the month of a date and displays the month in a Roman numeral format. Use a date of 06 11 67. This allows you to practice the TO_CHAR function. When printing the Roman numeral equivalent use LTRIM to remove any spaces padded to the left of the Roman numeral. If you are really ambitious on your own you can create the same RM-type function by using statements for practice from Day 4. Remember practice helps to solidify your knowledge through repetition and understanding. Here is one solution DECLARE v_Hold_Month Number BEGIN v_Hold_Month TO_NUMBER TO_CHAR TO_DATE 11-JUN-67 MM v_Hold_Month Converted to Roman Numeral LTRIM TO_CHAR v_Hold_Month RM END Your output is 6 Converted to Roman Numeral VI 2. Use the TRUNC function on the SYSDATE to round to the nearest century. The answer is SELECT TO_CHAR TRUNC SYSDATE CC MM DD YYYY HH MI SS AM Today s Date and Time from DUAL The output is similar to Today s Date and Time 01 01 1900 12 00 00 AM 628 Appendix 3. Use CONCAT to link two strings together. Repeat the same line by using C instead of CONCAT. Here is one solution DECLARE v_String1 VARCHAR2 60 CONCAT Connect Stringl to1 1 String2 v_String2 VARCHAR2 60 Connect Stringl to1 1 String2 BEGIN v_String1 v_String2 END Your output looks similar to Connect String1 to String2 Connect String1 to String2 4. Calculate the number of days between 01 01 97 to 03 31 97. Remember to use the TRUNC function to eliminate the TIME dependency. The answer is SELECT TRUNC TO_DATE

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.