TAILIEUCHUNG - SQL Clearly Explained- P7

SQL Clearly Explained- P7: You don’t need to be a database designer to use SQL successfully. However, you do need to know a bit about how relational databases are structured and how to manipulate those structures. | 308 Chapter 15 Embedded SQL else EXEC SQL COMMIT display error message continue processing There are three things to note about the COMMIT statement in this code The COMMIT must be issued after checking the SQL-STATE. Otherwise the COMMIT will change the value in SQLSTATE. There is no need to roll back a retrieval transaction so the code commits the transaction even if the retrieval fails. The COMMIT could be placed after the IF construct. However depending on the length of the code that follows error checking the transaction may stay open longer than necessary. Therefore the repeated COMMIT statement is an efficient choice in this situation. Indicator Variables The SQLSTATE variable is not the only way in which a DBMS can communicate the results of a retrieval to an application program. Each host variable into which you place data can be associated with an indicator variable. When indicator variables are present the DBMS stores a 0 to indicate that a data variable has valid data of a -1 to indicate that the row contained a null in the specified column and that the contents of the data variable are unchanged. To use indicator variables first declare host language variables of an integer data type to hold the indicators. Then follow each data variable in the INTO clause with the keyword INDICATOR and the name of the indicator variable. For example to use indicator variables with the customer data retrieval query Please purchase PDF Split-Merge on to remove this watermark. Retrieving Multiple Rows Cursors 309 EXEC SQL SELECT first_name last_name contact_phone INTO da_first INDICATOR in_first da_last INDICATOR in_last da_phone INDICATOR in_phone FROM customer WHERE customer_numb 12 You can then use host language syntax to check the contents of each indicator variable to determine whether you have valid data to process in each data variable. Note The INDICATOR keyword is optional. Therefore the syntax INTO first ifirst last ilast and so on is .

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.