Você está na página 1de 10

What are the disadvantages of PAGE level lock?

High resource utilization if large updates are to be done What is the diff bet plan,package,dbrm? plan: its executable module containg the access path package: its executable form of single dbrm dbrm:at precompilation time it stores the db2 statements its input for the bind process Plan is generated when you compile the DB2-SQL program. This plan is stored in the DBRM and binded to database as packages. (stored in s yscat.syspackages - pkgname) DBRM: Data base request module is generated by precompiler which contains the sq l statements which are separated from the source program. PACKAGE: By binding the DBRM package is generated.Package contains the internal structure of the original sql statements. PLAN: It is the combination of packages that are bind to form a PLAN. What is sqlcode -922 ? -922 means Authorization failure. What is the COBOL picture clause for a DB2 column defined as DECIMAL(11,2)? PIC S9(9)V99 COMP-3. Note: In DECIMAL(11,2), 11 indicates the size of the data type and 2 indicates t he precision. What is DCLGEN ? DCLGEN stands for Declaration generator its a db2 tool used to generate db2 equi valent cobol variables. using DCLGEN we can avoid coding effort and get 100% accuracy in conversation. How does Db2 use multiple table indexes? DB2 use the multiple indexes to satisfy multiple predicates in a SELECT statemen t that are joined by an AND or OR. What is COPY PENDING status? A state in which, an image copy on a table needs to be taken, In this status, th e table is available only for queries. You cannot update this table. To remove t he COPY PENDING status, you take an image copy or use REPAIR utility. My SQL statement SELECT AVG(SALARY) FROM EMP yields inaccurate results. Why? Because SALARY is not declared to have NULLs and the employees for whom the sala ry is not known are also counted. because null indicator has not been allocated to the nullable column.

At what stage db2 must be up? Db2 must be up while running the program What is an intent lock? An intent lock is at the table level for a segmented tablespace or at the tables pace level for a nonsegmented tablespace. They indicate at the table or tablespa ce level the kinds of locks at lower levels. Give some example of statistics collected during RUNSTATS? # of rows in the table Percent of rows in clustering sequence # of distinct values of indexed column # of rows moved to a nearby/farway page due to row length increase I have 1000 records in vsam,I want to read records 500 to 900 //JOB STATEMENT //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //AA1 DD DSN=DSRC239.KSDS.CLUSTER,DISP=SHR //AA2 DD DSN=DSRC239.NEW.PS,DISP=SHR //SYSIN DD * REPRO INFILE(AA1)OUTFILE(AA2)SKIP(499)COUNT(501) /* What is the difference between CS and RR isolation levels? CS: Releases the lock on a page after use RR: Retains all locks acquired till end of transaction cs: 1. when we read the record from one page to another page we will release the lock for previous page and lock the current page only. 2.it can be used only for write purpose RR: it wii be locked til the commit point irrespective of the page.

CURSOR STABILITY: It is a row level locking It accquires and exclusive lock on the row to be updated The lock will be released when the control moves to the next updatable row


It is a page level locking It accquires a exclusive lock on the entire page where the row is available The lock will be released when the control moves to the next updatable page. 30) When you COMMIT, is the cursor closed? - drona db2 interview questions What is the picture clause of the null indicator variable? ? it is not possible in comp declaring the picture clause it is not possible it is the jclerror What happens when you say OPEN CURSOR? If there is an ORDER BY clause, rows are fetched, sorted and made available for the FETCH statement. Other wise simply the cursor is placed on the first row. When you fire a open cursor command a buffer pool will create in the database en gine for particular cursor. A VARCHAR column REMARKS would be defined as follows: ... 10 REMARKS. 49 REMARKS-LEN PIC S9(4) USAGE COMP. 49 REMARKS-TEXT PIC X(1920). 05 var-length. 49 var-length1 pic s9(4) comp. 49 var-text pic x(). What is meant by index cardinality? The number of distinct values for a column is called index cardinality. DB2's RU NSTATS utility analyzes column value redundancy to determine whether to use a ta blespace or index scan to search for data. How to pass return codes from Cobol to jcl? By Using COND parameter in JCL.This parameter will automatically detect the retu rn code from the calling program. By Using the RETURN-CODE field in the COBOL program. How do you eliminate duplicate values in SELECT? ? Use SELECT DISTINCT ... 77) What is the picture clause of the null indicator variable? ? S9(4) COMP. What is diff b/w QMF & Spoofi?

