Question:- Why SELECT is not preferred in Embedded SQL programs?
Answer:- SELECT is not preferred in embedded SQL programs for three reasons. First, if the table structure is changed by the addition or deletion of a field and the program is modified, then using SELECT might retrieve the columns that the user may not use. This would lead to Input-Output overhead and the chances of index-only scan are also eliminated.
Question:- When is the LIKE statement used?
Answer:- The LIKE statement is used to conduct partial searches such as the search of employees by name. It is not necessary to indicate the complete name, partial string matches would do.
Question:- How is the value function used?
Answer:- We can perform two tasks using the ‘value’ function: • First, to avoid −ve SQLCODEs by handling NULLs and 0s in the computation • Second, to substitute numeric values for NULLs used in the computation
Question:- What are UNION and UNION ALL?
Answer:- Both UNION and UNION ALL are used to combine the results generated by multiple SELECT statements. • UNION is the function that eliminates duplicates in the table • UNION ALL retains the duplicates
Question:- Is there any restriction on the use of UNION in Embedded SQL?
Answer:- While using UNION in Embedded SQL, it has to be in a CURSOR.
Question:- What do you mean by BETWEEN and IN? Is BETWEEN inclusive of specified range values?
Answer:- BETWEEN would supply a range of values, whereas IN would provide a list of values. BETWEEN is always inclusive of the range values specified.
Question:- How can the FIRSTNAME and the LASTNAME from the EMP table be concatenated to generate complete names?
Answer:- Below is the statement that can be used to concatenate the first and last names to display full names: FIRSTNAME II ** II LASTNAME FROM EMP
Question:- What is a CURSOR and what is its use?
Answer:- A CURSOR is a programming device that helps the SELECT statement find out a set of rows but displays them one at a time. This is because the host language can deal with only one row at a time.
Question:- How to retrieve rows from a DB2 table in Embedded SQL?
Answer:- Rows from a DB2 table in Embedded SQL can be retrieved using the single-row SELECT statement. Another way is by using the CURSOR statement. However, the first process is the preferred one.
Question:- What is the result of the OPEN CURSOR statement?
Answer:- In the simple OPEN CURSOR statement, the CURSOR is placed on the first row of a table. On the other hand, when the ORDER BY clause is added, rows would be fetched, sorted, and would be available for the FETCH statement.
Question:- Can there be more than one cursor open for any program?
Answer:- Yes! The user can have more than one cursor open for any program.
Question:- How would the VARCHAR column REMARKS be defined?
Answer:- The VARCHAR column REMARKS would be defined as follows: • 10 REMARKS • 49 REMARKS-LEN PIC S9(4) USAGE COMP • 49 REMARKS-TEXT PIC X(1920)
Question:- What is the physical storage length of each of the data types, DATE, TIME, and TIMESTAMP?
Answer:- The physical storage length of DATE is 4 bytes, TIME is 3 bytes, and TIMESTAMP is 10 bytes.
Question:- What is meant by DCLGEN?
Answer:- DCLGEN refers to Declaration Generator that is used to create the host language copy books for the table definitions. It also creates the DECLARE table.