execute more queries at a time. 2. In SPUFI result of the query will be in PS or in PDS member will store but 3.you know the sqlcode after executing the query. QMF: 1.you cannot execute more than one query. 2. In QMF result of the query u can?t store. 3.you can't know the sqlcode of the query.

The biggest difference between QMF and SPUFI is that QMF is a query/reporting en vironment with the ability to format reports. SPUFI is just a quick and dirty SQ L execution engine. If you need to produce nice looking reports, enable user inp ut to a query, or store your queries and reports for future usage, QMF is a much better technology for doing so. How to enter in xpediter? For Xpediting a program first a cmnddio load should be created.Then give xp wher e u can give the load lib and xped ur program How do you leave the cursor open after issuing a COMMIT? ( for DB2 2.3 or above only ) Use WITH HOLD option in DECLARE CURSOR statement. But, it has not effect in psue do-conversational CICS programs. We have to use With Hold option while declaring the cursor, this will prevent au tomatic closing of cursor whenever commit is used in the program.

Is BETWEEN inclusive of the range values specified? ? Yes. 34) What is the COBOL picture clause of the following DB2 data types: DATE, TIME, TIMESTAMP? DATE: PIC X(10) TIME : PIC X(08) TIMESTAMP: PIC X(26) After bind i how can we run a cobol-db2 program? Using the utility IKJEFT01 in the JCL. What is stored in tables under creator SYSIBM? Meta data information is stored in the sysibm schema. sysibm schema holds the da tabase information and this schema exists for each database and holds the tables , columns, procedures and others that a user creates under that database.

Question : How to read last record in vsam file.,I don't know how many records are there? Move highvalues to the key of the VSAM file and the issue Readnext record comman d. Then give Readprev command. This will read the last record. 108) What are the disadvantages of using VARCHAR? 1. Can lead to high space utilization if most of the values are close to maximum . 2. Positioning of VARCHAR column has to be done carefully as it has performance implications. 3. Relocation of rows to different pages can lead to more I/Os on retrieval. How many columns maximum can be created in a table of a inner table of the subqu erry Maximum number of columns in a table --> 256 Maximum lenght of a row in a table -- > 64KB By using any condition is there any way to abend a program.?If so how? What is low values and high values? LOW-VALUES and HIGH-VALUES are figurative constants that represent the lowest an d highest possible values for an alphanumeric data item. You would use them anyt ime you want to set or compare a data item to "all bits off" or "all bits on" va lues. On system 390, LOW-VALUE = X'00' or all binary zeroes. HIGH-VALUE = X'FF' or all binary ones. What is the significance of the CURSOR WITH HOLD clause in a cursor declaration? The clause avoids closing the cursor and repositioning it to the last row proces sed when the cursor is reopened. What is the restriction on using UNION in embedded SQL? It has to be in a CURSOR. How does DB2 determine what lock-size to use? 76) How do you retrieve the data from a nullable column? ? Use null indicators. Syntax ... INTO :HOSTVAR:NULLIND How will u send data from a cobol file to db2 table? USING HOST VARIABLE we can pass data from COBOL to DB2 What is a DB2 plan? An application plan or package is generated by the bind to define an access path .

How is a typical DB2 batch pgm executed ? 1. Use DSN utility to run a DB2 batch program from native TSO. An example is sho wn: DSN SYSTEM(DSP3) RUN PROGRAM(EDD470BD) PLAN(EDD470BD) LIB('ED 01T.OBJ.LOADLIB') END 2. Use IKJEFT01 utility program to run the above DSN command in a JCL. Assuming that a site?s standard is that pgm name = plan name, what is the easies t way to find out which pgms are affected by change in a table?s structure ? Query the catalogue tables SYSPLANDEP and SYSPACKDEP.

What does it mean if the null indicator has -1, 0, -2? ? -1 : the field is null 0 : the field is not null -2 : the field value is truncated When do you use the IMAGECOPY? Answers: To take routine backup of tables After a LOAD with LOG NO After REORG with LOG NO What is a DB2 access path? An access path is the method used to access data specified in DB2 sql statements . What is the difference between TYPE 1 index & TYPE 2 index TYPE 1 & TYPE 2 are specified when an index is created on the table. TYPE 2 inde x is the option, which comes with DB2V4. With TYPE 2 index data can be retrieved faster as only the data pages are locked and not the index pages. Hence TYPE 2 index is recommended. How do you insert a record with a nullable column? To insert a NULL, move -1 to the null indicator To insert a valid value, move 0 to the null indicator

how to add records to table through file-aid? Use DB2 FILE-AID OPTION 3.7. 1.First extract the records into a flat file and add new records into the file. Load the same file into DB2 table. What is sqlcode -811?

SELECT statement has resulted in retrieval of more than one row. What are simple, segmented and partitioned table spaces ? Simple Tablespace: Can contain one or more tables Rows from multiple tables can be interleaved on a page under the DBAs control an d maintenance Segmented Tablespace: Can contain one or more tables Tablespace is divided into segments of 4 to 64 pages in increments of 4 pages. E ach segment is dedicated to single table. A table can occupy multiple segments Partitioned Tablespace: Can contain one table Tablespace is divided into parts and each part is put in a separate VSAM dataset . What is the index ,types of index ? Index is a mechanism that allows to search data quickly. In SQL Server 2000, two kinds of index are there : 1 : Clustered Index (only one) 2: Non Clustered Index(up to 249) 22) What are the issues related with correlated subqueries? ? Sub-queries are nested SELECT statements. Sub-query enables user to base the sea rch criteria of one SELECT on the result of another SELECT statement. When sub-query refers to the table referred in the main-query then the sub-query is executed for every execution of the main-query. This kind of sub-query is ca lled correlated sub-query. Correlated sub-queries cannot be used for update/inse rt/delete purpose. In my jcl ,the 1st step is delete step, if the data set is existing, I want to d elete, that one ,if dataset is no existing, I do not want abend the job, how can I code in disp? //step05 exec pgm=iefbr14 //sysout dd sysout=* //sysprint dd sysout=* //file01 dd dsn=........., // disp=(mod,delete,delete), // space=(1,(1,1),rlse) //file02 dd dsn=..... (repeat for all the files) What is the physical storage length of each of the following DB2 data types: DATE, TIME, TIMESTAMP? DATE: 4bytes TIME: 3bytes TIMESTAMP: 10bytes Date : 10 bytes Time : 8 bytes Timestamp : 26 bytes What is a clustering index ?

Causes the data rows to be stored in the order specified in the index. A mandato ry index defined on a partitioned table space. How do you specify and use a cursor in a COBOL program? ? Use DECLARE CURSOR statement either in working storage or in procedure division( before open cursor), to specify the SELECT statement. Then use OPEN, FETCH rows in a loop and finally CLOSE. What are the contents of a DCLGEN? 1. EXEC SQL DECLARE TABLE statement which gives the layout of the table/view in terms of DB2 datatypes. 2. A host language copy book that gives the host variable definitions for the co lumn names. How do I see the table definitions (columns, data types of columns, constraints or default values set etc) of a table in QMF? I tried 'DESCRIBE TABLE' but didn' t work (not able to execute in QMF). I can see the DCLGEN but looking for a way to see the actual table definition. SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBNAME=table-name AND TBCREATOR=' creator-name'; or to see column names, types and lengths SELECT NAME,COLTYPE,LENGTH FROM SYSIBM.SYSCOLUMNS WHERE TBNAME=table-name AND TBCREATOR=' creator-name'; File contains 5 records say D,E,F,C,A-I want to copy D and A records only by usi ng file-aid? Answers: Go to file-aid copy option.Enter the from dataset to be copied and to dataset to which you want to copy.go to options. Enter 0 at Initial records to skip field. Then enter 3 at the no of records to skip field and 1 to no of records to select .press enter and PF3. Give name some fields from SQLCA. SQLCODE, SQLERRM, SQLERRD After retrieving the elements from production,how can do the testing before movi ng the changes to production. Whether we have to create the JCL for testing or i t will automatically tested and compiled? Whenever a component is retrieved from the production base to a package, the com ponent automatically gets compiled and staged. If not, then you can restage/reco

mpile (by issuing 'r'/'s' command) the component after it is pulled in to the pa ckage. If testing means seeing the output, then you have to have JCL to execute it. What is maximum number of one storage group? If it is the number of DASDs you want to know, then it is 133 DASDs. What does CURRENTDATA option in bind indicate CURRENTDATA option ensures block fetch while selecting rows from a table. In DB2 V4 the default has been changed to NO. Therefore it is necessary to change all t he bind cards with CURRENTDATA(YES) which is default in DB2V3 & earlier to CURRE NTDATA (NO). What is a collection? a user defined name that is the anchor for packages. It has not physical existen ce. Main usage is to group packages. In SPUFI suppose you want to select max. of 1000 rows , but the select returns o nly 200 rows. What are PACKAGES ? ? They contain executable code for SQL statements for one DBRM. For every application program that has embedded SQL statements in it, a single D BRM is created irrespective of number of SQL statements it has. If the main program calls 'n' modules which are again Cobol-DB2 programs, then ' n+1' DBRMs are created. These DBRMs are fed into BIND PACKAGE step to create a PACKAGE which is not exec utable. PACKAGEis then binded to have apllication PLAn which is executable Where is the output of EXPLAIN stored? ? In userid.PLAN_TABLE What happens during pre-compilation and finally bind process? Pre-compilation---> Pre compiler check's the program for any embedded sql statem ents if found than separates them into a DBRM and an object module is formed for the host language to be compiled by the compiler.....On the otherhand the DBRM that is formed is either binded into a package or a plan to form an effective ap plication plan....Now when the program that had embedded sql-statements is final ly run than,for each of the sql statements a call is made to the corresponding t able using the application plan which had the optimised accesss logic.Remember i n programs with embeded sql-statements at run-time a thread is created between t he program and the table it tries to access! what is a db2 precompiler? When a Cobol program contains any embedded SQL statements the pre-compiler separ ates the non-Cobol statements and the Cobol statements separately, then the precompilation process begins. The non-cobol (SQL) statements are stored as a membe r of the pds called DBRM, then the bind process begins, which checks for any syn tax errors in SQL statement and then creates the plan or packages as per the ins

tallation defines. plan -> group of packages makes a plan. It is nothing but the executables (load module) of the program, then the Cobol statements load module is stored separately but before execution the two l oad modules are combined and then executed. Precompiler: 1) Checks for SQL syntax in application prgram 2) Copies all the SQL statements into a sepearte member known as DBRM(DataBase R equest Module) 3) Comment all the SQL statements 4) Replaces all the SQL statements with corresponding langauge call statements. 5) Finally Puts Timestamp During Pre-compilation : 1. The embedded SQL statements are stripped out. In the source code they are co mmented out and instead CALL statements are inserted. 2. Based on the DECLARE TABLE statement, the columns of the tables used in the p rogram are understood and the SQL statements are checked for any syntax errors. 3. The stripped out SQL is transformed into a DBRM with an identical time stamp on both the DBRM and the main source program. What is difference between Collection and Version? collection: set of packages with a collection id version: it refers to a package created at a particular time.(ie) if the same pa ckage is created at a later time with no changes it will be a different version. there are two options for version add/replace. Add puts the new version keeping the older version. Replace will replace the older version.