Sie sind auf Seite 1von 67

Oracle FAQ's

1. What is an Oracle instance? Overview of an Oracle Instance Every running Oracle database is associated with an Oracle instance. When a database is started on a database server (regardless of the type of computer), Oracle allocates a memory area called the ystem !lobal "rea ( !") and starts one or more Oracle processes. #his combination of the !" and the Oracle processes is called an Oracle instance. #he memory and processes of an instance manage the associated database$s data efficiently and serve the one or multiple users of the database. #he Instance and the %atabase "fter starting an instance, Oracle associates the instance with the specified database. #his is called mounting the database. #he database is then ready to be opened, which ma&es it accessible to authori'ed users. (ultiple instances can e)ecute concurrently on the same computer, each accessing its own physical database. In clustered and massively parallel systems ((**), the Oracle *arallel erver allows multiple instances to mount a single database. Only the database administrator can start up an instance and open the database. If a database is open, the database administrator can shut down the database so that it is closed. When a database is closed, users cannot access the information that it contains. ecurity for database startup and shutdown is controlled via connections to Oracle with administrator privileges. +ormal users do not have control over the current status of an Oracle database. Q: What is a view? ,iew " view is a tailored presentation of the data contained in one or more tables (or other views). -nli&e a table, a view is not allocated any storage space, nor does a view actually contain data. rather, a view is defined by a /uery that e)tracts or derives data from the tables the view references. #hese tables are called base tables. ,iews present a different representation of the data that resides within the base tables. ,iews are very powerful because they allow you to tailor the presentation of data to different types of users. ,iews are often used to0 1 provide an additional level of table security by restricting access to a predetermined set of rows and2or columns of a table 1 hide data comple)ity 1 simplify commands for the user 1 present the data in a different perspective from that of the base table 1 isolate applications from changes in definitions of base tables 1 e)press a /uery that cannot be e)pressed without using a view What is referential integrity? 3ules governing the relationships between primary &eys and foreign &eys of tables within a relational database that determine data consistency. 3eferential integrity re/uires that the value of every foreign &ey in every table be matched by the value of a primary &ey in another table.

4. +ame the data dictionary that stores user5defined constraints6 - E378O+ #3"I+# Tech Interviews comment by Krishna 9. What is a collection of privileges6 user7tab7privs7made user7tab7privs7recd Tech Interviews comment by Krishna :. napshot0 " snapshot is a read5only copy of a table or a subset of a table. Tech Interviews comment by Krishna ;. 8an i e)ecute tored *rocedures < =unctions from >? prompt 6 If yes how can i e)ecute 6 Tech Interviews comment by Koteswara Rao @. Ai Brishna What is a collection of privileges6 collection of privilages is role. sasi242@yahoo.com Tech Interviews comment by Sasidhar C. What is a cursor6 "ns0 cursor is a private s/l wor& area used to perform manipulations on data using plDs/l. adv0 1.mainly used for multiple row manipulations and loc&ing columns. note0 data which is populated into the cursor is &nown as active dataset. cursors are of two types 1.implicit 4.e)plicit implicit EEE attributes or properties for implicit cursor 1.s/lFis open0attribute returns a boolean value stating wether the cursor is open or closed. 4.s/l F found0 returns boolean value stating whether the record is found in the cursor. 9.s/lFnotfound 0 returns a boolean value stating whether the record is not found in the cursor :.s/l Frowcount 0returns a pneumeric value stating no.of rows e)ecuted in the cursor. e)plicit cursorsEretrives multiple rows. GGGGGGGGGGGG adv0 users can perform loc&s on th data in the cursor attributes 1.F is open 4.F found 9.F not found :.F rowcount +ote0 %"#" which is populated in the cursor is &nown as active data set. WE 8"+ W3I#E #WO 8-3 O3 I+ O+E *3O!3"( WE 8"+ W3I#E " 8-3 O3 *E8I=HI+! *"3"(E#E3 8-3 O3 WI#A -*%"#E 8?"- E I - E% #O *E3=O3( ?O8B O+ %"#". Aappy 8oding sasi242@yaho.com Tech Interviews comment by Sasidhar I. What is a se/uence6 "ns0It is a database obJect to auto generate numbers. Aappy 8oding sasi242@yahoo.com

Tech Interviews comment by Sasidhar K. +ame the data dictionary that stores user5defined tored procedures6 ans 05 user7obJects Tech Interviews comment by Aravind Kumar 1L. hi , i would li&e &now more about s/l advanced /ueries . Tech Interviews comment by mrs 11. >uestion0Why -se /lG ?oader in Oracle %atabase6 "nswer0 #he /l ?oader module of the oracle database (anagement ystem loads data into an e)isting O3"8?E table from an e)ternal files.It is available locally only on 8( and *8s with oracle version ;. #hroughout this documentation the 8"3 database described in 3eferance " is used for illustration. #here are several methods others than using >? G?oader of inserting data into a table. 1. #he /l insert command may be used from the >? G *lus module, for E)ample 0 insert into 8"3 values(M) where the values to be inserted into a row of the table are listed inside the parentheses. %ates and 8haracters data must be urrounded by single /uotes. items are seperated by commas. 4. /lG=orms allows you to add rows interactively using forms. #he forms may contain default values and chec&s for invalid data. 9. O%? loads the table from a control file and separate fi)ed format data file. O%? is available on all versions of O3"8?E . >? G ?oader is much more fle)ible than O%? and will eventually supersede it on all systems. Tech Interviews comment by Shashi 14. We can e)ecute a function in s/l /uery select functionname(paramaters) from dual. uppose i am created a function add which returns the addition of two numbers then select add(9,:) from dual. C O%N8 stands for open database connectivity trigger is a stored procedure which auotomatically fired on a table whenever any dml operation is affected in the table. we can create ddl trigger,database trigger(logon,logoff,startup,startoff),audit triggers pseudo column the column which does not e)ist in a table e).rownum,rowid,level etc Tech Interviews comment by Dinkocet 19. #han&s a lot for providing answers for the above /uestionsMi am grateful to all of you 3egards 3avi *ra&ash Tech Interviews comment by Ravi Prakash 1:. "nswer to some of the /uestions above0 O%N8 stands for Open %atabase 8onnectivity. It is used to connect the frontend with the bac&end(database) +ormali'ation is the techin/ue of designing the database with the least redundancy and duplicacy of data. #ypes of +ormali'ation0 1 += 4 += 9 += N8+= ; += @+= 0 Impossible to achieve this level of normali'ation Tech Interviews comment by Vick

1;. hi i have problem with import i have e)port file on linu) os and oracleIi i want import on windows platform what should i do6 Tech Interviews comment by rekhalal 1@. Ai Brishna , #han&s a lot for the "nswers Tech Interviews comment by sangeetha 1C. Ai "ll, #han& you for all posting the > < ". Tech Interviews comment by Pranesh 1I. what is a synonym 6 "ns. " synonym is an alternative name for tables,views,procedures and other database obJects generally when we have more than one schema and we wish to access an obJect of a different schema then we create synonyms for that obJect in the schema where we wish to access the obJect. ynta)0 create synonym synonym5name for schemaname.obJect5name what is an e)ception 6 E)ception is an event that causes suspension of normal program e)ecution. In oracle there are serveral types of e)ceptions 1) *re5defined e)ceptions li&e +O7%"#"7=O-+%,#OO7("+H73OW 4) -ser5defined e)ceptions which would validate the business logic 9) unnamed system e)ceptions which are raised due to errors in the application code .. you can name these e)ceptions using *3"!(" EO8E*#IO+7I+I# :)-nnamed programmer5defined e)ceptions. E)ceptions that are defined and raised in the server by the programmer. In this case, the programmer provides both an error number (between 54LLLL and 54LKKK) and an error message, and raises that e)ception with a call to 3"I E7"**?I8"#IO+7E33O3. for all the e)ceptions raised oracle fills in s/leerm and s/lcode variable which provide the error message and error code for the e)ception raised. What are pseudo5columns in >?6 *rovide e)amples6 " pseudocolumn behaves li&e a table column, but is not actually stored in the table. Hou can select from pseudocolumns, but you cannot insert, update, or delete their values. E)amples0 8-33,"?,+EO#,"?,3OWI%,?E,E? what is a schema 6 " schema is a oracle database user account. Tech Interviews comment by Rajesh B 1K. What is a schema 6 " database user account is called a schema. Tech Interviews comment by thevampirea@yahoo co in 4L. What is a schema 6 " schema is a logical collection of database obJects li&e tables, views, p&gs, procedures, triggers, etc. It usually has an associated database user. Tech Interviews comment by Anil Kuppa 41. this is Just to subscribe Tech Interviews comment by !atraj 44. What is a co5related sub5/uery6 It is very similar to sub5/ueries where the parent /uery is e)ecuted based on the values returned by sub5 /uries. but when come$s to co5related sub/ueries for every instance of parent /uery sub/uery is e)ecuted and

based on the result od sub5/uery the parent /uery will display the record as we will have refernce of parent /uries in su5/ueries we call these as corelated sub/uries. so, we can define co5related sub /uery as for every record retrival from the sub /uery is processed and based on result of process the parent record is displayed. Tech Interviews comment by !atraj 49. wht is the maJor difference b2w oracle Ii < Ki Tech Interviews comment by renjith 4:. what is trigger6 #rigger is an event. It is used prevent the invalid entries of the data.#here has a different types of trigger are available. 1)rowlevel trigger before insert,before delete,before update after insert,after delete,after update 4)statement level trigger before insert,before delete,before update after insert,after delete,after update 9)I+ #E"% O= trigger :) chema level #riggers ;) ystem level #riggers Tech Interviews comment by Ramananth 4;. co5related sub5/uery 5 I assume you mean correlated sub5/uery6 Tech Interviews comment by "ark 4@. Ai i want to get information about coalescing to tablespace6 end theinformation to me through the mail id i have mentioned above. 3egards ?uc&y Tech Interviews comment by #ucky 4C. i want to &now how to use rownum and rowid efficiently in s/lGplus /ueries Tech Interviews comment by sudha 4I. hi will u ple'''' tell me can we return cursor in the function if yes than what the process6 can we define e)ceptions twice in same bloc&6 what is ma). no. of statment that can specified in triggers6 in cursor where the cursor variable used in pac&age body6 Tech Interviews comment by lekha reddy 4K. is there any solution to delete a particular colum in a database by s/l Tech Interviews comment by manraj 9L. Aow can I assigned two table in a single bloc& (database bloc&) in forms@i6 Tech Interviews comment by Sudipta 91. >. Is there any solution to delete a particular colum in a database by s/l6 ". #his is cant be done in versions before Ki. In Ki >?P alter table delete column . Tech Interviews comment by $aurav Sachan 94. pseudo columns in s/l are currval and ne)tval.#hese are used with se/uences to retreive the ne)t se/uence value and current se/uence value. #he usage is as follows suppose abc is the se/uence name if i want to see the currval of the se/uence we issue the s/l statement select abc.currval from dual.

if we want to see the ne)t value of the se/uence we issue the command select abc.ne)tval from dual. Tech Interviews comment by satish 99. Ai here i would li&e to give simple answer for /uestion Q1 What is an oracle instance6 "n Oracle instance consists of the ystem !lobal "rea ( !") memory structure and the bac&ground processes used to manage a database. "n instance is identified by using methods specific to each operating system. #he instance can open and use only one database at a time. rinivasa 3eddy Tech Interviews comment by Srinivasa Reddy 9:. hi, what is the maJor difference between normal =O3 ?OO* and 8-3 O3 ?OO*6 53egards (uttappa .#. Tech Interviews comment by "uttappa S % 9;. Ai, when we install the new version of Oracle then what happens to our earlier forms6 Tech Interviews comment by &jjwala 9@. what is overloading of pac&ages in oracle Tech Interviews comment by jyothi 9C. is it possible to create a cursor which is based on more than one table. Tech Interviews comment by vasundhara 9I. #he correct answer for this /uestion is >. Is there any solution to delete a particular colum in a database by s/l6 ". alter table drop column or first mar& the column unused alter table set unused column then drop it alter table drop unused columns. #his will drop all the columns mar&ed as unused. If a particular column has to be dropped, mention the column name after columns Tech Interviews comment by Ram 9K. the answer thevampirea@yahoo.co.in for RWhat is a schema6S is wrong. " schema is a collection of logical obJects owned by a user. " user in that regard is an account registered with the Oracle server. Once u login into ur account2user, u can access other user$s schema obJects li&e i can write scott.emp, if at all i$ve acces to scott user$s emp table. Tech Interviews comment by rahul :L. %ata (odel0 #he logical data structure developed during the logical database design process is a data model or entity model. It is also a description of the structural properties that define all entries represented in a database and all the relationships that e)ist among them. F3OW#H*E is used to declare a record with the same types as found in the specified database table, view or cursor F#H*E is used to declare a field with the same type as that of a specified table$s column. Inde) for a physical structure (b5tree) to help you /uery run faster. #able partition is a method of brea&ing a large table into smaller tables grouped by some logical separators. in your case, having both inde) and partition will ma&e things faster. %ata 8ontrol statements #hese are used to control the data using %8? (data control language) e)0 !rant etc.

#rigger 0 " program in a database that gets called each time a row in a table is I+ E3#E%, -*%"#E%, or %E?E#E%. #riggers allow you to chec& that any changes are correct, or to fill in missing information before it is commited. #riggers are normally written in *?2 >? or Tava. 3elation0 (athematical term for a table. 3edo ?og0 " set of files that record all changes made to an Oracle database. " database (- # have at least two redo log files. ?og files can be multiple)ed on multiple dis&s to ensure that they will not get lost. "lso see thread. Oracle "38Aiver *rocess. "38A is an Oracle bac&ground process created when you start an instance in "38AI,E ?O! (O%E. #he "38A process will archive on5line redo log files to some bac&up media. Nuffer 8ache0 #he portion of the !" that holds copies of Oracle data bloc&s. "ll user processes that connect to an instance share access to the buffer cache. *erformance of the buffer cache is indicated by the N8A3 (Nuffer 8ache Ait 3atio). Nac&ground *rocess0 +on5user process that is created when a database instance is started. #hese processes are used to manage and monitor database operations. E)ample bac&ground processes0 (O+, *(O+ etc. #wo5*hase 8ommit0 " strategy in which changes to a database are temporarily applied. Once it has been determined that all parts of a change can be made successfully, the changes are permanently posted to the database. #he steps involved are the RpreparedS and Rcommit re/uestS -nion0 "ll the distinct rows are selected by either /uery. Intersect0 "ll distinct rows selected by both /ueries (inus0 "ll distinct rows that are selected by the first E?E8# statement and that are not selected in the second E?E8# statement. Toin0 #he process of combining data from two or more tables using matching columns. #ypes of Join are E/ui Toin, Outer Toin, elf Toin, +atural Toin, etc. E/ui Toin0 "n E/ui Toin (a&a. Inner Toin or imple Toin) is a Join statement that uses an e/uivalency operation (i.e0 col" U colN) to match rows from different tables. #he converse of an e/ui Join is a none/uiJoin operation. Outer Toin0 imilar to the E/ui Toin, but Oracle will also return non matched rows from the tale with the outer Join operator (V). (issing values are filled with null values. elf Toin0 " Join in which a table is Joined with itself. +atural Toin0 " Join statement that compares the common columns of both tables with each other. One should chec& whether common columns e)ist in both tables before doing a natural Join. Integer %ata #ypes0 ,"38A"34 ( i'e), +-(NE3 (*recision, i'e) %enormali'ation0 #he opposite of data normali'ation (almost). In a denormali'ed database, some duplicated data storage is allowed. #he benefits are /uic&er data retrieval and2or a database structure that is easier for end5users. 3egards. Tech Interviews comment by 'enis 'ohn K
0 comments

Oracle apps technical document


1) What is !"? #rchitect$re of apps?

" pac&aged business software system that lets a company automate andintegrate the maJority of its business processes. share common data and practices across the enterprise. WandX produce and access information in a real5time environment. 2) %ell me some thing a&o$t 'Q()(O#* !. /l G loader is a bul& loader utility used for moving data from e)ternal files into the oracle database. /l G loader supports various load formats, selective loading, and multi5tables loads. 1) conventional 55#he conventional path loader essentially loads the data by using standard Yinsert$ statement. 2) +irect

55 the direct path loader (direct U true) by possess of logic involved with that, and loads directly in to the oracle data files. EO05
(y data.csv file 1LL1, Rscott tigerS,1LLL,:L 1LL4,SgvreddyS,49:;,;L

?oad data Infile Yc0DdataDmydata.csv$ Into table emp =ields terminated by R,S optionally enclosed by YS$ (empno, empname,sal,deptno) Psqlldr scott/tiger@vis control=loader.ctl log= gvlog.log bad=gvbad.baddiscard=gvdis.dsc .
,) how +o $ +$mp +ata from pl-s.l &loc/ to flat files? -sing utl7file pac&age, we can dump data from pl2s/l bloc& to flat file. "! )! Q01! 2 3%' for -#?7=I?E is specify the accessible directories for the -#?7=I?E function in the initiali'ation file (I+I#.O3") -sing the -#?7=I?E7%I3 parameters. E)0 -#?7=I?E7%I3 U 4:) 55remember to update I+I# I%.O3", 55utl7file7dir U Yc0Doradata$ %eclare =p utl7file.file7type. Negin =p 0U utl7file.fopen(c0Doradata$,tab1.t)t$,$w$). -tl7file.putf(fp,$Fs Fs Dn Yte)t field$, ;;). -tl7file.fclose(fp). End.

4) What is ' %)O5)6OO7'? 8ollection of 8hat of "ccounts and 8urrency and 8alendars is called ON 8) What is the interface? Interface #able is a table which is used as medium for transfer of data between two systems. 9) What is invoice? end you a re/uest for payment :) What is 136O03* an+ O0% 6O03*? ;*ifferent types of interfaces) Inbound Interface0 =or inbound interfaces, where these products are the destination, interface tables as well as supporting validation, processing, and maintenance programs are provided. Outbound Interface0 =or outbound interfaces, where these products are the source, database views are provided and the destination application should provide the validation, processing, and maintenance programs <) %ell me what r the 6ase ta&les in the #!? hz_parties (party_id) (store info about org, groups and people)
AZ7*"3#IE stores information about parties such as organi'ations, people, and groups, including the identifying address information for the party.

hz_cust_accounts (cust_account_id)
AZ78- #7"88O-+# stores information about customer relationships. If a party becomes a customer, information about the customer account is stored in this table. Hou can establish multiplecustomer relationships with a single party, so each party can have multiple customer account records in this table.

hz_cust_acct_sites_all (cust_acct_site_id)

AZ78- #7"88#7 I#E 7"?? stores information about customer sites.One customer account can have multiple sites. #he address is maintained in AZ7?O8"#IO+ .

hz_cust_site_uses_all (site_use_id)
AZ78- #7 I#E7- E 7"?? stores information about site uses or business purposes. " single customer site can have multiple site uses, such as bill to or ship to, and each site use is stored as a record in this table.

hz_party_sites (party_site_id)
AZ7*"3#H7 I#E stores information about the relationship between *arties and ?ocations. #he same party can have multiple party sites.*hysical addresses are stored in AZ7?O8"#IO+ .

hz_locations (location_id)
AZ7?O8"#IO+ stores information about physical locations.

hz_Person_Profiles (person_profile_id)
AZ7*E3 O+7*3O=I?E stores detail information about people.

hz_Organization_Profiles (organization_profile_id)
AZ7O3!"+IZ"#IO+7*3O=I?E stores credit rating, financial statistics, socioeconomic and corporate lin&age information for business sites. #he primary &ey for this table is O3!"+IZ"#IO+7*3O=I?E7I%.

=) What r the ta&le>s interface ta&les in the c$stomer interface ta&les? 1) !a?c$stomers?interface?all
#his table stores customer, address, and business purpose information. Hou do not have to enter values in this table if you do not want to import customers, addresses, or business purposes. #**! ''1 thro$gh 4 Enter the address for your customer in these four columns. Hou can enter up to four lines of an address. @ali+ation: If you enter a value in O3I!7 H #E(7"%%3E 73E=, you must enter a value in "%%3E 1. =or multiple rows with the same address reference, insert values in address 1[:. *estination: AZ7?O8"#IO+ ."%%3E 1, AZ7?O8"#IO+ ."%%3E 4, AZ7?O8"#IO+ ."%%3E 9, AZ7?O8"#IO+ ."%%3E :

2) !a?c$stomer?profile?int?all
" customer level profile must e)ist in "78- #O(E37*3O=I?E 7I+#E3="8E for new customers and each bill[to business purpose.

,) !a?contact?phones?int?all
#his table stores telephone numbers for customers, addresses and contacts as well as contacts for customers and addresses.

4) !a?c$stomer?&an/s?int?all
#his table stores ban& information for a customer or for a specific Nill[#o address, you must enter a ban& account for this customer,

8) !a?c$st?paymetho+?int?all
#o import payment methods for customers and bill[to business purposes,

10) What r the staging ta&les in the c$stomer interface? 3a7customers7stg 3a7customers7address7stg 3a7customers7point7stg 3a7customers7contact points7stg 3a7customers7relate7stg 3a7customer7error. 11)%ell me some man+atory col$mns in the c$stomer interface ta&les? a) !a?c$stomers?interface?all 1) Orig7system7customer7ref 4) insert7update7flag

9) customer7number :) customer7status ;)last7updated7by @) last7updated7date C)created7by I) creation7date. &) !a?c$stomer?profile?int?all 1) customer7profile7class7name c) !a?contact?phones?int?all 1)orig7system7telephone7ref 4)telephone 9) telephone7type +) !a?c$stomer?&an/s?int?all 1) ban&7a2c7name 4)ban&7a2c7no 9)ban&7a2c7currency7code e) !a?c$st?paymetho+?int?all 1) payment7method7name 12)%ell me the 3avigation for c$stomer interface? 3eceivables Interface 8ustomers 1. What ta&les cannot &e $p+ate+ thro$gh c$stomer interface? +o updates will be allowed to be made through customer interface for =ollowing tables 3"7 I#E7- E 7"?? 3"78- #O(E373E?"#IO+ AI* 7"?? 3"78- #73E8EI*#7(E#AO% "*7N"+B7N3"+8AE "*7N"+B7"88O-+# 7"?? "*7N"+B7"88O-+#7- E 7"?? 2. Aow to sen+ a++itional c$stomer an+ a++ress information thro$gh c$stomer interafce Aere is where attribute columns are used. G "dditional 8ustomer data can be populated in 3"78- #O(E3 7I+#E3="8E7"??.customer7attribute1 to 1; #his will go into 3"78- #O(E3 .attribute1 to 1; G "dditional address information can be populated in 3"78- #O(E3 7I+#E3="8E7"??.address7attribute1 to 1; #his will go into 3"7"%%3E E 7"??.attribute1 to 1; "nd so on. 8. What sho$l+ &e the &atch siBe ;n$m&er of c$stomer recor+s) general g$i+elines for optimal performance "bout 1L,LLL records per bacth is ideal, it is suggested to &eep the batch si'e small. 9. Why +oes c$stomer interface error o$t if there is mismatch in a++ress information? Necause the code validates against these mismatches. arplscin.s.l an+ arpl&cin.s.l It validates the address being inserted or updated with respect to the ta) location fle)field structure. =or each row being inserted or updated in 3"78- #O(E3 7I+#E3="8E, and that has not already been mar&ed in error,

the set7location7ccid function is called to return either an e)isting ccid for the address entered or to create a new entry in "37?O8"#IO+7,"?-E for this new address. #he 3"78- #O(E3 7I+#E3="8E record is then updated with the value of the ccid returned. :. Aow +o yo$ sen+ recor+s at c$stomer level profile an+ a++ress-site level profile? =or every customer record in 3"78- #O(E3 7I+#E3="8E7"??, insert two records in table 3"78- #O(E37*3O=I?E 7I+#7"??. (3efer +ote0 1LCLILL.@ ) =. *oes C$stomer 1nterface import salesperson +ata6 +o, 3efer Enhancement Nug0 1:C:K; 11. C$stomer 1nterface process can &e $se+ for $p+ating the c$stomer information Aow +oes the 0"*#% wor/? 8urrent functionality of 8ustomer Interface is to update all the data. Hou cannot run 8ustomer Interface to update only changed data. (3efer Nug0 ICK141 for the intended functinality) 12. What are some of the important fiel+s that C$stomer 1nterface +oes not loa+? +ot all fields in 3"78- #O(E3 are being loaded by the interface. I878O%E ! "7I+%I8"#O3 =ON7*OI+# "?E 78A"++E?78O%E =3EI!A#7#E3( W"3EAO- E7I% *3I8E ?I # AI*7*"3#I"? *"H(E+#7#E3(7I% in 3"7 I#E7- E .*"H(E+#7#E3(7I% (3efer Enhancement 3e/uest Nug0 4:;9LL) 1,. 3ew %C#-C$stomer 2o+elD how to loa+ c$stomer as " !'O3 or O!E#31F#%1O3 thro$gh C$stomer 1nterface? a) *opulate ra7customers7interface7all . person7flag U \H\ 3un 8ustomer Interface process will load this record as *E3 O+ b) *opulate ra7customers7interface7all . person7flag U \+\ ( or +-?? ) 3un 8ustomer Interface process will load this record as O3!"+IZ"#IO+ 1,) %ell me what is the proce+$re to +evelop an interface?
a. =irst we will get the 3e/uirement document. b. We will create control file based on that plot file. c. #hen the control files which loads the data into staging tables. d. #hrough pl2s/l programs we will mapping and validate the data and then dump into the interface tables. e. #hrough the standard programs we will push the data from interfacetables to Nase tables. 14) What vali+ations $ +i+ in the c$stomer interface? a. c$stomer name 0 the same customer reference can$t have different customer names with in this table AZ7*"3#IE .*"3#H7+"(E b. c$stomer n$m&er 0 must be null if your r using automatic customer numbering, must e)it if you are not using automatic customer numbering. #his value much be uni/ue with in AZ7*"3#IE c. c$stomer stat$s 0 must be Y"$ for active or YI$ for inactive AZ7*"3#IE 7 #"#d. &an/ acco$nt n$m or &an/ acco$nt c$rrency co+e 0 if the ban& a2c already e)ist do not enter a value if the ban& a2c does not e)ist you must enter a value e. &an/ a-c name 0 it must e)ist in "*7N"+B7"88O-+# or if it does not e)ist values must e)ist for N"+B7"2878-33E+8H78O%E

N"+B7"287+-( N"+B7+"(E N"+B7N3"+8A7+"(E +ote 0 every interface table has two error msg 1) Error code. 4) Error msg. 18) Aow can $ call a stan+ar+ interface program from s.l or pl-s.l co+e?
=+%73E>-E #. -N(I#73E>-E # (Y*O$,$EOE8-#"N?E +"(E$,,,,*"3"(E#E3 ) 19) #"1>s 5O! C0'%O2 ! 13% !5#C ? AZ78- #7"287,Z*-N.-*%"#E78- #7"28 AZ78- #7"287,Z*-N.83E"#E78- #7"28 =+%7*3O=I?E =+%7"**?I8"#IO+ =+%7!?ON"? =+%5=I?E =+%78O+8 -N(can submit conc program in host invironment)

1:) %ell me some #"1? =+%7=I?E.*-#?I+E(=+%7=I?E.?O!) =+%7=I?E.*-#?I+E(=+%7=I?E.O-#*-#) 1s the "rogram eGitsD +elete conc program an+ its eGec$ta&les.
I= =+%7*3O!3"(.*3O!3"(7EOI# (YE(*$,"**?I8"#IO+7+"(E7I+) #AE+ =+%7*3O!3"(.%E?E#E7*3O!3"((YE(*$,"**?I8"#IO+7+"(E7I+) =+%7*3O!3"(.%E?E#E7EOE8-#"N?E(YE(*$,"**?I8"#IO+7+"(E7I+) E+%.

1<) What are profile options? Is the =unctional and #echnical behavior of Oracle "pplications *ac&age. EO0 5 I want to assign the user9 responsibility to p: printer then 'ystem #+ministrator "rofile 'ystem (FND_ !"FI#$_" TI"N%& 1=) Oracle )6$siness s$ite? "racle a''s ( analytical com'onents so)tware. (Oracle discover) (Oracle sales analy'er) (Oracle financial analy'er) (Oracle mar&eting analy'er) 24) What is m$lti org? H(egal entity has more than one operating $nit is calle+ as m$lti orgI a) Nusiness group 555 Auman resources information is secured by Nusiness group b) ?egal entity. 555 inter5company and fiscal2ta) reporting. 'ec$rity responsi&ility operating $nit. c) Operating unit 555 secures "3, OE, "*, *" and *O Information. d) Organi'ations 555 is a speciali'e unit of wor& at particular locations 28) What are the 0ser "#!#2 % !' in the !eports? "?CO3C?! Q0 '%?1* "?5( 4?@#(0 29) 53* 0' ! 41%':) =+% 3WI+I# sets your profile option values, multiple organi'ations and allows Oracle "pplication ObJect ?ibrary user e)its to detect that they have been called by an Oracle 3eports program. =+% 3WEOI# ensures that all the memory allocated for "O? user e)its have been freed up properly. =+% =?EOI%,"? are used to display fle) field information li&e prompt, value etc

=+% =?EO >? these user e)its allow you to use fle) fields in your reports =+% =O3("#78-33E+8H is used to print currency in various formats by using formula column

29) "(-'Q( store+ proce+$re parameters? or what are the two parameters that are man+atory for pl-s.l type conc$rrent program? *rocedure2function (E33N-= O-# 3E#8O%E O-# MMMMMMM.) E33N-= 05 -sed to write the error message to log or re/uest file. 3E#8O%E 05 *opulate log re/uest file with program submission details info. 2:) What is @al$e 'et? 55#he value set is a collection (or) container of values. 55When ever the value set associated with any report parameters. It provides list of values to the end user to accept one of the values as report parameter value. 55 If the list of values needed to be dynamic and ever changing and define a table based values set. 2:) What r the vali+ation types? 1) +one 55555555 validation is minimal. 4) Independent 555555input must e)ist on previously defined list of values 9) %ependent 555555input is chec&ed against a subset of values based on a prior value. 9) #able 55555 input is chec&ed against values in an application table :) pecial 555555values set uses a fle) field itself. ;) *air 555555 two fle) fields together specify a range of valid values. @) #ranslatable independent 55555 input must e)ist on previously defined list of values. translated values can be used. C) #ranslatable dependent 5555555 input is chec&ed against a subset of values based on a prior values. translated value can be used. 2<) 5orm +evelopment process? a) open template form b) ave as .fmb c) 8hange the form module name as form name. d) %elete the default bloc&s, window, and canvas e) 8reate a window. f) "ssign the window property class to window g) 8reate a canvas (subclass info) h) "ssign canvas property class to the canvas I) assign the window to the canvas and canvas to the window J) 8reate a data bloc& &) (odify the form level properties. (sub class item #e)t item) l) (odify the app7cusom pac&age. In the program unit. m) (odify the pre5form trigger (form level) n) (odify the module level properties ((console window, =irst navigation p) ave and compile the form. *lace the .fm) in the server directory. >) 3egister in the "O? #""(1C#%1O3 5O!2 #""(1C#%1O3 503C%1O3 #""(1C#%1O3 2 30 2=)Aow +o $ c$stomiBe the !eports?

a. Identify the hort name of the standard report in which module we have to customi'e $*+ , i) - want to c-stomi.e in the /! mod-le 'ath is
/''l to'0ar011.2.30re'orts04%0 .rd)

b. Open the .rdf file in 3eport builder and change the name of the module. c. Open the data module and modify the /uery (what is client re/uirements) assign the columns to the attrib-tes. d. !o to report wi'ard and select, what r the newly created columns. e. #hen 8ompile it. #hen u will get a .rep file in the specified module. If it is not in the specified directory then we have to put in the server directory. f. #hen 3egister in the "O? Conc$rrent eGec$ta&le. Conc$rrent program. g. go to system administrator'ec$rity !esponsi&ility re.$est h) "dd and assign a concurrent program to a re/uest group ,0) !egistering parametric report? "ny applications will have two parameters, 1) from5period 4) to5period a) !o to obJect navigator and create the parameters. 0ser parameters from?noD to?no ;+ata type char an+ wi+th ,0) b) Open the report layout and write the /uery(we have to reg the table in "O?) %elect em'no5ename5)rom g_em' where em'no between +)rom_no and to_no c) 8ompile and put the .3%* file in the server directory. +) 3egistering in "O?. Conc$rrent eGec$ta&le Conc$rrent program then go to R"#!#2 % !'I e) !o to #pplication vali+ation set. then go to H *1% 13%OI "fter entering the 6/#4$ %$T% (1) "nd T"7$N% (4) f) !o to "dministrations 'e.$rity responsi&ility !e.$est h) "dd and assign a concurrent program to a re/uest group ,1) %ell me some report names an+ their ta&le names in E(D #"D #!D an+ "O?
1) ra?c$stomer?trG?all c-stomer_tr*_id tr*_n-mber (invoice no5 debit memo no5 credit memo no& c-st_tr*_ty'e_id 4) ra?c$stomer?lines?all ;+etails of invoice) c-tomer_tr*_id ,) ar?payment?sch+$les?all chec8_id #his table stores all transactions e)cept adJustments and miscellaneous cash receipts. Oracle 3eceivables updates this table when activity occurs against an invoice, debit memo, chargebac&, credit memo, on account credit, or receipt. 4) ra?c$st?trG?types?all ;invoice types) c-st_tr*_ty'e_id

8) ra?&atches?all Natch7id
#his table stores information about each receipt batch that you create in Oracle 3eceivables. Each row includes information about a specific batch such as batch source, status, batch type, control count, and control amount

9) ra?receiva&le?application?all :) ra?a+J$stments?all

#his table stores information about your invoice adJustments. Each row includes general information about the adJustment you are ma&ing such as activity name, amount, accounting information, reason, and type of adJustment. Hou need one row for each adJustment you are ma&ing to an invoice.

I) ra?cash?receiots?all 8ash7receipt7id
#his table stores one record for each receipt that you enter. Oracle 3eceivables creates records concurrently in the "378" A73E8EI*#7AI #O3H7"??, "37*"H(E+#7 8AE%-?E 7"??, and "373E8EI,"N?E7"**?I8"#IO+ tables for invoice[related receipts. 1) ap7invoice7all invoice7amount, base7amount, payment7status7flag(Yy$ [fully paid Yn$Eunpaid Yp$ [partially paid) 4) ap7invoice7payments7all invoice7id, 9) ap7invoice7distibutions7"ll amount, base7amount, dist7code7combination7id, line7type7loo&up7code :) ap7payment7schdules payment7status7flag(R Y$$$$S) ;) ap7payment7dustributions7all @) ap7chec&s7all chec&7id, "*78AE8B 7"?? stores information about payments issued to suppliers or refunds received from suppliers. Hou need one row for each payment you issue to a supplier or refund received from a supplier. Hour Oracle *ayables application uses this information to record payments you ma&e to suppliers or refunds you receive from suppliers. C) ap7accounting7events7all I) ap7ban&7accounts7all "*7N"+B7"88O-+# 7"?? contains information about your ban& accounts. Hou need one row for each ban& account you define. Each ban& account must be affiliated with one ban& branch. When you initiate an automatic payment batch, enter a manual chec&, or create a >uic& payment, you can select a ban& account that you define in this table. K) ap7ban&7accounts7uses7all "*7N"+B7"88O-+#7- E 7"?? stores information for the internal and e)ternal ban& accounts you define in Oracle *ayables and Oracle
3eceivables applications.

1) po7vendors7all 4) po7vendors7sites7all 9) po7headers7all po7header7id :) po7lines7all po7line7id ;) po7line7locations7"ll @) po7distributions7all po7distribution7id,

1) El?co+e?com&inations
!?78O%E78O(NI+"#IO+ stores valid account combinations for each "ccounting =le)field structure within your Oracle !eneral ?edger application. "ssociated with each account are certain codes and flags, including whether the account is enabled, whether detail posting or detail budgeting is allowed, and others.

2) El?Je?&atches.
!?7TE7N"#8AE stores Journal entry batches.

,) El?Je?hea+ers

!?7TE7AE"%E3 stores Journal entries. #here is a one[to[many relationship between Journal entry batches and Journal entries. Each row in this table includes the associated batch I%, the Journal entry name and description, and other information about the Journal entry. #his table corresponds to the Tournals window of the Enter Tournals form. #"#- is $-$ for unposted, $*$ for posted. Other statuses indicate that an error condition was found. " complete list is below.

4) El?Je?lines.
!?7TE7?I+E stores the Journal entry lines that you enter in the Enter Tournals form. #here is a one[to[many relationship between Journal entries and Journal entry lines. Each row in this table stores the associated Journal entry header I%, the line number, the associated code combination I%, and the debits or credits associated with the Journal line. #"#- is $-$ for unposted or $*$ for posted

8) El?set of &oo/s
!?7 E# 7O=7NOOB stores information about the sets of boo&s you define in your Oracle !eneral ?edger application. Each row includes the set of boo&s name, description, functional currency, and other information. #his table corresponds to the et of Noo&s form.

9) El?perio+s
!?7*E3IO% stores information about the accounting periods you define using the "ccounting 8alendar form. Each row includes the start date and end date of the period, the period type, the fiscal year, the period number, and other information. #here is a one[to[many relationship between a row in the !?7*E3IO%7 E# table and rows in this table.

1) O" 3)* 61% 2 2O ! "O!%? #his report shows all the open5debit memo transactions, based on customer number and dates. 8olumns 05 type, customer7no, tr)7no, amt7due, remaining. *arameter 05 type, customer, from7date, to7date. 2) E 3 !#%13E "O'1%1@ "#K 51( 5O! 6#37 ! "O!%? Nasically this report generates a flat file of all the payments in order to send in to the ban&. ,) 0"*#% "O'1%1@ "#K CA C7' ! "O!%? #his report which updates the data into the ("*) account payables system from the plot file, the file which is sent by ban& 4) 0"*#% "O'1%1@ "#K O0% '%#3*13E CA C7'? #his report which shows the out standing chec&s 8) C0'%O2 ! "#K2 3% * %#1(' ! "O!%? Which shows each customer original amount, amount pay and due amount based on transaction type (boo&s, pens) %ransaction types in #! 8redit memo transaction types Invoice, debit memo, and charge bac& transaction types 8ommitment transaction types Q) AOW *O KO0 ! C%15K %A !!O!' 13 13% !5#C %#6( '? %epending on the naming convention used, errors appear in either alphabetical order or by error code number.

,1) Aow +o $ i+entity its name of report? 'ystem a+ministrator conc$rrent program +efine 'ystem a+ministrator conc$rrent program eGec$ta&le ,2) Who information>s? 1) 8reated by 4) 8reation date 9) ?ast 7updated by :) last7update7date ;) last7update7value ,,) 5( 4 51 (*'?

0se+ to capt$re the a++itional &$siness information.

*55 "dditional 8aptured in attribute prefi)ed columns +ot reported on standard reports

755 -ni/ue Info, (andatory egment prefi)ed Is reported on standard reports

#o provide e)pansion space on your form With -sed for entering and displaying &ey the help of WX. WX 3epresents information descriptive =le) field. =or e)ample Oracle !eneral uses a &ey =le) =?EO =I?E% 0 %E 83I*#I,E 0 3E!I! #E3 field called "ccounting =le) field to uni/uely identifies a general account.
=?EO =I?E% 0 BEH 0 3E!I! #E3

Oracle #pplications 7 K 5( 4 51 (*' 1) !? 05 "88O-+#I+! 4) "3 05 "?E #"O ?O8"#IO+, #E33I#O3H, 9) "* 05 N"+B %E#"I? , 8O # "??O8"#IO+, *EO*?E !3O-* Oracle #pplications * 'C!1"%1@ 5( 4 51 (*' ;"artial) 1) !? 05 daily rates 4) "3 05 credit history, information 9) *" 05 ban& branch, payment terms, site address, ,4) What are the re.$ests gro$ps? a) ingle re/uest0 5 this allows you to submit an individual re/uest. b) 3e/uest set 0 5 this allows you to submit a pre5defined set of re/uests. ,8) 'ys #+min 2o+$le? a) %efine 8ustom -sers, &) %efine ?ogin -sers, c) 3egister oracle %N users, +) %efine 8oncurrent *rograms, e) 3egister 8oncurrent E)ecutables, f) etting *rofile Option ,alues, g) %efine 3e/uest #ypes. ,9) #O(? a) 3egistering tables. &) 3egistering views c) 3egistering db se/uences +) 3egistering profile options e) 3egistering loo&ups and loo&up codes f) 3egistering forms g) 3egistering =orm and +on5=orm functions i)registering (enus and sub5menus. J) 3egistering %== and B==. /) ?ibraries ,:) What r the type 2o+els in the system parameters of the report? 1) Nit map 4) 8haracter mode ,<) .What is '!W "ac/age? (%ql !e'ort 9riter& #he 3eport builder Nuilt in pac&age &now as 3W *ac&age #his pac&age e)tends reports ,8ontrol report e)ecution, output message at runtime, Initiali'e layout fields, *erform %%? statements used to create or %roptemporary table, 8all -ser E)ist, to format width of the columns, to page brea& the column, to set the colors E)0 3W.%O7 >?, It$s li&e %%? command, we can create table, views , etc., 3W. E#7=IE?%7+-( 3W. E#7=I?E%78A"3 3W. E# =I?E% 7%"#E ,:) *ifference &etween 6in+ an+ (eGical parameters? 613* @#!1#6( : 55 are used to replace a single value in s/l, pl2s/l 55 bind variable may be used to replace e)pressions in select, where, group, order

by, having, connect by, start with cause of /ueries. 55 bind reference may not be referenced in =3O( clause (or) in place of reserved words or clauses. ( 41C#( ! 5 ! 3C : 55 you can use le)ical reference to replace the clauses appearing "=#E3 select, from, group by, having, connect by, start with. 55 you can$t ma&e le)ical reference in a pl2s/l statmetns. ,<) 2atriG !eport: imple, !roup above, +ested 'imple 2atriG !eport 0 : groups 1.8ross *roduct !roup 4. 3ow and 8olumn !roup 9. 8ell !roup :. 8ell column is the source of a cross product summary that becomes the cell content. 5rames0 1.3epeating frame for rows(down direction) 4.3epeating frame for columns("cross ) 9.(atri) obJect the intersection of the two repeating frames ,=) what is 5leG mo+e an+ Confine mo+e? Confine mo+e On0 child obJects cannot be moved outside their enclosing parent obJects. Off0 child obJects can be moved outside their enclosing parent obJects. 5leG mo+e: On0 parent borders ]stretch] when child obJects are moved against them. Off0 parent borders remain fi)ed when child obJects are moved against them. 40) What is "lace hol+er Col$mns? " placeholder is a column is an empty container at design time. #he placeholder can hold a value at run time has been calculated and placed in to It by pl2s/l code from anther obJect. Hou can set the value of a placeholder column is in a Nefore 3eport trigger. tore a #emporary value for future reference. EO. tore the current ma) salary as records are retrieved. 2,) What is 5orm$la Col$mn? " formula column performs a user5defined computation on another column(s) data, including placeholder columns. 24) What is '$mmary col$mns? " summary column performs a computation on another column\s data.-sing the 3eport Wi'ard or %ata Wi'ard, you can create the following summaries0 sum, average, count, minimum, ma)imum, F total. Hou can also create a summary column manually in the %ata (odel view, and use the *roperty *alette to create the following additional summaries0 first, last, standard deviation, variance. 80) What is c$rsor? " 8ursor is a pointer, which wor&s on active set, I.e. which points to only one row at a time in the conte)t area$s "8#I,E E#. " cursor is a construct of pl2s/l, used to process multiple rows using a pl2s/l bloc&. 2<) %ypes of c$rsors? 1) 1mplicit0 declared for all %(? and pl2s/l statements. Ny default it selects one row only. 4) Gplicit0 %eclared and named by the programmer. -se e)plicit cursor to individually process each row returned by a

(ultiple statements, is called "8#I,E E#. "llows the programmer to manually control e)plicit cursor in the *l2s/l bloc& a) +eclare0 create a named s/l area b) Open0 identify the active set. c) 5etch: load the current row in to variables. d) Close0 release the active set. 8-3 O3 "##3IN-#E a) Lis open0 evaluates to true if the cursor is open. b) Lnot fo$n+0 evaluates to true if the most recent fetch does not return a row c) Lfo$n+0 evaluates to true if the most recent fetch returns a row. d) Lrow co$nt0 evaluates to the total number of rows returned to far.
Example for cursor: 1) Declare Vno emp.empno%type; Vname emp.ename %type; Cursor emp cursor is !elect empno"ename From emp; #e$in Open cursor; For % in 1..1& loop Fetch emp cursor into 'no"'name; D(ms output.putline)to char)'no) ** +**'name); ,nd i-; , nd; .) #e$in Open emp cursor; /oop Fetch 0hen emp cursor % ro0count 11& or ,mp curor % not -ound; #dms output put line)to char)'no)** +** 'name); ,nd loop; Close emp cursor; ,nd;

C0!'O! 5O! (OO" ") cursor for loop is a short cut to process e)plicit cursors N) it has higher performance 8) cursor for loop re/uires only the declaration of the cursor, remaining things li&e opening, fetching and close are automatically ta&e by the cursor for loop
Example: 1) Declare Cursor emp cursor is !elect empno"ename From emp; #e$in For emp record in emp cursor loop D(ms output.putline)emp record.empno); D(ms output.putline)emp record.ename) ,nd loop

,nd;

Can we create a c$rsor witho$t +eclaring it?


Hes [ by using cursor for loop using sub/ueries. NE!I+ =O3 emp7record I+ ( E?E8# empno, ename =3O( emp) ?OO* 55 implicit open and implicit fetch occur I= emp7record.empno U CI9K #AE+ ... E+% ?OO*. 55 implicit close occurs E+%.

a) for $p+ate cla$se: 1) use e)plicit loc&ing to deny access for the duration of a transaction 4) loc& the rows before update or delete E) 0 select MM. =romMM. =or updateW of column refX Wno7waitX &) where c$rrent of cla$se? 1) use cursor to update or delete the current row Where current of ^P 2=) #ttri&$te +ata types? 1) Ftype 4) Frow type. ,0) Gception Aan+ilings? Is a mechanism provided by pl2s/l to detect runtime errors and process them with out halting the program abnormally 1) pre5defined 4) user5defined. "! )* 513 *: 1) cursor7already7open55555555attempted to open an already open cursor. 4) %up7val7on7inde) 55555555attempted to insert a duplicate values. 9) Invalid7cursor 55555555 illegal cursor operation occurred. :) Invalid7number 55555555 conversion of character string to number fails. ;) ?ogin7denied 555555555loging on to oracle with an invalid user name and password. @) program7error 55555555 pl2s/l has an internal problem. C) storage7error 55555555 pl2s/l ran out of memory or memory is corrupted. I) to7many7row 555555555single row select returned more than one row. K) value7error 55555555 arithmetic,conversion,truncation or si'e constraint error occurred. 1L) 'ero7devided 55555555 attempted to divided by 'ero. 0' !)* 513 *: %eclare 0 name the e)ception 3aise 0 e)plicitly raise the e)ception by using the raise statements 3eference0 e)ception handing section. %he !aise?#pplication? rror?"roce+$re: Hou can use this procedure to issue user5defined error messages from stored sub programs. Hou can report errors to your applications and avoid returning unhandled e)ceptions. Raise(Application()rror*error(num+er,message-,.true/0alse12

Error number between 54LLLL to 54LKKK pragma eGception?init? It tells the compiler to associate an e)ception with an oracle error. #o get an error message of a specific oracle error. E)0 pragma e)ception7init(e)ception name, oracle error number) Gample for Gceptions? 1) Chec/ the recor+ is eGist or not? %eclare E empF rowtype Negin e.empno 0U <empno. select G into e from emp where empno Ue.empno.
D(ms output.putline)+empno ** e.empno); ,2ception 3hen no data -ound then D(ms output.putline)e.empno **doest e2ist); ,nd; 2) User defined exceptions? De-ine p dept desc 4$'reddy De-ine p dept num(er 41.56 Declare , in'alid dept e2ception; #e$in 7pdate departments !et dept name48p dept desc 3here dept id 48p dept num(er; %- s9l% not -ound then :aise e in'alid departments; ,nd i-; Commit; ,2ception 3hen e in'alid departments then D(ms output.putline)+no such dept); ,nd;

82) what is ! 5 C$rsor? #o e)ecute a multi5row /uery, oracle opens an unnamed wor& area that stores processing information, to access the information, an e)plicit, which names the wor& area or, a cursor variable, which points to the wor& area. where as a cursor always refers to the same /uery wor& area, a cursor variable can refer to a different wor& areas, cursor variable area li&e Yc$ or Ypascal$ pointers, which hold the memory location(address) of some obJect instead of the obJect itself. o, declaring a cursor variable creates a pointers, not an obJect. ,2) Can $ +efine eGceptions twice in same &loc/? +o ,,) Can yo$ have two f$nctions with the same name in a pl-s.l &loc/? Hes ,4) Can yo$ have two store+ f$nctions with in the same name? Hes ,8) Can f$nction &e overloa+? Hes

,9) What is the maGim$m n$m&er of statements that can &e specifie+ in a trigger statement? One. ,2) 'tore+ proce+$re? tored procedure is a se/uence of statements that perform specific function. 8,) What is proce+$re? 5555 is a named pl2s/l bloc& to perform a specific tas&. 5555 " procedure may have %(? statements. 5555 It may or may not return a value. 5555 *rocedure can return more than one value. Gample for proce+$re 1) #o accept the year as a parameter and list emp belong to the year6 8reate or replace *rocedure empy(y number) is 8ursor emp7cursor is elect G from emp where to7char(hiredate,$yyyy$)U$y$. Emp7record empFrowtype. Negin =or emp7record in emp7cursor loop *rint (emp7record.empno). *rint (emp7record.ename). *rint (emp7record.sal). End loop. End. O$tp$t : var emp) number. Negin 0emp) 0U Y149:$. End. E)ec empy(0emp)). *rint empy. 84) What is f$nction? 5555 is a named pl2s/l bloc& to perform a specific tas&, is mainly used for calculation purpose. 5555 " function is called as part of an e)ception. 5555 Every function should return a value Gample for f$nction 8reate or replace =unction get7sal(p7id in emp.emp7noF type) 3eturn number Is v7sal emp.salFtype 0UL. Negin elect salary into v7salary =rom emp Where emp7no U p7id. 3eturn v7salary End get7sal. End. O$tp$t :

var g7sal number. E)ec 0g7sal 0U get7sal(KK). *rint g7salary.


=.Can f$nctions &e overloa+e+ ? Kes. 10.Can 2 f$nctions have same name M inp$t parameters &$t +iffer only &y ret$rn +atatype 3o.

88) What is the pac/age? 5555 !roup logically related pl2s/l types, items and subprograms. 1) pac&age specification 4) pac&age body
Advantages of a package: ;odularity ,asier Application Desi$n %n-ormation <idin$ O'erloadin$ You cannot overload:

1#wo subprograms if their formal parameters differ only in name or parameter mode. (datatype and their total number is same). 1#wo subprograms if their formal parameters differ only in datatype and the different datatypes are in the same family (number and decimal belong to the same family) 1#wo subprograms if their formal parameters differ only in subtype and the different subtypes are based on types in the same family (,"38A"3 and #3I+! are subtypes of ,"38A"34) 1#wo functions that differ only in return type, even if the types are in different families. 89) What is 5O!W#!* * C(#!#%1O3 in "ac/ages? *?2 >? allows for a special subprogram declaration called a forward declaration. It consists of the subprogram specification in the pac&age body terminated by a semicolon. Hou can use forward declarations to do the following0 1 %efine subprograms in logical or alphabetical order. 1 %efine mutually recursive subprograms.(both calling each other). 1 !roup subprograms in a pac&age Gample of forwar+ *eclaration: 83E"#E O3 3E*?"8E *"8B"!E NO%H forward7pac& I *3O8E%-3E calc7rating(. . .). 55 forward declaration *3O8E%-3E award7bonus(. . .) I 55 subprograms defined NE!I+ 55 in alphabetical order calc7rating(. . .). ... E+%. *3O8E%-3E calc7rating(. . .) I NE!I+ ... E+%. E+% forward7pac&.

89) What are triggers? 5555 triggers are similar to procedures, in that they are the named pl2s/l bloc&s with declarative, e)ecutable and e)ception5handling sections, how ever a procedure is e)ecuted e)plicitly from another bloc& via a procedure call, which can also pass arguments.

5555 " trigger is e)ecuted implicitly when ever a particular event tas& places. "nd is nothing but a event. 5555 #he triggering event is a %(? (insert, update, delete) operations on a data base table ))))) fires whenever a +ata event;s$ch as *2() or system event;s$ch as login or sh$t+own) occ$rs on a schema or +ata&ase %rigger timing : 1) before 4) after 9) instead of ( this is used for views) %riggering events 0 1) insert 4)update 9) delete %rigger type : 1) statement level 4) row level. 5iring se.$ence of +ata&ase triggers 1) before statement trigger 4) before row trigger 9) after row trigger :) after statement trigger G: 1) Create or replace trigger sec$re?emp Nefore Insert on emp Negin If (to7char(sysdate,$dy$) in(Ysat$,$sun$)) or #o7char(sysdate,$hh4:0mi$) +ot between $LI0LL$ and $1I0LL$) #hen raise7application7error(54L;LL,$u can insert in the office timings$) End if. End. G :) 2) write a program to all transitions with name smith? 8reate or replace #rigger trigger7name Nefore insert or update or delete On emp =or each row When (old.ename U$smith$ or +ew.ename U$smith$) Negin 3aise7application7error(54LLL9,$smith$). End. 8:) *ifference &etween triggers an+ proce+$res? %efined with create trigger %efined with create proce+$re #he data dictionary contains source code %ata dictionary contains source code in in the user7triggers. user7source Implicitly invo&ed E)plicitly invo&ed

8ommit, save point and rollbac& are not #hose are allowed allowed(#8?) 8<) (OC7'?
55 Is to reduce concurrency 1) share loc/ 555it allows the other users for only reading not to insert or update or delete. 4) eGcl$sive loc/ 555 only one user can have the privileges of insert or update and delete of particular obJect 555 others can only read. 9) $p+ate loc/ 5555multiple user can read, update delete (oc/ levels : 1) table level 4) table space 9) data base level.

8<) What is template? a) #he #E(*?"#E form is the re/uired starting point for all development of new
=orms. b) #he #E(*?"#E form includes platform[independent attachments of several ?ibraries. #""'CO! :) It contains pac&age and procedures that are re/uired of all forms to support the (E+,#OO?N"3 . #""'*#K"7 :) It contains pac&ages that control the oracle applications 8"?E+%E3 =E"#-3E . 53*'Q5 :) it contains pac&ages and procedures for (E "!E %I8#O+"3H, =?EO =IE?% , *3O=I?E "+% 8O+8-33E+# *3O8E I+!. C0'%O2 :) it allows e)tension of oracle applications forms with out modification of oracle application code, you can use the custom library for customi'ation such as Boom ( such as moving to another form and /uerying up specific records) 8=) What are a+)hoc reports? "ns.0 "d5hoc 3eport is made to meet one5time reporting needs. 8oncerned with or formed for a particular purpose. =or e)ample, ad hoc ta) codes or an ad hoc database /uery

90) What is responsi&ility? Is collection of menus, re/uest security groups and data groups 2en$s0 collection of forms is nothing but menus !e.$est sec$rity gro$ps0 collection of programs. *ata gro$ps0 is a group of modules to be made accessible by the user through 3esponsibility 'ystem a+min sec$rity +efine 'ec$rity $ser +efine 91) What are different execution methods of executabls?

FlexRpt The execution file is wrnitten using the FlexReport AP ! Flex"#l The execution file is written using the Flex"#l AP ! $ost The execution file is a host script! %racle Reports The execution file is an %racle Reports file! P&'"(& "tored Procedure The execution file is a stored procedure! "(&)&oader The execution file is a "(& script! "(&)Plus The execution file is a "(&)Plus script! "(&)Report The execution file is a "(&)Report script! "pawned The execution file is a * or Pro)* progra+! cution file is a progra+ written to run as a subroutine of the concurrent +anager! ,e reco++end against defining new i++ediate concurrent progra+s, and suggest you use either a P&'"(& "tored Procedure or a "pawned * Progra+ instead!

Composite *atatypes 0
= >/?!Q/ @A#/,! = >/?!Q/ :,CO:D! 5 Aested @A#/, 5 VA::AB

What is the se.$ence of f$nctions N gro$p &yDhavingDor+er&y in a select statements ?


!electC.. Droup (yC <a'in$C Order(y..

*ifference &etween 0ser an+ '$per 0ser?


7ser E lo$in user or -ront end user !uper user E it has -ull access o- particular module
0 comments

%ntroduction to !tructured Query /an$ua$e


#his page is a introductory tutorial of the tructured >uery ?anguage (also &nown as >?) and is a pioneering effort on the World Wide Web, as this is the first comprehensive >? tutorial available on the Internet. >? allows users to access data in relational database management systems, such as Oracle, ybase, Informi), (icrosoft >? erver, "ccess, and others, by allowing users to describe the data the user wishes to see. >? also allows users to define the data in a database, and manipulate that data. #his page will describe how to use >?, and give e)amples. #he >? used in this document is ]"+ I], or standard >?, and no >? features of specific database management systems will be discussed until the ]+onstandard >?] section. It is recommended that you print this page, so that you can easily refer bac& to previous e)amples. "lso, you may be interested in Joining the new >? 8lub on Hahoo_, where you can read or enter messages in a >? forum. Nasics of the E?E8# tatement In a relational database, data is stored in tables. "n e)ample table would relate ocial ecurity +umber, +ame, and "ddress0 Employee"ddress#able + =irst+ame ?ast+ame "ddress 8ity tate ;14@IC:;I Toe mith I9 =irst treet Aoward Ohio C;I:4LL14 (ary cott I:4 ,ine "ve. ?osantiville Ohio 1L44;:IK@ am Tones 99 Elm t. *aris +ew Hor& IC@;14;@9 arah "c&erman ::L -. . 11L -pton (ichigan +ow, let\s say you want to see the address of each employee. -se the E?E8# statement, li&e so0 E?E8# =irst+ame, ?ast+ame, "ddress, 8ity, tate =3O( Employee"ddress#able. #he following is the results of your /uery of the database0 =irst +ame ?ast +ame "ddress 8ity tate Toe mith I9 =irst treet Aoward Ohio (ary cott I:4 ,ine "ve. ?osantiville Ohio am Tones 99 Elm t. *aris +ew Hor& arah "c&erman ::L -. . 11L -pton (ichigan #o e)plain what you Just did, you as&ed for the all of data in the Employee"ddress#able, and specifically,

you as&ed for the columns called =irst+ame, ?ast+ame, "ddress, 8ity, and tate. +ote that column names and table names do not have spaces...they must be typed as one word. and that the statement ends with a semicolon (.). #he general form for a E?E8# statement, retrieving all of the rows in the table is0 E?E8# 8olumn+ame, 8olumn+ame, ... =3O( #able+ame. #o get all columns of a table without typing all column names, use0 E?E8# G =3O( #able+ame. Each database management system (%N( ) and database software has different methods for logging in to the database and entering >? commands. see the local computer ]guru] to help you get onto the system, so that you can use >?. 8onditional election #o further discuss the E?E8# statement, let\s loo& at a new e)ample table (for hypothetical purposes only)0 Employee tatistics#able EmployeeI%+o alary Nenefits *osition L1L C;LLL 1;LLL (anager 1L; @;LLL 1;LLL (anager 1;4 @LLLL 1;LLL (anager 41; @LLLL 14;LL (anager 4:: ;LLLL 14LLL taff 9LL :;LLL 1LLLL taff 99; :LLLL 1LLLL taff :LL 94LLL C;LL Entry5?evel ::1 4ILLL C;LL Entry5?evel 3elational Operators #here are si) 3elational Operators in >?, and after introducing them, we\ll see how they\re used0 U E/ual ^ or _U (see manual) +ot E/ual ^ ?ess #han P !reater #han ^U ?ess #han or E/ual #o PU !reater #han or E/ual #o #he WAE3E clause is used to specify that only certain rows of the table are displayed, based on the criteria described in that WAE3E clause. It is most easily understood by loo&ing at a couple of e)amples. If you wanted to see the E(*?OHEEI%+O\s of those ma&ing at or over `;L,LLL, use the following0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E "?"3H PU ;LLLL. +otice that the PU (greater than or e/ual to) sign is used, as we wanted to see those who made greater than `;L,LLL, or e/ual to `;L,LLL, listed together. #his displays0 E(*?OHEEI%+O 555555555555 L1L 1L;

1;4 41; 4:: #he WAE3E description, "?"3H PU ;LLLL, is &nown as a condition (an operation which evaluates to #rue or =alse). #he same can be done for te)t columns0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E *O I#IO+ U \(anager\. #his displays the I% +umbers of all (anagers. !enerally, with te)t columns, stic& to e/ual to or not e/ual to, and ma&e sure that any te)t that appears in the statement is surrounded by single /uotes (\). +ote0 *osition is now an illegal identifier because it is now an unused, but reserved, &eyword in the >?5K4 standard. (ore 8omple) 8onditions0 8ompound 8onditions 2 ?ogical Operators #he "+% operator Joins two or more conditions, and displays a row only if that row\s data satisfies "?? conditions listed (i.e. all conditions hold true). =or e)ample, to display all staff ma&ing over `:L,LLL, use0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E "?"3H P :LLLL "+% *O I#IO+ U \ taff\. #he O3 operator Joins two or more conditions, but returns a row if "+H of the conditions listed hold true. #o see all those who ma&e less than `:L,LLL or have less than `1L,LLL in benefits, listed together, use the following /uery0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E "?"3H ^ :LLLL O3 NE+E=I# ^ 1LLLL. "+% < O3 can be combined, for e)ample0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E *O I#IO+ U \(anager\ "+% "?"3H P @LLLL O3 NE+E=I# P 14LLL. =irst, >? finds the rows where the salary is greater than `@L,LLL and the position column is e/ual to (anager, then ta&ing this new list of rows, >? then sees if any of these rows satisfies the previous "+% condition or the condition that the Nenefits column is greater than `14,LLL. ubse/uently, >? only displays this second new list of rows, &eeping in mind that anyone with Nenefits over `14,LLL will be included as the O3 operator includes a row if either resulting condition is #rue. "lso note that the "+% operation is done first.#o generali'e this process, >? performs the "+% operation(s) to determine the rows where the "+% operation(s) hold true (remember0 all of the conditions are true), then these results are used to compare with the O3 conditions, and only display those remaining rows where any of the conditions Joined by the O3 operator hold true (where a condition or result from an "+% is paired with another condition or "+% result to use to evaluate the O3, which evaluates to true if either value is true). (athematically, >? evaluates all of the conditions, then evaluates the "+% ]pairs], and then evaluates the O3\s (where both operators evaluate left to right). #o loo& at an e)ample, for a given row for which the %N( is evaluating the >? statement Where clause to determine whether to include the row in the /uery result (the whole Where clause evaluates to #rue), the %N( has evaluated all of the conditions, and is ready to do the logical comparisons on this result0 #rue "+% =alse O3 #rue "+% #rue O3 =alse "+% =alse =irst simplify the "+% pairs0 =alse O3 #rue O3 =alse +ow do the O3\s, left to right0 #rue O3 =alse

#rue #he result is #rue, and the row passes the /uery conditions. Ne sure to see the ne)t section on +O#\s, and the order of logical operations. I hope that this section has helped you understand "+%\s or O3\s, as it\s a difficult subJect to e)plain briefly. #o perform O3\s before "+%\s, li&e if you wanted to see a list of employees ma&ing a large salary (`;L,LLL) or have a large benefit pac&age (`1L,LLL), and that happen to be a manager, use parentheses0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E *O I#IO+ U \(anager\ "+% ( "?"3H P ;LLLL O3 NE+E=I# P 1LLLL). I+ < NE#WEE+ "n easier method of using compound conditions uses I+ or NE#WEE+. =or e)ample, if you wanted to list all managers and staff0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E *O I#IO+ I+ (\(anager\, \ taff\). or to list those ma&ing greater than or e/ual to `9L,LLL, but less than or e/ual to `;L,LLL, use0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E "?"3H NE#WEE+ 9LLLL "+% ;LLLL. #o list everyone not in this range, try0 @ E?E8# E(*?OHEEI%+O =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E "?"3H +O# NE#WEE+ 9LLLL "+% ;LLLL. imilarly, +O# I+ lists all rows e)cluded from the I+ list. "dditionally, +O#\s can be thrown in with "+%\s < O3\s, e)cept that +O# is a unary operator (evaluates one condition, reversing its value, whereas, "+%\s < O3\s evaluate two conditions), and that all +O#\s are performed before any "+%\s or O3\s. >? Order of ?ogical Operations (each operates from left to right) 1. +O# 4. "+% 9. O3 -sing ?IBE ?oo& at the Employee tatistics#able, and say you wanted to see all people whose last names started with ] ]. try0 E?E8# E(*?OHEEI%+O =3O( E(*?OHEE"%%3E #"N?E WAE3E ?" #+"(E ?IBE \ F\. #he percent sign (F) is used to represent any possible character (number, letter, or punctuation) or set of characters that might appear after the ] ]. #o find those people with ?ast+ame\s ending in ] ], use \F \, or if you wanted the ] ] in the middle of the word, try \F F\. #he \F\ can be used for any characters in the same position relative to the given characters. +O# ?IBE displays rows not fitting the given description. Other possibilities of using ?IBE, or any of these discussed conditionals, are available, though it depends on what %N( you are using. as usual, consult a manual or your system manager or administrator for the available features on your system, or Just to ma&e sure that what you are trying to do is available and allowed. #his

disclaimer holds for the features of >? that will be discussed below. #his section is Just to give you an idea of the possibilities of /ueries that can be written in >?. Toins In this section, we will only discuss inner Joins, and e/uiJoins, as in general, they are the most useful. =or more information, try the >? lin&s at the bottom of the page. !ood database design suggests that each table lists data only about a single entity, and detailed information can be obtained in a relational database, by using additional tables, and by using a Join. =irst, ta&e a loo& at these e)ample tables0 "nti/ueOwners OwnerI% Owner?ast+ame Owner=irst+ame C L1 Tones Nill L4 mith Nob 1; ?awson *atricia 41 "&ins Tane ;L =owler am Orders OwnerI% Item%esired L4 #able L4 %es& 41 8hair 1; (irror "nti/ues ellerI% NuyerI% Item L1 ;L Ned L4 1; #able 1; L4 8hair 41 ;L (irror ;L L1 %es& L1 41 8abinet L4 41 8offee #able 1; ;L 8hair L1 1; Tewelry No) L4 41 *ottery 41 L4 Noo&case ;L L1 *lant tand Beys =irst, let\s discuss the concept of &eys. " primary &ey is a column or set of columns that uni/uely identifies the rest of the data in any given row. =or e)ample, in the "nti/ueOwners table, the OwnerI% column uni/uely identifies that row. #his means two things0 no two rows can have the same OwnerI%, and, even if two owners I have the same first and last names, the OwnerI% column ensures that the two owners will not be confused with

each other, because the uni/ue OwnerI% column will be used throughout the database to trac& the owners, rather than the names. " foreign &ey is a column in a table where that column is a primary &ey of another table, which means that any data in a foreign &ey column must have corresponding data in the other table where that column is the primary &ey. In %N( 5spea&, this correspondence is &nown as referential integrity. =or e)ample, in the "nti/ues table, both the NuyerI% and ellerI% are foreign &eys to the primary &ey of the "nti/ueOwners table (OwnerI%. for purposes of argument, one has to be an "nti/ue Owner before one can buy or sell any items), as, in both tables, the I% rows are used to identify the owners or buyers and sellers, and that the OwnerI% is the primary &ey of the "nti/ueOwners table. In other words, all of this ]I%] data is used to refer to the owners, buyers, or sellers of anti/ues, themselves, without having to use the actual names. *erforming a Toin #he purpose of these &eys is so that data can be related across tables, without having to repeat data in every table55this is the power of relational databases. =or e)ample, you can find the names of those who bought a chair without having to list the full name of the buyer in the "nti/ues table...you can get the name by relating those who bought a chair with the names in the "nti/ueOwners table through the use of the OwnerI%, which relates the data in the two tables. #o find the names of those who bought a chair, use the following /uery0 E?E8# OW+E3?" #+"(E, OW+E3=I3 #+"(E =3O( "+#I>-EOW+E3 , "+#I>-E WAE3E N-HE3I% U OW+E3I% "+% I#E( U \8hair\. +ote the following about this /uery...notice that both tables involved in the relation are listed in the =3O( clause of the statement. In the WAE3E clause, first notice that the I#E( U \8hair\ part restricts the listing to those who have bought (and in this e)ample, thereby own) a chair. econdly, notice how the I% columns are related from one table to the ne)t by use of the N-HE3I% U OW+E3I% clause. Only where I%\s match across tables and the item purchased is a chair (because of the "+%), will the names from the "nti/ueOwners table be listed. Necause the Joining condition used an e/ual sign, this Join is called an e/uiJoin. #he result of this /uery is two names0 mith, Nob < =owler, am. %ot notation refers to prefi)ing the table names to column names, to avoid ambiguity, as follows0 E?E8# "+#I>-EOW+E3 .OW+E3?" #+"(E, "+#I>-EOW+E3 .OW+E3=I3 #+"(E =3O( "+#I>-EOW+E3 , "+#I>-E WAE3E "+#I>-E .N-HE3I% U "+#I>-EOW+E3 .OW+E3I% "+% "+#I>-E .I#E( U \8hair\. "s the column names are different in each table, however, this wasn\t necessary. %I #I+8# and Eliminating %uplicates ?et\s say that you want to list the I% and names of only those people who have sold an anti/ue. Obviously, you want a list where each seller is only listed once55you don\t want to &now how many anti/ues a person sold, Just the fact that this person sold one (for counts, see the "ggregate =unction section below). #his means that you will need to tell >? to eliminate duplicate sales rows, and Just list each person only once. #o do this, use the %I #I+8# &eyword. K =irst, we will need an e/uiJoin to the "nti/ueOwners table to get the detail data of the person\s ?ast+ame and =irst+ame. Aowever, &eep in mind that since the ellerI% column in the "nti/ues table is a foreign &ey to the

"nti/ueOwners table, a seller will only be listed if there is a row in the "nti/ueOwners table listing the I% and names. We also want to eliminate multiple occurrences of the ellerI% in our listing, so we use %I #I+8# on the column where the repeats may occur (however, it is generally not necessary to strictly put the %istinct in front of the column name). #o throw in one more twist, we will also want the list alphabeti'ed by ?ast+ame, then by =irst+ame (on a ?ast+ame tie). #hus, we will use the O3%E3 NH clause0 E?E8# %I #I+8# E??E3I%, OW+E3?" #+"(E, OW+E3=I3 #+"(E =3O( "+#I>-E , "+#I>-EOW+E3 WAE3E E??E3I% U OW+E3I% O3%E3 NH OW+E3?" #+"(E, OW+E3=I3 #+"(E. In this e)ample, since everyone has sold an item, we will get a listing of all of the owners, in alphabetical order by last name. =or future reference (and in case anyone as&s), this type of Join is considered to be in the category of inner Joins. "liases < In2 ub/ueries In this section, we will tal& about "liases, In and the use of sub/ueries, and how these can be used in a 95 table e)ample. =irst, loo& at this /uery which prints the last name of those owners who have placed an order and what the order is, only listing those orders which can be filled (that is, there is a buyer who owns that ordered item)0 E?E8# OW+.OW+E3?" #+"(E ?ast +ame, O3%.I#E(%E I3E% Item Ordered =3O( O3%E3 O3%, "+#I>-EOW+E3 OW+ WAE3E O3%.OW+E3I% U OW+.OW+E3I% "+% O3%.I#E(%E I3E% I+ ( E?E8# I#E( =3O( "+#I>-E ). #his gives0 ?ast +ame Item Ordered 555555555 555555555555 mith #able mith %es& "&ins 8hair ?awson (irror #here are several things to note about this /uery0 1. =irst, the ]?ast +ame] and ]Item Ordered] in the elect lines gives the headers on the report. 4. #he OW+ < O3% are aliases. these are new names for the two tables listed in the =3O( clause that are used as prefi)es for all dot notations of column names in the /uery (see above). #his eliminates ambiguity, especially in the e/uiJoin WAE3E clause where both tables have the column named OwnerI%, and the dot notation tells >? that we are tal&ing about two different OwnerI%\s from the 1L two different tables. 9. +ote that the Orders table is listed first in the =3O( clause. this ma&es sure listing is done off of that table, and the "nti/ueOwners table is only used for the detail information (?ast +ame). :. (ost importantly, the "+% in the WAE3E clause forces the In ub/uery to be invo&ed (]U "+H] or

]U O(E] are two e/uivalent uses of I+). What this does is, the sub/uery is performed, returning all of the Items owned from the "nti/ues table, as there is no WAE3E clause. #hen, for a row from the Orders table to be listed, the Item%esired must be in that returned list of Items owned from the "nti/ues table, thus listing an item only if the order can be filled from another owner. Hou can thin& of it this way0 the sub/uery returns a set of Items from which each Item%esired in the Orders table is compared. the In condition is true only if the Item%esired is in that returned set from the "nti/ues table. ;. "lso notice, that in this case, that there happened to be an anti/ue available for each one desired...obviously, that won\t always be the case. In addition, notice that when the I+, ]U "+H], or ]U O(E] is used, that these &eywords refer to any possible row matches, not column matches...that is, you cannot put multiple columns in the sub/uery elect clause, in an attempt to match the column in the outer Where clause to one of multiple possible column values in the sub/uery. only one column can be listed in the sub/uery, and the possible match comes from multiple row values in that one column, not vice5versa. Whew_ #hat\s enough on the topic of comple) E?E8# /ueries for now. +ow on to other >? statements. (iscellaneous >? tatements "ggregate =unctions I will discuss five important aggregate functions0 -(, ",!, ("O, (I+, and 8O-+#. #hey are called aggregate functions because they summari'e the results of a /uery, rather than listing all of the rows. -( () gives the total of all the rows, satisfying any conditions, of the given column, where the given column is numeric. ",! () gives the average of the given column. ("O () gives the largest figure in the given column. (I+ () gives the smallest figure in the given column. 8O-+#(G) gives the number of rows satisfying the conditions. ?oo&ing at the tables at the top of the document, let\s loo& at three e)amples0 E?E8# -(( "?"3H), ",!( "?"3H) =3O( E(*?OHEE #"#I #I8 #"N?E. #his /uery shows the total of all salaries in the table, and the average salary of all of the entries in the table. E?E8# (I+(NE+E=I# ) =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E *O I#IO+ U \(anager\. #his /uery gives the smallest figure of the Nenefits column, of the employees who are (anagers, which is 14;LL. E?E8# 8O-+#(G) 11 =3O( E(*?OHEE #"#I #I8 #"N?E WAE3E *O I#IO+ U \ taff\. #his /uery tells you how many employees have taff status (9). ,iews In >?, you might (chec& your %N") have access to create views for yourself. What a view does is to allow you to assign the results of a /uery to a new, personal table, that you can use in other /ueries, where this new table is given the view name in your =3O( clause. When you access a view, the /uery that is defined in your view creation statement is performed (generally), and the results of that /uery loo& Just li&e another table in the /uery that you wrote invo&ing the view. =or e)ample, to create a view0 83E"#E ,IEW "+#,IEW " E?E8# I#E(%E I3E% =3O( O3%E3 . +ow, write a /uery using this view as a table, where the table is Just a listing of all Items %esired from the Orders table0 E?E8# E??E3I%

=3O( "+#I>-E , "+#,IEW WAE3E I#E(%E I3E% U I#E(. #his /uery shows all ellerI%\s from the "nti/ues table where the Item in that table happens to appear in the "ntview view, which is Just all of the Items %esired in the Orders table. #he listing is generated by going through the "nti/ue Items one5by5one until there\s a match with the "ntview view. ,iews can be used to restrict database access, as well as, in this case, simplify a comple) /uery. 8reating +ew #ables "ll tables within a database must be created at some point in time...let\s see how we would create the Orders table0 83E"#E #"N?E O3%E3 (OW+E3I% I+#E!E3 +O# +-??, I#E(%E I3E% 8A"3(:L) +O# +-??). #his statement gives the table name and tells the %N( about each column in the table. *lease note that this statement uses generic data types, and that the data types might be different, depending on what %N( you are using. "s usual, chec& local listings. ome common generic data types are0 8har()) 5 " column of characters, where ) is a number designating the ma)imum number of characters allowed (ma)imum length) in the column. Integer 5 " column of whole numbers, positive or negative. %ecimal(), y) 5 " column of decimal numbers, where ) is the ma)imum length in digits of the decimal numbers in this column, and y is the ma)imum number of digits allowed after the decimal point. #he ma)imum (:,4) number would be KK.KK. %ate 5 " date column in a %N( 5specific format. ?ogical 5 " column that can hold only two values0 #3-E or ="? E. 14 One other note, the +O# +-?? means that the column must have a value in each row. If +-?? was used, that column may be left empty in a given row. "ltering #ables ?et\s add a column to the "nti/ues table to allow the entry of the price of a given Item (*arentheses optional)0 "?#E3 #"N?E "+#I>-E "%% (*3I8E %E8I("?(I,4) +-??). #he data for this new column can be updated or inserted as shown later. "dding %ata #o insert rows into a table, do the following0 I+ E3# I+#O "+#I>-E ,"?-E (41, L1, \Ottoman\, 4LL.LL). #his inserts the data into the table, as a new row, column5by5column, in the pre5defined order. Instead, let\s change the order and leave *rice blan&0 I+ E3# I+#O "+#I>-E (N-HE3I%, E??E3I%, I#E() ,"?-E (L1, 41, \Ottoman\). %eleting %ata ?et\s delete this new row bac& out of the database0 %E?E#E =3O( "+#I>-E WAE3E I#E( U \Ottoman\. Nut if there is another row that contains \Ottoman\, that row will be deleted also. ?et\s delete all rows (one, in this case) that contain the specific data we added before0 %E?E#E =3O( "+#I>-E WAE3E I#E( U \Ottoman\ "+% N-HE3I% U L1 "+% E??E3I% U 41.

-pdating %ata ?et\s update a *rice into a row that doesn\t have a price listed yet0 -*%"#E "+#I>-E E# *3I8E U ;LL.LL WAE3E I#E( U \8hair\. #his sets all 8hair\s *rices to ;LL.LL. "s shown above, more WAE3E conditionals, using "+%, must be used to limit the updating to more specific rows. "lso, additional columns may be set by separating e/ual statements with commas. (iscellaneous #opics Inde)es 19 Inde)es allow a %N( to access data /uic&er (please note0 this feature is nonstandard2not available on all systems). #he system creates this internal data structure (the inde)) which causes selection of rows, when the selection is based on inde)ed columns, to occur faster. #his inde) tells the %N( where a certain row is in the table given an inde)ed5column value, much li&e a boo& inde) tells you what page a given word appears. ?et\s create an inde) for the OwnerI% in the "nti/ueOwners table0 83E"#E I+%EO OI%7I%O O+ "+#I>-EOW+E3 (OW+E3I%). +ow on the names0 83E"#E I+%EO +"(E7I%O O+ "+#I>-EOW+E3 (OW+E3?" #+"(E, OW+E3=I3 #+"(E). #o get rid of an inde), drop it0 %3O* I+%EO OI%7I%O. Ny the way, you can also ]drop] a table, as well (careful_55that means that your table is deleted). In the second e)ample, the inde) is &ept on the two columns, aggregated together55strange behavior might occur in this situation...chec& the manual before performing such an operation. ome %N( \s do not enforce primary &eys. in other words, the uni/ueness of a column is not enforced automatically. What that means is, if, for e)ample, I tried to insert another row into the "nti/ueOwners table with an OwnerI% of L4, some systems will allow me to do that, even though we do not, as that column is supposed to be uni/ue to that table (every row value is supposed to be different). One way to get around that is to create a uni/ue inde) on the column that we want to be a primary &ey, to force the system to enforce prohibition of duplicates0 83E"#E -+I>-E I+%EO OI%7I%O O+ "+#I>-EOW+E3 (OW+E3I%). !3O-* NH < A",I+! One special use of !3O-* NH is to associate an aggregate function (especially 8O-+#. counting the number of rows in each group) with groups of rows. =irst, assume that the "nti/ues table has the *rice column, and each row has a value for that column. We want to see the price of the most e)pensive item bought by each owner. We have to tell >? to group each owner\s purchases, and tell us the ma)imum purchase price0 E?E8# N-HE3I%, ("O(*3I8E) =3O( "+#I>-E !3O-* NH N-HE3I%. +ow, say we only want to see the ma)imum purchase price if the purchase is over `1LLL, so we use the A",I+! clause0 E?E8# N-HE3I%, ("O(*3I8E) =3O( "+#I>-E !3O-* NH N-HE3I% A",I+! *3I8E P 1LLL. (ore ub/ueries

1: "nother common usage of sub/ueries involves the use of operators to allow a Where condition to include the elect output of a sub/uery. =irst, list the buyers who purchased an e)pensive item (the *rice of the item is `1LL greater than the average price of all items purchased)0 E?E8# N-HE3I% =3O( "+#I>-E WAE3E *3I8E P ( E?E8# ",!(*3I8E) V 1LL =3O( "+#I>-E ). #he sub/uery calculates the average *rice, plus `1LL, and using that figure, an OwnerI% is printed for every item costing over that figure. One could use %I #I+8# N-HE3I%, to eliminate duplicates. ?ist the ?ast +ames of those in the "nti/ueOwners table, O+?H if they have bought an item0 E?E8# OW+E3?" #+"(E =3O( "+#I>-EOW+E3 WAE3E OW+E3I% I+ ( E?E8# %I #I+8# N-HE3I% =3O( "+#I>-E ). #he sub/uery returns a list of buyers, and the ?ast +ame is printed for an "nti/ue Owner if and only if the Owner\s I% appears in the sub/uery list (sometimes called a candidate list). +ote0 on some %N( \s, e/uals can be used instead of I+, but for clarity\s sa&e, since a set is returned from the sub/uery, I+ is the better choice. =or an -pdate e)ample, we &now that the gentleman who bought the boo&case has the wrong =irst +ame in the database...it should be Tohn0 -*%"#E "+#I>-EOW+E3 E# OW+E3=I3 #+"(E U \Tohn\ WAE3E OW+E3I% U ( E?E8# N-HE3I% =3O( "+#I>-E WAE3E I#E( U \Noo&case\). =irst, the sub/uery finds the NuyerI% for the person(s) who bought the Noo&case, then the outer /uery updates his =irst +ame. 3emember this rule about sub/ueries0 when you have a sub/uery as part of a WAE3E condition, the elect clause in the sub/uery must have columns that match in number and type to those in the Where clause of the outer /uery. In other words, if you have ] WAE3E 8olumn+ame U ( E?E8#...).], the elect must have only one column in it, to match the 8olumn+ame in the outer Where clause, and they must match in type (both being integers, both being character strings, etc.). EOI # < "?? 1; EOI # uses a sub/uery as a condition, where the condition is #rue if the sub/uery returns any rows, and =alse if the sub/uery does not return any rows. this is a nonintuitive feature with few uni/ue uses. Aowever, if a prospective customer wanted to see the list of Owners only if the shop dealt in 8hairs, try0

E?E8# OW+E3=I3 #+"(E, OW+E3?" #+"(E =3O( "+#I>-EOW+E3 WAE3E EOI # ( E?E8# G =3O( "+#I>-E WAE3E I#E( U \8hair\). If there are any 8hairs in the "nti/ues column, the sub/uery would return a row or rows, ma&ing the EOI # clause true, causing >? to list the "nti/ue Owners. If there had been no 8hairs, no rows would have been returned by the outside /uery. "?? is another unusual feature, as "?? /ueries can usually be done with different, and possibly simpler methods. let\s ta&e a loo& at an e)ample /uery0 E?E8# N-HE3I%, I#E( =3O( "+#I>-E WAE3E *3I8E PU "?? ( E?E8# *3I8E =3O( "+#I>-E ). #his will return the largest priced item (or more than one item if there is a tie), and its buyer. #he sub/uery returns a list of all *rices in the "nti/ues table, and the outer /uery goes through each row of the "nti/ues table, and if its *rice is greater than or e/ual to every (or "??) *rices in the list, it is listed, giving the highest priced Item. #he reason ]U] must be used is that the highest priced item will be e/ual to the highest price on the list, because this Item is in the *rice list. -+IO+ < Outer Toins (briefly e)plained) #here are occasions where you might want to see the results of multiple /ueries together, combining their output. use -+IO+. #o merge the output of the following two /ueries, displaying the I%\s of all Nuyers, plus all those who have an Order placed0 E?E8# N-HE3I% =3O( "+#I>-E -+IO+ E?E8# OW+E3I% =3O( O3%E3 . +otice that >? re/uires that the elect list (of columns) must match, column5by5column, in data type. In this case NuyerI% and OwnerI% are of the same data type (integer). "lso notice that >? does automatic duplicate elimination when using -+IO+ (as if they were two ]sets]). in single /ueries, you have to use %I #I+8#. #he outer Join is used when a Join /uery is ]united] with the rows not included in the Join, and are especially useful if constant te)t ]flags] are included. =irst, loo& at the /uery0 1@ E?E8# OW+E3I%, \is in both Orders < "nti/ues\ =3O( O3%E3 , "+#I>-E WAE3E OW+E3I% U N-HE3I% -+IO+ E?E8# N-HE3I%, \is in "nti/ues only\ =3O( "+#I>-E

WAE3E N-HE3I% +O# I+ ( E?E8# OW+E3I% =3O( O3%E3 ). #he first /uery does a Join to list any owners who are in both tables, and putting a tag line after the I% repeating the /uote. #he -+IO+ merges this list with the ne)t list. #he second list is generated by first listing those I%\s not in the Orders table, thus generating a list of I%\s e)cluded from the Join /uery. #hen, each row in the "nti/ues table is scanned, and if the NuyerI% is not in this e)clusion list, it is listed with its /uoted tag. #here might be an easier way to ma&e this list, but it\s difficult to generate the informational /uoted strings of te)t. #his concept is useful in situations where a primary &ey is related to a foreign &ey, but the foreign &ey value for some primary &eys is +-??. =or e)ample, in one table, the primary &ey is a salesperson, and in another table is customers, with their salesperson listed in the same row. Aowever, if a salesperson has no customers, that person\s name won\t appear in the customer table. #he outer Join is used if the listing of all salespersons is to be printed, listed with their customers, whether the salesperson has a customer or not55that is, no customer is printed (a logical +-?? value) if the salesperson has no customers, but is in the salespersons table. Otherwise, the salesperson will be listed with each customer. "nother important related point about +ulls having to do with Joins0 the order of tables listed in the =rom clause is very important. #he rule states that >? ]adds] the second table to the first. the first table listed has any rows where there is a null on the Join column displayed. if the second table has a row with a null on the Join column, that row from the table listed second does not get Joined, and thus included with the first table\s row data. #his is another occasion (should you wish that data included in the result) where an outer Join is commonly used. #he concept of nulls is important, and it may be worth your time to investigate them further. E+O-!A >-E3IE ___ you say6...now on to something completely different... Embedded >?55an ugly e)ample (do not write a program li&e this...for purposes of argument O+?H) 2G 5#o get right to it, here is an e)ample program that uses Embedded >?. Embedded >? allows programmers to connect to a database and include >? code right in the program, so that their programs can use, manipulate, and process data from a database. 5#his e)ample 8 *rogram (using Embedded >?) will print a report. 5#his program will have to be precompiled for the >? statements, before regular compilation. 5#he EOE8 >? parts are the same (standard), but the surrounding 8 code will need to be changed, including the host variable declarations, if you are using a different language. 5Embedded >? changes from system to system, so, once again, chec& local documentation, especially variable declarations and logging 1C

in procedures, in which networ&, %N( , and operating system considerations are crucial. G2 2GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG2 2G #AI *3O!3"( I +O# 8O(*I?"N?E O3 EOE8-#"N?E G2 2G I# I =O3 EO"(*?E *-3*O E O+?H G2 2GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG2 Qinclude 2G #his section declares the host variables. these will be the variables your program uses, but also the variable >? will put values in or ta&e values out. G2 EOE8 >? NE!I+ %E8?"3E E8#IO+. int NuyerI%. char =irst+ameW1LLX, ?ast+ameW1LLX, ItemW1LLX. EOE8 >? E+% %E8?"3E E8#IO+. 2G #his includes the >?8" variable, so that some error chec&ing can be done. G2 EOE8 >? I+8?-%E >?8". main() a 2G #his is a possible way to log into the database G2 EOE8 >? 8O++E8# -serI%2*assword. 2G #his code either says that you are connected or chec&s if an error code was generated, meaning log in was incorrect or not possible. G2 if(s/lca.s/lcode) a printf(*rinter, ]Error connecting to database server.Dn]). e)it(). b printf(]8onnected to database server.Dn]). 2G #his declares a ]8ursor]. #his is used when a /uery returns more than one row, and an operation is to be performed on each row resulting from the /uery. With each row established by this /uery, I\m going to use it in the report. ?ater, ]=etch] will be used to pic& off each row, one at a time, but for the /uery to actually be e)ecuted, the ]Open] statement is used. #he ]%eclare] Just establishes the /uery. G2 EOE8 >? %E8?"3E Item8ursor 8-3 O3 =O3 E?E8# I#E(, N-HE3I% =3O( "+#I>-E O3%E3 NH I#E(. EOE8 >? O*E+ Item8ursor. 2G V55 Hou may wish to put a similar error chec&ing bloc& here 55V G2 2G =etch puts the values of the ]ne)t] row of the /uery in the host variables, respectively. Aowever, a ]priming fetch] (programming techni/ue) must first be done. When the cursor is out of data, a s/lcode will be generated allowing us to leave the loop. +otice that, for simplicity\s sa&e, the loop will leave on any s/lcode, 1I even if it is an error code. Otherwise, specific code chec&ing must be performed. G2 EOE8 >? =E#8A Item8ursor I+#O 0Item, 0NuyerI%.

while(_s/lca.s/lcode) a 2G With each row, we will also do a couple of things. =irst, bump the price up by `; (dealer\s fee) and get the buyer\s name to put in the report. #o do this, I\ll use an -pdate and a elect, before printing the line on the screen. #he update assumes however, that a given buyer has only bought one of any given item, or else the price will be increased too many times. Otherwise, a ]3owI%] logic would have to be used (see documentation). "lso notice the colon before host variable names when used inside of >? statements. G2 EOE8 >? -*%"#E "+#I>-E E# *3I8E U *3I8E V ; WAE3E I#E( U 0Item "+% N-HE3I% U 0NuyerI%. EOE8 >? E?E8# OW+E3=I3 #+"(E, OW+E3?" #+"(E I+#O 0=irst+ame, 0?ast+ame =3O( "+#I>-EOW+E3 WAE3E N-HE3I% U 0NuyerI%. printf(]F4;s F4;s F4;s], =irst+ame, ?ast+ame, Item). 2G -gly report55for e)ample purposes only_ !et the ne)t row. G2 EOE8 >? =E#8A Item8ursor I+#O 0Item, 0NuyerI%. b 2G 8lose the cursor, commit the changes (see below), and e)it the program. G2 EOE8 >? 8?O E Item8ursor. EOE8 >? 8O((I# 3E?E" E. e)it(). b 8ommon >? >uestions < "dvanced #opics 1. Why can\t I Just as& for the first three rows in a table6 55Necause in relational databases, rows are inserted in no particular order, that is, the system inserts them in an arbitrary order. so, you can only re/uest rows using valid >? features, li&e O3%E3 NH, etc. 4. What is this %%? and %(? I hear about6 55%%? (%ata %efinition ?anguage) refers to (in >?) the 8reate #able statement...%(? (%ata (anipulation ?anguage) refers to the elect, -pdate, Insert, and %elete statements. "lso, >(?, referring to elect statements, stands for >uery (anipulation ?anguage. 9. "ren\t database tables Just files6 55Well, %N( \s store data in files declared by system managers before new tables are created (on large systems), but the system stores the data in a special format, and may spread data from one table over several files. In the database world, a set of files created for a database is called a tablespace. In general, on small systems, everything about a database (definitions and all table data) is &ept in one file. :. (3elated /uestion) "ren\t database tables Just li&e spreadsheets6 55+o, for two reasons. =irst, 1K spreadsheets can have data in a cell, but a cell is more than Just a row5column5intersection. %epending on your spreadsheet software, a cell might also contain formulas and formatting, which database tables cannot have (currently). econdly, spreadsheet cells are often dependent on the data in other cells. In databases, ]cells] are independent, e)cept that columns are logically related (hopefully. together a row of columns describe an entity), and, other than primary &ey and foreign &ey constraints, each row in a table is independent from one another. ;. Aow do I import a te)t file of data into a database6 55Well, you can\t do it directly...you must use a utility, such as Oracle\s >?G?oader, or write a program to load the data into the database. " program

to do this would simply go through each record of a te)t file, brea& it up into columns, and do an Insert into the database. @. What web sites and computer boo&s would you recommend for more information about >? and databases6 55=irst, loo& at the sites at the bottom of this page. I would especially suggest the following0 %N Ingredients (more theorical topics), %N( ?ab2?in&s (comprehensive academic %N( lin& listing), #utorial *age (listing of other tutorials), and mini >? (more information about the best &nown free %N( ). "lso, if you wish to practice >? on an interactive site (using Tava technologies), I highly recommend =ran& #orres\ (torresfcuswest.net) site at http022s/lcourse.com and its new se/uel (so to spea&) site at http022s/lcourse4.com. =ran& did an outstanding Job with his site, and if you have a recent release browser, it\s definitely worth a visit. In addition, point your browser to www.topica.com, and subscribe to their >? e5mail #ips of the %ay...they are outstanding. #im >uinlan goes into topics that I can\t even begin to go into here, such inde) data structures (N5trees and NV5trees) and Join algorithms, so advanced I# 3%N( pros will get a daily insight into these data management tools. -nfortunately, there is not a great deal of information on the web about >?. the list I have below is fairly comprehensive (definitely representative). "s far as boo&s are concerned, I would suggest (for beginners to intermediate5level) ]Oracle0 #he 8omplete 3eference] (multiple versions) from Oracle and ]-nderstanding >?] from ybe) for general >? information. "lso, I would recommend O\3eilly *ublishing\s boo&s, and Toe 8el&o\s writings for advanced users. =or specific %N( info (especially in the "ccess area), I recommend >ue\s ]-sing] series, and the boo&s of "lison Nalter. C. What is a schema6 55" schema is a logical set of tables, such as the "nti/ues database above...usually, it is thought of as simply ]the database], but a database can hold more than one schema. =or e)ample, a star schema is a set of tables where one large, central table holds all of the important information, and is lin&ed, via foreign &eys, to dimension tables which hold detail information, and can be used in a Join to create detailed reports. I. I understand that Oracle offers a special &eyword, %ecode, that allows for some ]if5then] logic. Aow does that wor&6 55 #echnically, %ecode allows for conditional output based on the value of a column or function. #he synta) loo&s li&e this (from the Oracle0 8omplete 3eference series)0 elect ...%E8O%E (,alue, If1, #hen1, WIf 4, #hen 4, ...,X Else) ...=rom .... #he ,alue is the name of a column, or a function (conceivably based on a column or columns), and for each If included in the statement, the corresponding #hen clause is the output if the condition is true. If none of the conditions are true, then the Else value is output. ?et\s loo& at an e)ample0 elect %istinct 8ity, %E8O%E (8ity, \8incinnati\, \>ueen 8ity\, \+ew Hor&\, \Nig "pple\, \8hicago\, 4L \8ity of Nroad houlders\, 8ity) " +ic&name =rom 8ities. #he output might loo& li&e this0 8ity +ic&name 555555555555 555555555555555555555555555555 Noston Noston 8incinnati >ueen 8ity 8leveland 8leveland +ew Hor& Nig "pple \8ity\ in the first argument denotes the column name used for the test. #he second, fourth, etc. arguments are the individual e/uality tests (ta&en in the order given) against each value in the 8ity column. #he third, fifth, etc. arguments are the corresponding outputs if the corresponding test is true. #he final parameter is the default output if none of the tests are true. in this case, Just print out the column value. #I*0 If you want nothing to be output for a given condition, such as the default ]Else] value, enter the

value +ull for that value, such as0 elect %istinct 8ity, %E8O%E (8ity, \8incinnati\, \>ueen 8ity\, \+ew Hor&\, \Nig "pple\, \8hicago\, \8ity of Nroad houlders\, +ull) " +ic&name =rom 8ities. If the 8ity column value is not one of the ones mentioned, nothing is outputted, rather than the city name itself. 8ity +ic&name 555555555555 5555555555 Noston 8incinnati >ueen 8ity 8leveland +ew Hor& Nig "pple K. Hou mentioned 3eferential Integrity before, but what does that have to do with this concept I\ve heard about, 8ascading -pdates and %eletes6 55#his is a difficult topic to tal& about, because it\s covered differently in different %N( \s. =or e)ample, (icrosoft >? erver (C.L < below) re/uires that you write ]triggers] (see the Hahoo >? 8lub lin& to find lin&s that discuss this topic55I may include that topic in a future version of this page) to implement this. (" /uic& definition, though. a #rigger is a >? statement stored in the database that allows you to perform a given /uery Wusually an ]"ction] >uery55%elete, Insert, -pdateX automatically, when a specified event occurs in the database, such as a column update, but anyway...) (icrosoft "ccess (believe it or not) will perform this if you define it in the 3elationships screen, but it will still burden you with a prompt. Oracle does this automatically, if you specify a special ]8onstraint] (see reference at bottom for definition, not synta)) on the &eyed column. o, I\ll Just discuss the concept. =irst, see the discussion above on *rimary and =oreign &eys. 41 8oncept0 If a row from the primary &ey column is deleted2updated, if ]8ascading] is activated, the value of the foreign &ey in those other tables will be deleted (the whole row)2updated. #he reverse, a foreign &ey deletion2update causing a primary &ey value to be deleted2changed, may or may not occur0 the constraint or trigger may not be defined, a ]one5to5many] relationship may e)ist, the update might be to another e)isting primary &ey value, or the %N( itself may or may not have rules governing this. "s usual, see your %N( \s documentation. =or e)ample, if you set up the "nti/ueOwners table to have a *rimary Bey, OwnerI%, and you set up the database to delete rows on the =oreign Bey, ellerI%, in the "nti/ues table, on a primary &ey deletion, then if you deleted the "nti/ueOwners row with OwnerI% of \L1\, then the rows in "nti/ues, with the Item values, Ned, 8abinet, and Tewelry No) (\L1\ sold them), will all be deleted. Of course, assuming the proper %N definition, if you Just updated \L1\ to another value, those eller I% values would be updated to that new value too. 1L. how me an e)ample of an outer Join. 55Well, from the /uestions I receive, this is an e)tremely common e)ample, and I\ll show you both the Oracle and "ccess /ueries... #hin& of the following Employee table (the employees are given numbers, for simplicity)0 +ame %epartment 1 1L 4 1L 9 4L : 9L ; 9L +ow thin& of a department table0 %epartment

1L 4L 9L :L +ow suppose you want to Join the tables, seeing all of the employees and all of the departments together...you\ll have to use an outer Join which includes a null employee to go with %ept. :L. In the boo&, ]Oracle C0 the 8omplete 3eference], about outer Joins, ]thin& of the (V), which must immediately follow the Join column of the table, as saying add an e)tra (null) row anytime there\s no match]. o, in Oracle, try this /uery (the V goes on Employee, which adds the null row on no match)0 elect E.+ame, %.%epartment =rom %epartment %, Employee E Where E.%epartment(V) U %.%epartment. 44 #his is a left (outer) Join, in "ccess0 E?E8# %I #I+8#3OW Employee.+ame, %epartment.%epartment =3O( %epartment ?E=# TOI+ Employee O+ %epartment.%epartment U Employee.%epartment. "nd you get this result0 +ame %epartment 1 1L 4 1L 9 4L : 9L ; 9L :L 11. What are some general tips you would give to ma&e my >? /ueries and databases better and faster (optimi'ed)6 Hou should try, if you can, to avoid e)pressions in elects, such as E?E8# 8olumn" V 8olumnN, etc. #he /uery optimi'er of the database, the portion of the %N( that determines the best way to get the re/uired data out of the database itself, handles e)pressions in such a way that would normally re/uire more time to retrieve the data than if columns were normally selected, and the e)pression itself handled programmatically. (inimi'e the number of columns included in a !roup Ny clause. If you are using a Join, try to have the columns Joined on (from both tables) inde)ed. When in doubt, inde). -nless doing multiple counts or a comple) /uery, use 8O-+#(G) (the number of rows generated by the /uery) rather than 8O-+#(8olumn7+ame). 14. What is a 8artesian product6 55 imply, it is a Join without a Where clause. It gives you every row in the first table, Joined with every row in the second table. #his is best shown by e)ample0 E?E8# G =3O( "nti/ueOwners, Orders. #his gives0 "nti/ueOwners. OwnerI% "nti/ueOwners. Owner?ast+ame "nti/ueOwners. Owner=irst+ame

Orders. OwnerI% Orders. Item%esired L1 Tones Nill L4 #able L1 Tones Nill L4 %es& L1 Tones Nill 41 8hair L1 Tones Nill 1; (irror L4 mith Nob L4 #able 49 L4 mith Nob L4 %es& L4 mith Nob 41 8hair L4 mith Nob 1; (irror 1; ?awson *atricia L4 #able 1; ?awson *atricia L4 %es& 1; ?awson *atricia 41 8hair 1; ?awson *atricia 1; (irror 41 "&ins Tane L4 #able 41 "&ins Tane L4 %es& 41 "&ins Tane 41 8hair 41 "&ins Tane 1; (irror ;L =owler am L4 #able ;L =owler am L4 %es& ;L =owler am 41 8hair ;L =owler am 1; (irror #he number of rows in the result has the number of rows in the first table times the number of rows in the second table, and is sometimes called a 8ross5Toin. If you thin& about it, you can see how Joins wor&. ?oo& at the 8artesian product results, then loo& for rows where the OwnerI%\s are e/ual, and the result is what you would get on an e/uiJoin. Of course, this is not how %N( \s actually perform Joins because loading this result can ta&e too much memory. instead, comparisons are performed in nested loops, or by comparing values in inde)es, and then loading result rows. 19. What is normali'ation6 55+ormali'ation is a techni/ue of database design that suggests that certain criteria be used when constructing a table layout (deciding what columns each table will have, and creating the &ey structure), where the idea is to eliminate redundancy of non5&ey data across tables. +ormali'ation is usually referred to in terms of forms, and I will introduce only the first three, even though it is somewhat common to use other, more advanced forms (fourth, fifth, Noyce58odd. see documentation). =irst +ormal =orm refers to moving data into separate tables where the data in each table is of a similar type, and by giving each table a primary &ey. *utting data in econd +ormal =orm involves removing to other tables data that is only dependent of a part of the &ey. =or e)ample, if I had left the names of the "nti/ue Owners in the items table, that would not be in econd +ormal =orm because that data would be redundant. the name would be repeated for each item owned. as such, the names were placed in their own table. #he names themselves don\t have anything to do with the items, only the identities of the buyers and sellers. 4: #hird +ormal =orm involves getting rid of anything in the tables that doesn\t depend solely on the

primary &ey. Only include information that is dependent on the &ey, and move off data to other tables that are independent of the primary &ey, and create a primary &ey for the new tables. #here is some redundancy to each form, and if data is in 9+= (shorthand for 9rd normal form), it is already in 1+= and 4+=. In terms of data design then, arrange data so that any non5primary &ey columns are dependent only on the whole primary &ey. If you ta&e a loo& at the sample database, you will see that the way then to navigate through the database is through Joins using common &ey columns. #wo other important points in database design are using good, consistent, logical, full5word names for the tables and columns, and the use of full words in the database itself. On the last point, my database is lac&ing, as I use numeric codes for identification. It is usually best, if possible, to come up with &eys that are, by themselves, self5e)planatory. for e)ample, a better &ey would be the first four letters of the last name and first initial of the owner, li&e TO+EN for Nill Tones (or for tiebrea&ing purposes, add numbers to the end to differentiate two or more people with similar names, so you could try TO+EN1, TO+EN4, etc.). 1:. What is the difference between a single5row /uery and a multiple5row /uery and why is it important to &now the difference6 55=irst, to cover the obvious, a single5row /uery is a /uery that returns one row as its result, and a multiple5row /uery is a /uery that returns more than one row as its result. Whether a /uery returns one row or more than one row is entirely dependent on the design (or schema) of the tables of the database. "s /uery5writer, you must be aware of the schema, be sure to include enough conditions, and structure your >? statement properly, so that you will get the desired result (either one row or multiple rows). =or e)ample, if you wanted to be sure that a /uery of the "nti/ueOwners table returned only one row, consider an e/ual condition of the primary &ey column, OwnerI%. #hree reasons immediately come to mind as to why this is important. =irst, getting multiple rows when you were e)pecting only one, or vice5versa, may mean that the /uery is erroneous, that the database is incomplete, or simply, you learned something new about your data. econd, if you are using an update or delete statement, you had better be sure that the statement that you write performs the operation on the desired row (or rows)...or else, you might be deleting or updating more rows than you intend. #hird, any /ueries written in Embedded >? must be carefully thought out as to the number of rows returned. If you write a single5row /uery, only one >? statement may need to be performed to complete the programming logic re/uired. If your /uery, on the other hand, returns multiple rows, you will have to use the =etch statement, and /uite probably, some sort of looping structure in your program will be re/uired to iterate processing on each returned row of the /uery. 1;. #ell me about a simple approach to relational database design. 55#his was sent to me via a news posting. it was submitted by Tohn =rame ( JframecJframe.com ) and 3ichard =reedman ( rfreedmcvoicenet.com ). I offer a shortened version as advice, but I\m not responsible for it, and some of the concepts are readdressed in the ne)t /uestion... =irst, create a list of important things (entities) and include those things you may not initially believe is important. econd, draw a line between any two entities that have any connection whatsoever. e)cept that no two entities can connect without a \rule\. e.g.0 families have children, employees wor& for a department. #herefore put the \connection\ in a diamond, the \entities\ in s/uares. #hird, your picture should now have many s/uares (entities) connected to other entities through diamonds (a s/uare enclosing an entity, with a line to a diamond describing the relationship, and then another line to the other 4; entity). =ourth, put descriptors on each s/uare and each diamond, such as customer 55 airline 55 trip. =ifth, give each diamond and s/uare any attributes it may have (a person has a name, an invoice has a number), but some relationships have none (a parent Just owns a child). i)th, everything on your page that has attributes is now a table, whenever two entities have a relationship where the relationship has no attributes, there is merely a foreign &ey between the tables. eventh, in general you want to ma&e tables not repeat data. o, if a customer has a name and several addresses, you can see that for every address of a customer, there will be repeated the customer\s first name, last name, etc. o, record +ame in one

table, and put all his addresses in another. Eighth, each row (record) should be uni/ue from every other one. (r. =reedman suggests a \auto5increment number\ primary &ey, where a new, uni/ue number is generated for each new inserted row. +inth, a &ey is any way to uni/uely identify a row in a table...first and last name together are good as a \composite\ &ey. #hat\s the techni/ue. 1@. What are relationships6 55"nother design /uestion...the term ]relationships] (often termed ]relation]) usually refers to the relationships among primary and foreign &eys between tables. #his concept is important because when the tables of a relational database are designed, these relationships must be defined because they determine which columns are or are not primary or foreign &eys. Hou may have heard of an Entity53elationship %iagram, which is a graphical view of tables in a database schema, with lines connecting related columns across tables. ee the sample diagram at the end of this section or some of the sites below in regard to this topic, as there are many different ways of drawing E53 diagrams. Nut first, let\s loo& at each &ind of relationship... " One5to5one relationship means that you have a primary &ey column that is related to a foreign &ey column, and that for every primary &ey value, there is one foreign &ey value. =or e)ample, in the first e)ample, the Employee"ddress#able, we add an EmployeeI%+o column. #hen, the Employee"ddress#able is related to the Employee tatistics#able (second e)ample table) by means of that EmployeeI%+o. pecifically, each employee in the Employee"ddress#able has statistics (one row of data) in the Employee tatistics#able. Even though this is a contrived e)ample, this is a ]151] relationship. "lso notice the ]has] in bold...when e)pressing a relationship, it is important to describe the relationship with a verb. #he other two &inds of relationships may or may not use logical primary &ey and foreign &ey constraints...it is strictly a call of the designer. #he first of these is the one5to5many relationship (]15(]). #his means that for every column value in one table, there is one or more related values in another table. Bey constraints may be added to the design, or possibly Just the use of some sort of identifier column may be used to establish the relationship. "n e)ample would be that for every OwnerI% in the "nti/ueOwners table, there are one or more ('ero is permissible too) Items bought in the "nti/ues table (verb0 buy). =inally, the many5to5many relationship (](5(]) does not involve &eys generally, and usually involves identifying columns. #he unusual occurrence of a ](5(] means that one column in one table is related to another column in another table, and for every value of one of these two columns, there are one or more related values in the corresponding column in the other table (and vice5versa), or more a common possibility, two tables have a 15( relationship to each other (two relationships, one 15( going each way). " WbadX e)ample of the more common situation would be if you had a Job assignment database, where one table held one row for each employee and a Job assignment, and another table held one row for each Job with one of the assigned employees. Aere, you would have multiple rows for each employee in the first table, one for each Job assignment, and multiple rows for each Job in the second 4@ table, one for each employee assigned to the proJect. #hese tables have a (5(0 each employee in the first table has many Job assignments from the second table, and each Job has many employees assigned to it from the first table. #his is the tip of the iceberg on this topic...see the lin&s below for more information and see the diagram below for a simplified e)ample of an E53 diagram. 1C. What are some important nonstandard >? features (e)tremely common /uestion)6 55Well, see the ne)t section... +onstandard >?...]chec& local listings] I+#E3 E8# and (I+- are li&e the -+IO+ statement, e)cept that I+#E3 E8# produces rows that appear in both /ueries, and (I+- produces rows that result from the first /uery, but not the second. 3eport !eneration =eatures0 the 8O(*-#E clause is placed at the end of a /uery to place the result of an aggregate function at the end of a listing, li&e 8O(*-#E -( (*3I8E). "nother option is to use

brea& logic0 define a brea& to divide the /uery results into groups based on a column, li&e N3E"B O+ N-HE3I%. #hen, to produce a result after the listing of a group, use 8O(*-#E -( O= *3I8E O+ N-HE3I%. If, for e)ample, you used all three of these clauses (N3E"B first, 8O(*-#E on brea& second, 8O(*-#E overall sum third), you would get a report that grouped items by their NuyerI%, listing the sum of *rices after each group of a NuyerI%\s items, then, after all groups are listed, the sum of all *rices is listed, all with >?5generated headers and lines. In addition to the above listed aggregate functions, some %N( \s allow more functions to be used in elect lists, e)cept that these functions (some character functions allow multiple5row results) are to be used with an individual value (not groups), on single5row /ueries. #he functions are to be used only on appropriate data types, also. Aere are some (athematical =unctions0 "N (O) "bsolute value5converts negative numbers to positive, or leaves positive numbers alone 8EI?(O) O is a decimal value that will be rounded up. =?OO3(O) O is a decimal value that will be rounded down. 4C !3E"#E #(O,H) 3eturns the largest of the two values. ?E" #(O,H) 3eturns the smallest of the two values. (O%(O,H) 3eturns the remainder of O 2 H. *OWE3(O,H) 3eturns O to the power of H. 3O-+%(O,H) 3ounds O to H decimal places. If H is omitted, O is rounded to the nearest integer. I!+(O) 3eturns a minus if O ^ L, else a plus. >3#(O) 3eturns the s/uare root of O. 8haracter =unctions ?E=#(,O) 3eturns the leftmost O characters of the string. 3I!A#(,O) 3eturns the rightmost O characters of the string. -**E3() 8onverts the string to all uppercase letters. ?OWE3() 8onverts the string to all lowercase letters. I+I#8"*() 8onverts the string to initial caps. ?E+!#A() 3eturns the number of characters in the string. dd 8ombines the two strings of te)t into one, concatenated string, where the first string is immediately followed by the second. ?*"%(,O,\G\) *ads the string on the left with the G (or whatever character is inside the /uotes), to ma&e the string O characters long. 3*"%(,O,\G\) *ads the string on the right with the G (or whatever character is inside the /uotes), to ma&e the string O characters long. -N #3(,O,H) E)tracts H letters from the string beginning at position O. +,?(,) #he +ull value function will substitute for any +-??s for in the . If the current value of is not +-??, +,? has no effect. ynta) ummary55=or "dvanced -sers Only Aere are the general forms of the statements discussed in this tutorial, plus some e)tra important ones (e)planations given). 3E(E(NE3 that all of these statements may or may not be available on your system, so chec& documentation regarding availability0 "?#E3 #"N?E "%%d%3O*d(O%I=H (8O?-(+ *E8I=I8"#IO+W X...see 8reate #able). 55allows you to add or delete a column or columns from a table, or change the specification (data type, etc.) on an e)isting column. this statement is also used to change the physical specifications of a table (how a table is stored, etc.), but these definitions are %N( 5specific, so read the documentation. "lso, these physical specifications are used with the 8reate #able statement, when a table is first created. In addition, only one option

4I can be performed per "lter #able statement 55either add, drop, O3 modify in a single statement. 8O((I#. 55ma&es changes made to some database systems permanent (since the last 8O((I#. &nown as a transaction) 83E"#E W-+I>-EX I+%EO O+ (). 55-+I>-E is optional. within brac&ets. 83E"#E #"N?E ( W()X , ...other columns). (also valid with "?#E3 #"N?E) 55where IZE is only used on certain data types (see above), and constraints include the following possibilities (automatically enforced by the %N( . failure causes an error to be generated)0 1. +-?? or +O# +-?? (see above) 4. -+I>-E enforces that no two rows will have the same value for this column 9. *3I("3H BEH tells the database that this column is the primary &ey column (only used if the &ey is a one column &ey, otherwise a *3I("3H BEH (column, column, ...) statement appears after the last column definition. :. 8AE8B allows a condition to be chec&ed for when data in that column is updated or inserted. for e)ample, 8AE8B (*3I8E L) causes the system to chec& that the *rice column is greater than 'ero before accepting the value...sometimes implemented as the 8O+ #3"I+# statement. ;. %E="-?# inserts the default value into the database if a row is inserted without that column\s data being inserted. for e)ample, NE+E=I# I+#E!E3 %E="-?# U 1LLLL @. =O3EI!+ BEH wor&s the same as *rimary Bey, but is followed by0 3E=E3E+8E (), which refers to the referential primary &ey. 83E"#E ,IEW " . %E?E#E =3O( WAE3E . I+ E3# I+#O W()X ,"?-E (). 3O??N"8B. 55#a&es bac& any changes to the database that you have made, bac& to the last time you gave a 8ommit command...beware_ ome software uses automatic committing on systems that use the transaction features, so the 3ollbac& command may not wor&. E?E8# W%I #I+8#d"??X =3O( WWAE3E X W!3O-* NH X WA",I+! X WO3%E3 NH W" 8d%E 8XX. 55where " 8d%E 8 allows the ordering to be done in " 8ending or %E 8ending order -*%"#E E# U 4K WWAE3E X. 55if the Where clause is left out, all rows will be updated according to the et statement. E)ercises >ueries -sing the e)ample tables in the tutorial, write a >? statement to0 1. how each "nti/ues order and the last and first names of the person who ordered the item.

4. how each column in the Employee tatistics#able in alphabetical order by *osition, then by EmployeeI%+o. 9. how the annual budget for Nenefits from the Employee tatistics#able. :. -sing the I+ Operator, show the names of the owners of 8hairs. ;. how the names of all "nti/ues Owners who have do not have an order placed. @. how the names of those who have placed "nti/ue orders, with no duplicates (Aint0 consider the order of tables in the =rom clause). C. %elete all of Nob mith\s "nti/ue orders (Aint0 Nob\s I% +umber is L4). I. 8reate an "nti/ue order for a 3oc&ing 8hair for Tane "&ins (Aint0 Tane\s I% +umber is 41). K. 8reate a table called Employees, with columns EmployeeI%+o (don\t worry about trailing 'eroes), =irst+ame, and ?ast+ame. 1L. (8hallenger) how the annual budget for alary by each position from the Employee tatistics#able (Aint0 #ry !3O-* NH). %atabases 11. What is the relationship between the "nti/ueOwners table and the Owners table6 14. If you do not have a primary &ey in a table, the addition of what type of column is preferred to give the table a primary &ey6 19. Which function will allow you to substitute a given value for any +ull values arising from a elect statement6 1:. When using Embedded >?, what do you need to create in order to iterate through the results of a multi5row /uery, one row at a time6 1;. If all of the columns in all of the tables in your schema are dependent solely on the value of the primary &ey in each table, in which +ormal =orm is your design6 1@. What term is used to describe the event of a database system automatically updating the values of foreign &eys in other tables, when the value of a primary &ey is updated6 1C. What database obJect provides fast access to the data in the rows of a table6 1I. What type of >? statement is used to change the attributes of a column6 1K. In a 8reate #able statement, when a column is designated as +O# +-??, what does this mean6 4L. If you wish to write a /uery that is based on other /ueries, rather than tables, what do these other /ueries need to be created as6 "nswers (>ueries may have more than one correct answer)0 1. E?E8# "nti/ueOwners.Owner?ast+ame, "nti/ueOwners.Owner=i rst+ame, Orders.Item%esired =3O( "nti/ueOwners, Orders WAE3E "nti/ueOwners.OwnerI% U Orders.OwnerI%. or E?E8# "nti/ueOwners.Owner?ast+ame, "nti/ueOwners.Owner=irst+ame, Orders.Item%esired =3O( "nti/ueOwners 3I!A# TOI+ Orders O+ "nti/ueOwners.OwnerI% U Orders.OwnerI%. 9L 4. E?E8# G =3O( Employee tatistics#able O3%E3 NH *osition, EmployeeI%+o. 9. E?E8# um(Nenefits) =3O( Employee tatistics#able. :. E?E8# Owner?ast+ame, Owner=irst+ame

=3O( "nti/ueOwners, "nti/ues WAE3E Item In (\8hair\) "+% "nti/ueOwners.OwnerI% U "nti/ues.NuyerI%. ;. E?E8# Owner?ast+ame, Owner=irst+ame =3O( "nti/ueOwners WAE3E OwnerI% +O# I+ ( E?E8# OwnerI% =3O( Orders). @. E?E8# %I #I+8# Owner?ast+ame, Owner=irst+ame =3O( Orders, "nti/ueOwners WAE3E "nti/ueOwners.OwnerI% U Orders.OwnerI%. or to use TOI+ notation0 E?E8# %I #I+8# "nti/ueOwners.Owner?ast+ame, "nti/ueOwners.Owner=irst+ame =3O( "nti/ueOwners 3I!A# TOI+ Orders O+ "nti/ueOwners.OwnerI% U Orders.OwnerI%. C. %E?E#E =3O( O3%E3 WAE3E OW+E3I% U L4. I. I+ E3# I+#O O3%E3 ,"?-E (41, \3oc&ing 8hair\). K. 83E"#E #"N?E E(*?OHEE (EmployeeI%+o I+#E!E3 +O# +-??, =irst+ame 8A"3(:L) +O# +-??, ?ast+ame 8A"3(:L) +O# +-??). 1L. E?E8# *osition, um( alary) =3O( Employee tatistics#able !3O-* NH *osition. 11. One5to5(any. 14. "n integer identification number. an auto5increment I% is preferred. 19. +,?. 1:. " 8ursor. 1;. #hird +ormal =orm. 1@. 8ascading update. 1C. "n Inde). 1I. "?#E3 #"N?E. 1K. " value is re/uired in this column for every row in the table. 4L. ,iews. Important 8omputing < >?2%atabase ?in&s >? 3eference *age *rogrammer\s ource %evO %N Ingredients >? #rainer 2W Web "uthoring %N( ?ab2?in&s >? ="> 91 >uery ?ist >? *ractice ite >? 8ourse II %atabase Tump ite *rogramming #utorials on the Web

*ostgre >? "dobe "crobat " !ood %N 8ourse #utorial *age Intelligent Enterprise (aga'ine mini >? >? for %N4 Noo& >? erver C >? 3eference2E)amples >? #opics ?ee\s %ata Warehousing Aomepage (I# >? for Web +erds 3%N( erver =eature 8omparison (atri) Oracle ="> Oracle %eveloper (4LLL) Intro to 3elational %atabase %esign >? am, the >? erver %etective Z%+et\s >? Introduction Naycon !roup\s %ragonlee\s " good, but anonymous -8 %avis\ Oracle *%=\s "bout.com\s %atabase "dvisor (anas #ungare\s at =ind#utorials.com " !entle Introduction to >? >? (+ews) Wire I strongly urge you to visit some of the database lin&s shown above, especially if you\re interested in advanced topics, such as the >?5K4 standard, different relational %N( \s, and advanced /uery processing. If you\re using a well5&nown, name5brand %N( , the web site of your vendor is often the first and best place to loo& for information. I am not available for any consultations at this time. If you have a /uestion or comment, please go to the
0 comments

Oracle !Q/FAet? AetG FAQ


What is >?G+et2 +etI6 +E#I (called >?G+E# prior to OracleI) is Oracle\s client2server middleware product that offers transparent connection from client tools to the database, or from one database to another. >?G+et2 +etI wor&s across multiple networ& protocols and operating systems. #+ or #ransparent +etwor& ubstrate is Oracle\s networ&ing architecture. #+ provides a uniform application interface to enable networ& applications to access the underlying networ& protocols transparently. #he #+ architecture consists of three software components0 #+ 5based applications, Oracle *rotocol "dapters (O*"), and networ&ing software li&e #8*2I*. Nac& to top of file What is the difference between >?G+et ,1, ,4 and +E#I6 >?G+et ,1 >?G+et ,4 +etI %efault port 1;4;2tcp 1;412tcp 1;412tcp tart command tcpctl start lsnrctl start lsnrctl start

top command tcpctl stop lsnrctl stop lsnrctl stop 8onnect string protocol0host0sid eg. #0 3,10%N1 pecified in #+ +"(E .O3" pecified in #+ +"(E .O3" 8onfig files 2etc2oratab tnsnames.ora, s/lnet.ora < listener.ora tnsnames.ora, s/lnet.ora < listener.ora Env variable ?O8"?U #WO7#" BU #WO7#" BU Nac& to top of file Aow does one configure >?G+et6 (ost people (myself included) prefer to edit the >?G+et configuration files by hand. #he only ]officially supported] configuration method, however, is via the Oracle +etI "ssistant or Oracle +etI Easy 8onfig utility (previously called Oracle +etwor& (anager). #his configuration utility is *8 based. Hou need to generate the necessary files on your *8 and =#* or copy them to the relevant operating systems you use Oracle on. ?oo& at the following sample configuration files0 `O3"8?E7AO(E2networ&2admin2s/lnet.ora 5555555555555555555555555555555555555 automatic7ipc U O+ Q et to O== for *8\s trace7level7client U O== Q et to 1@ if tracing is re/uired s/lnet.e)pire7time U L Q Idle time in minutes s/lnet.authentication7services U ("??) names.directory7loo&up U (#+ +"(E ,O+"(E ) names.default7domain U world name.default7'one U world `O3"8?E7AO(E2networ&2admin2tnsnames.ora 555555555555555555555555555555555555555 dbname1, aliasname1, aliasname4 U (description U (address7list U (address U (protocol U tcp) (host U yourAost.domain) (port U 1;41) ) ) (connect7data U (sid U your I%) ) ) `O3"8?E7AO(E2networ&2admin2listener.ora 555555555555555555555555555555555555555 ?I #E+E3 U Q ?istener name is ?I #E+E3 (address7list U (addressU (protocolUipc) (&eyUyour I%) )

(addressU (protocol U tcp) (host U yourAost.domain) (port U 1;41) ) ) #"3#-*7W"I#7#I(E7?I #E+E3 U L 8O++E8#7#I(EO-#7?I #E+E3 U 1L #3"8E7?E,E?7?I #E+E3 U O+ #3"8E7=I?E7?I #E+E3 U `O3"8?E7AO(E2networ&2trace2listener.trc I%7?I #7?I #E+E3 U ( I%7?I #U ( I%7%E 8U ( I%7+"(EUyour I%) (O3"8?E7AO(EUHO-37O3"8?E7AO(E) ) ) +O#E0 " wrong #+ +"(E .O3" entry on a line will bloc& all valid entries below. 8opy names to the top until you find the incorrect entry. Nac& to top of file I have some trouble with >?G+et. Aow can I produce a trace file6 8reate2edit your >?+E#.O3" file. Hou will find this file in one of the following locations ( >?G+et ,4 searches for it in this order)0 %irectory pointed to by the #+ 7"%(I+ parameter (`#+ 7"%(I+ on -ni)) 2etc (-ni) only) 2var2opt2oracle (-ni) only) `O3"8?E7AO(E2networ&2admin or netI2admin directory Hour >?+E#.O3" file should contain the following lines to produce a trace file0 trace7level7clientU1@ trace7uni/ue7clientUyes ometimes it is useful to only trace #+ *I+! pac&ets. "dd the following parameters to your >?+E#.O3" file0 #+ *I+!.#3"8E7?E,E? U 1@ #+ *I+!.#3"8E7%I3E8#O3H U 2tmp2tnsping2 #he following parameters are also worth setting0 trace7file7client U cli.trc trace7directory7client U log7file7client U s/lnet.log log7directory7client U Nac& to top of file Aow can I set up a dedicated server connection6 When you configue your database to use (# ((ulti5threaded server), all client re/uests are handed off to one of the shared server processes by the listener, via a dispatcher. If you want certain clients to use a dedicated erver process, you need to set the dedicated server option in your database connect string0 ie. >?*?- 8O##2#I!E3c(%E 83I*#IO+U("%%3E 7?I #U("%%3E U(*3O#O8O?U#8*)

(*O3#U1;41) (+O%EUyour erver+ame))) (8O++E8#7%"#"U( I%Uyour id) ( E3,E3U%E%I8"#E%))) Hou can also edit your #+ +"(E .O3" file and add the ( E3,E3U%E%I8"#E%) part in the 8O++E8#7%"#" list or simply set - E7%E%I8"#E%7 E3,E3UO+ in your >?+E#.O3" file. Nac& to top of file 8an I upgrade to >?G+et ,4 if I still have ,1 clients6 >?G+et ,1 cannot tal& with >?G+et ,4, and vice versa. #he only way to overcome this problem is to run >?G+et ,1 and ,4 simultaneously on the same database server. Hou can then install >?G+et ,4 on your clients as time permits. >?G+et ,1 and ,4 can coe)ist on the same server, or on the same client. Hou can also list ,1 connect strings in your #+ +"(E .O3" file. Eg0 O3"17+E#1 U #0machine7name2port0database7name +ote that >?G+et ,1 is not available from version C.9 of the database. Nac& to top of file Aow can I enable dead connection detection6 %ead database connections can be detected and &illed by >?G+et if you specify the >?+E#.EO*I3E7#I(EUn parameter in your >?+E#.O3" file (usually in `O3"8?E7AO(E2networ&2admin). #his parameter will instruct >?G+et to send a probe through the networ& to the client every n minutes, if the client doesn\t respond, it will be &illed. +O#E0 #his parameter is only useful on the database server side, specifying it on a client wor&station will have no effect. Nac& to top of file What are inband and out of band brea&s6 %ata e)ceptions li&e 8ontrol58 can be transmitted as part of the regular data stream (inband) or as a separate asyncronious message (outband). Obviously outband brea&s are much faster as they can interrupt the flow of data. Out Of Nound Nrea&s (OON) are enabled by default. One can disable OON from the >?+E#.O3" file0 %I "N?E7OONUon Nac& to top of file What can be done to increase >?G+et performance6 1. While a >? statement is running >?G+et polls the client continuously to catch 8O+#3O?58 situations. #his results into a lot of poll and fstat system calls. #he following >?+E#.O3" parameter can be specified to reduce polling overhead on your system0 N3E"B7*O??7 BI*Un Q +umber of pac&ets to s&ip between chec&ing for brea&s (defaultU:) 4. *respawned server sessions. Hou can tell the listener to start up a pool of idle server processes. When a connection re/uest is made, it doesn\t have to start a server process. it Just hands one of the idle processes to the client (and then starts a new connection in its own time). #his is configured in ?I #E+E3.O3", in the I%7?I #7?I #E+E3 section, as follows0 I%7?I #7?I #E+E3 U ( I%7?I # U ( I%7%E 8 U ( I%7+"(E U your I%)

(*3E *"W+7("O U ;L) (*3E *"W+7?I # U (*3E *"W+7%E 8 U (*3O#O8O? U #8*) (*OO?7 IZE U ;) (#I(EO-# U 4)))) ) *3E *"W+7("O0 if there are over ;L sessions connected to the database, the listener won\t prespawn any more. *OO?7 IZE0 the listener will maintain an idle pool of ; server processes. #I(EO-#0 after a client disconnects, the listener will &eep the freed5up server process around for two minutes, waiting for a new connection re/uest, before &illing that process. 9. (ultiple listeners with load balancing. Hou can start multiple listeners on a server, and reference all of the listeners in the #+ +"(E .O3" file. When a client ma&es a connection re/uest, the >?G+et client will randomly pic& one of the listeners to contact. In ?I #E+E3.O3", specify multiple listeners as in0 Q %efine listener "... #"3#-*7W"I#7#I(E7?I #E+E37" U L 8O++E8#7#I(EO-#7?I #E+E37" U 1L ?I #E+E37"U ("%%3E 7?I # U ("%%3E U (*3O#O8O? U #8*) (AO # U yourAost.domain) (*O3# U 1;41))) I%7?I #7?I #E+E37" U ( I%7?I # U ( I%7%E 8 U ( I%7+"(E U your I%) (*3E *"W+7("O U ;L))) Q %efine the second listener... #"3#-*7W"I#7#I(E7?I #E+E37N U L 8O++E8#7#I(EO-#7?I #E+E37N U 1L ?I #E+E37NU ("%%3E 7?I # U ("%%3E U (*3O#O8O? U #8*) (AO # U yourAost.domain) (*O3# U 1;44))) I%7?I #7?I #E+E37N U ( I%7?I # U ( I%7%E 8 U ( I%7+"(E U your I%) (*3E *"W+7("O U ;L))) #he #+ +"(E .O3" service for this database would be something li&e0 oradb1.world U (description7listU (descriptionU (address7listU (addressU (protocolUtcp) (hostUyourAost.domain)

(portU1;41))) (connect7data U (sid U your I%))) (description U (address7list U (addressU (protocolUtcp) (hostUyourAost.domain) (portU1;44))) (connect7data U (sid U your I%)))) Nac& to top of file 8an one get connected to a system regardless of machine failure6 Hou can place multiple address entries for a single connection alias in the #+ +"(E .O3" file. #his means that you can connect to a database, even if some &ind of physical failover occurred. ?oo& at the following e)ample0 oradb1 U (%E 83I*#IO+ U ("%%3E 7?I # U ("%%3E U (8O((-+I#H U #8*78O(() (*3O#O8O? U #8*) (AO # U (achineL1)) ("%%3E U (8O((-+I#H U #8*78O(() (*3O#O8O? U #8*) (AO # U (achineL4))) (8O++E8#7%"#"U( ( I%Uoradb1)))) uppose (achineL1 is down, then every new >?G+E# connection using service oradb1 will automatically login to (achineL4. Aowever, there is one restriction, the I% must be the same on both machines. #his feature can provide guaranteed login for application servers and for the Oracle *arallel erver. Nac& to top of file 8an one grant or restrict access to a system via >?G+et6 Hes, create a protocal.ora file li&e this0 tcp.validnode7chec&ing U yes tcp.invited7nodes U (www.orafa/.org,19K.1I;.;.111) tcp.e)cluded7nodes U (199.1C.1;.41) Nac& to top of file Where can one get more info about >?G+et2 +etI6 >?G+E# 15459 %ownload >?G+et ,4 ?ight for %O Nac& to top of file

Aow does one setup an Oracle +ames erver 8reate a domain database0 3un script `O3"8?E7AO(E2networ&2admin2namesins.s/l =rom a WindowsK)2 +# wor&station, start the Oracle +etI "ssistant and configure =or server start the names server0 namesctl start Nac& to top of file Aow to get your listener to register itself with the +ames erver6 Edit your ?I #E+E3.O3" file and add a line - E7*?-!"+%*?"H7listener7nameUO+ for each listener defined on your machine. econdly, assign a !?ON"?7%N+"(E parameter for each listener. ample ?I #E+E3.O3" file0 - E7*?-!7"+%7*?"H7?I #E+E3 U O+ ?I #E+E3 U ("%%3E 7?I # U ("%%3E U (*3O#O8O?UI*8) (BEHU wblp5nt5L11b7orcl.companyO.com) ) ("%%3E U (*3O#O8O?UI*8) (BEHU orcl) ) ("%%3E U (8O((-+I#H U #8*I*.companyO.com) (*3O#O8O? U #8*) (Aost U wblp5nt5L11b.companyO.com) (*ort U 1;4@) ) ) #"3#-*7W"I#7#I(E7?I #E+E3 U L 8O++E8#7#I(EO-#7?I #E+E3 U 1L #3"8E7?E,E?7?I #E+E3 U O== I%7?I #7?I #E+E3 U ( I%7?I # U ( I%7%E 8 U (!?ON"?7%N+"(E U wblp5nt5L11b7orcl.companyO.com) ( I%7+"(E U orcl) (O3"8?E7AO(E U 2) (*3E *"W+7("O U 1L) ) ) Nac& to top of file Aow does one register an Oracle +ames erver Entry6 Oracle +ames erver entries are normally entered from the Oracle +etwor& (anager (,C) or the Oracle +etI "ssistant. Noth these tools run from your des&top. Hou can also manually register an entry on your server using the +"(E 8#? command. Eg0 +"(E 8#?P register mydb.world 5t oracle7database 5d

(descriptionU(addressU(protocolUtcp)(hostU149.:;.@C.I)(portU1;4@))(connect7dataU(sidU(H%N))) +O#E0 the whole command must be entered on one line. "lso, ma&e sure you register this database with all +ames ervers running in your domain. #o chec& if your entry is correctly recorded in the +ames erver, issue this command0 +"(E 8#?P /uery mydb.world G Nac& to top of file Aow can I chec& if a listener registered itself with the +ames erver6 Issue the ? +38#? command and type either E3,I8E or #"#- . If the listener successfully registered itself with the Oracle +ames server you will notice the &eyword ]3egistered] ne)t to the service name. E)ample0 ervices ummary... oraweb(3egistered) has 1 service handler(s) Nac& to top of file What is the 8onnection (anager and what is it good for6 #he Oracle 8onnection (anager (8(an) is a +etI process that relays networ& traffic to a different address, and optionally changes its characteristics. #he 8onnenction manager is commonly used for the following0 8onnenction 8oncentration "ccess 8ontrol (ultiprotocol upport *rovide Tava applets to connect to a database that is not on the machine the Tava applet was downloaded from. Nac& to top of file Aow does one configure the 8onnection (anager6 #he 8("+.O3" file specify 8onnection (anager configuration details. ?oo& at this sample 8("+.O3" file0 8("+ U ("%%3E U(*3O#O8O?Utcp)(AO #U1:1.1:;.I9.:)(*O3#U1@1L)) 8("+7"%(I+ U ("%%3E U(*3O#O8O?Utcp)(AO #U1:1.1:;.I9.:)(*O3#U1@;L))

8("+73-?E U (3-?E7?I # U (3-?E U ( 38U1:1.1:;.G.G) Q Wildcard is ])] (% #U1:1.1:;.G.G) ( 3,Ued49) ("8#U"88) )) 8("+7*3O=I?E U (*"3"(E#E37?I #U (("OI(-(73E?"H UI) Q %efault is normally too small (?O!7?E,E?U1) (#3"8I+!U+O) ( AOW7#+ 7I+=OUHE ) (3E?"H7 #"#I #I8 U+O) ) Nac& to top of file

Aow does one route data through the 8onnection (anager6 8ode a #+ +"(E .O3" entry with two addesses. #he first addres specifies the address 8( is listening on (coded in 8("+.O3"). #he socond is the address the traffic must be routed to. Hou also need to specify O-38E73O-#EUHE . E%497cman U (%E 83I*#IO+ U ("%%3E 7?I # U ("%%3E U(*3O#O8O?U#8*)(AO #U1:1.1:;.I9.:)(*O3#U1@1L)) ("%%3E U(*3O#O8O?U#8*)(AO #U'aedu4.'a.oracle.com)(*O3#U1K49)) ) (8O++E8#7%"#" U ( E3,I8E7+"(E U ed49) ) ( O-38E73O-#E U HE ) ) Nac& to top of file 7
0 comments

Oracle >recompiler FAQ


What is a precompiler and what is it good for6 " precompiler is a tool that allows programmers to embed >? statements in a high5level source program. #he precompiler accepts the source program as input, translates the embedded >? statements into standard Oracle runtime library calls, and generates a modified source program that you can compile, lin&, and e)ecute in the usual way. e)amples are *roG8 *recompiler for 8, *roG8obol for 8obol and >?T for Tava etc. Nac& to top of file What languages are supported6 #he following 9!? languages are supported by the Oracle precompilers0 Aost ?anguage0 =ile E)tention0 *roG 8ONO? G.*8O *roG "da G.*"% *roG =ortran G.*=O *roG 8 (8VV included) G.*8 *roG *?2I G.**? *roG *ascal G.**" *lease note that OracleI does not support *ascal, *?2I and "da. =or Tava related issues, visit the T%N82T >? =">. Nac& to top of file What is the difference between O8I and the *recompilers6 #he Oracle O8I (Oracle 8all Interface), is an alternate low5level interface to the Oracle database. #he >? precompilers for the various host languages (*roG8, *roG"da, *roG=ortran, *roG8ONO?, etc.) reads EOE8 >? commands and generate data structures and calls to its runtime library0 >??IN (libs/l.a in -+IO). >??IN, in turn, calls the -ser *rogram Interface (-*I) to communicate with the database. It does not generate calls to the Oracle 8all Interface (O8I) but you can mi) O8I and *recompiler calls.

=or more info about the Oracle 8all Interfaces, see the O8I =">. Nac& to top of file hould I use *roG8 ,1 or ,46 #ry to ma&e the switch to version 4.L as soon as possible. tarting with OracleC release C.9, it will be the only version available. #he support matri)0 %atabase ,ersion0 *roG8 ,ersion0 C.L 1.; C.1 1.@ and 4.L C.4 1.@ and 4.1 C.9 4.4 I.) I.) Necause *roG8 4.) behaves differently from *roG8 1.), and to ease migration, both versions of *roG8 were shipped with C.1 and C.4. I recommend using 4.) or higher for any new development. Hou can use the *"3 EU*"3#I"? or *"3 EU+O+E options to get behavior similar to version 1.). Nac& to top of file Aow does one compile a precompiler program6 #he following synta) is used to precompile a *roG8 program0 proc inameUmyprog.pc hostU8 Oracle includes some sample precompiler programs with it\s installation. #hese are normally located under the `O3"8?E7AO(E2precomp2demo2proc (or related) directories. "fter you\ve precompiled your program, invo&e the standard host language compiler and lin&er. "lso remember, if you modify your source code, change the original precompiled source program. In 8, for e)ample, you would modify the G.*8 file and not the G.8 file. #he G.8 file gets overwritten every time you precompile your program. ?oo& at the following table for other host languages0 ?anguage0 *rogram0 *recompiler0 *recompiled to0 8 G.pc proc G.c 8ONO? G.pco procob G.cob =O3#3"+ G.pfo profor G.for *" 8"? G.ppa propas G.pas "%" G.pad proada G.ada Nac& to top of file Aow does one compile a *3OG8 program6 Hou can study the sample ma&efile provided by Oracle and construct your own, but it would probably be better to Just use ]ma&e] to precompile and then compile your program in one step. ?oo& at this -ni) e)amples0 OracleC0 ma&e 5f `O3"8?E7AO(E2precomp2demo2proc2proc.m& build EOEUmyprog ONT Umyprog.o OracleI0 ma&e 5f `O3"8?E7AO(E2precomp2demo2proc2demo7proc.m& build EOEUmyprog ONT Umyprog.o +O#E0 ONT and EOE has to be entered in caps___ Nac& to top of file

Aow can I tell *roG8 what directory my header files are in6 Is there some way to tell the *roG8 preprocessor to search other directories for include (G.h) files, similar to the 8 compiler switch ]5I]6 I am hoping to avoid having to change all of my Qinclude statements... "s documented in the *roG8 manual (in the chapter called ]3unning the *recompiler]) there is a I+8?-%E flag that can be used for this. ?oo& at this e)ample0 proc inameUinputfile.pc includeUdirectory1 includeUdirectory4... Nac& to top of file What is an indicator variable and why should I use it6 Indicator variables are used to e)plicitly handle +-?? values. When you E?E8# or =E#8A a +-?? value into a host variable2array an ]O3"5L1:L;0 fetched column values is +-??] run5time error will result. #his behaviour was introduced with OracleC when you recompiled your programs with the %N( U,C (the default) precompiler option. One wor&around for this is to use the +,?() function to prevent the selection of +-?? values. E)ample0 EOE8 >? E?E8# E+"(E, "?, 8O(( I+#O 0emp7name, 0emp7sal, 0emp7comm0comm7indicator =3O( emp. if (comm7indicator UU 51) pay U emp7sal. else pay U emp7sal V emp7comm. Nac& to top of file Aow does one e)ecute *?2 >? code from *roG86 E)ample0 EOE8 >? EOE8-#E begin dbms7application7info.set7client7info(\(y 8 *rogram with embedded *?2 >?\). end. E+%5EOE8. Nac& to top of file Where can I get more info about the Oracle *recompilers6 Oracle *recompilers 5 Online %ocumentation Oracle *recompilers #echnical Nulletins Nac& to top of file
0 comments

Oracle OD#C Connecti'ity FAQ


What is O%N8 and where does it come from6 O%N8 (Open %atabase 8onnectivity) provides a way for client programs (eg ,isual Nasic, E)cel, "ccess, >VE etc) to access a wide range of databases or data sources. O%N8 is a standardi'ed "*I, developed according to the specifications of the >? "ccess !roup, that allows one to connect to >? databases. It defines a set of function calls, error codes and datatypes that can be used to develop database independent applications. O%N8 is usually used when database independance or simultaneous access to different data sources is re/uired.

"re there alternative products that can be used6 Hes, loo& at Oracle ObJects for O?E (OO:O).

Where can I get O%N8 drivers for OracleC2I and Oracle 3db6 #he Oracle O%N8 drivers can be downloaded, free of charge, from the Oracle home page. #here is also a free, open source O%N8 driver available from http022www.easysoft.org2. If you are still using Oracle ,@, you can use the O%N8 driver that comes with (icrosoft "ccess 1.1 or an e/uivalent driver from whatever source. ince O%N8 is a standard, there are alternative drivers available via other vendors. #he following vendors provide O%N8 drivers that can run from Windows and -ni)0 InterNase oftware 8orp. Open?in& oftware (erant (formerly Intersolv) imbaE)press etc... +ote0 If you plan to use a 1@5bit application with O%N8 (even if it is running on WindowsK; or Windows +#), you will need to use a 1@5bit Windows 9.1 O%N8 driver.

What do I need to get O%N8 to wor&6 " wor&ing Oracle O%N8 stac& loo&s li&e this0 V55555555555555555555V ,isual Nasic, E)cel, "ccess, d O%N8 "pplication d Oracle *ower ObJects, etc. V55555555555555555555V d V55555555555555555555V d %river (anager d #his is O%N8.%?? V55555555555555555555V d V55555555555555555555V #his is the Oracle O%N8 %river d O%N8 %river d ( >O3"C).%?? or >O947C).%??) or V55555555555555555555V driver for a different data source2 vendor d V55555555555555555555V Oracle\s >?G+et (only for remote database) d %atabase #ransport d or other database transport V55555555555555555555V d V55555555555555555555V #8*2I* or d +etwor& #ransport d other protocol driver V55555555555555555555V (optional 5 only for remote connections) d V55555555555555555555V Hour Oracle database or d %ata ource d other data source you connect to V55555555555555555555V

%o I need >?G+et to connect to Oracle via O%N86 =or Oracle\s O%N8 drivers, HE . ome multi5tier O%N8 drivers (eg. Openlin& and ,isionware) do not re/uire >?G+et on the client as one has to install an \O%N8 server component\ on the server. #he O%N8 drivers then use the underlying networ& protocol (eg. #8*2I*) without using >?G+et.

Aow do I create a %ata ource6 " data source is a logical name for a data repository or database. #o define a data source, open the O%N8 manager by double clic&ing on the O%N8 icon in the 8ontrol *anel. elect the ]add] button, then select the O%N8 %river for the database you want to connect to. #he data source definition screen will appear. %efine the data source name and other information as it pertains to your configuration.

What O%N8 8onformance ?evel is supported by Oracle6 O%N8 provides : conformance levels depending upon how much of the O%N8 specification is implemented in the driver. #he levels are0 8O3E "*I ?E,E? 1 ?E,E? 4 ?E,E? 9 5 latest spec. #he OracleC O%N8 driver supports O%N8 ,ersion 4.; and 9.L ?evel 4 only. Oracle does not support ?evel 9 O%N8, but ?evel 1 is all that is necessary to do standard operations. If you develop applications that will run on different databases, you might want to limit yourself to level 1 O%N8 calls.

hould I give O%N8 to my end5users6 It all depends... for performance reasons I would not allow end5users to access an O?#* (On5line #ransaction *rocessing) system via O%N8. 3ather, setup a %ata Warehouse or %ata (art and let users enter their ]/ueries from hell] against that database.

Aow secure is O%N86 "ny O%N8 sniffer will be able to trace everything from an O%N8 perspective. #his includes data, usernames, passwords etc. Aowever, if you are using an O%N8 driver that provides encryption, you can increase your level of security. ince any front5end tool can effectively connect to and modify your databases, you need to enforce security at the server level. On the other hand, if you use #8*2I*, O%N8 security should be the least of your concerns___

Aow fast is O%N86

"ccording to Oracle, their O%N8 driver, on average, runs about 9F slower than native Oracle access. (y e)perience, however, is that O%N8 can be e)tremely slow___

Aow can I test if O%N8 is setup correctly6 E)ecute the O%N8# #.EOE program that comes with your O%N8 driver to ensure that all your connections are properly configured and that you can connect to your data source.

Aow can I trace O%N8 calls6 #he (icrosoft O%N8 "dministrator ((y 8omputer2 8ontrol *anel2 O%N8) provides a simple O%N8 call trace that logs O%N8 calls to a file. #o use this facility, clic& the Options button on the initial %ata ources form. 8hec& the bo) labeled ]#race O%N8 8alls] and change the default log filename ( >?.?O!) if desired. #he underlying O%N8 calls the front5end application ma&es to communicate with the O%N8 %river will be logged to this file. peciali'ed O%N8 trace programs, such as (icrosoft\s O%N8 py (included in the O%N8 %B 4.L), O%N8 Inspector and O%N8 "gent can be used to capture detailed O%N8 call information and the return code for each call.

Aow do I tell which driver version I have installed6 3un the O%N8 administrator from the des&top (O%N8"%(.EOE or O%N8"%94.EOE)0 8lic& the ]%rivers] button 8hoose the desired O%N8 driver 8lic& the ]"bout] button ,ersion information will be displayed for the selected driver.

What is >?*" #A3O-!A6 -se the O%N8 >?*" #A3O-!A option when you need to pass your >? statement to the O%N8 data source directly. +o massaging or local processing is done on the statement, it is passed to the database server " I . #his improves performance, but the resulting dynaset is not updatable. E)ample0 db.E)ecute >?(]NE!I+ procedurename(param1,param4,param9). E+%.], >?*" #A3O-!A)

Aow does one attach an Oracle table in ( 5"ccess6 8reate a lin&ed table under the table tab in "ccess. 3ight clic&. select lin& table. " dialog bo) opens, at the bottom, change the ]files of type] bo) to O%N8 %atabases. #his will open the %ata ource dialog bo). elect your data source, file or machine (note the type you created earlier). Hou will now be prompted to login to the Oracle database. One can also lin& a table programmatically. Open a new (O%-?E in "ccess, add this code to it and 3-+ (=;)0 Option 8ompare %atabase Option E)plicit =unction "ttach#able() "s ,ariant

On Error !o#o "ttach#able7Err %im db "s %atabase %im tdef "s #able%ef %im str8onnect "s tring et db U 8urrent%b() str8onnect U ]O%N8.% +Uoraweb.%N>U/it5u/5cbiw7oraweb.%"#"N" EU] \ +O#E0 % + is your O%N8 %ata ource +ame. %N> is your #+ +"(E .O3" entry name et tdef U db.8reate#able%ef(](H7"88E 7#"N?E+"(E]) \ tdef."ttributes %N7"##"8AE%O%N8 tdef.8onnect U str8onnect tdef. ource#able+ame U ](H7O3"8?E7#"N?E+"(E] db.#able%efs."ppend tdef "ttach#able7E)it0 E)it =unction "ttach#able7Err0 (sgNo) ]Error0 ] < tr(Err) < ] 5 ] < Error` < ] occured in global module.] 3esume "ttach#able7E)it End =unction

Aow does one get Oracle data into ( 5E)cel6 #here are several ways to e)tract Oracle data from (icrosoft E)cel. ?oo& at these methods0 =rom s/lplus, spool records into a file, then import into E)cel. Eg0 set echo off pagesi'e L head off feed off veri off trimspool on spool data.t)t select 8O?1 dd \,\ dd 8O?4 dd \,\ dd 8O?9 .... spool off ?oad Oracle ObJects for O?E (OO:O) on your *8. ee the OO:O ="> for more details. %ownload Ora)cel ?ite, a freeware plug5in used to run >? statements directly from E)cel. Ora)cel re/uires OO:O to be installed on your *8.
0 comments

Oracle O(Hects -or O/, )OOIO) FAQ


What is Oracle ObJects for O?E6 Oracle ObJects for O?E (OO:O) is a middleware product manufactured by Oracle 8orporation that allows native access to OracleC databases from client applications via the (icrosoft O?E (ObJect ?in&ing and Embedding) standard. OO:O\s predecessor was called Oracle !lue. Oracle ObJects consists of the following three components0 "n O?E 4.L "utomation (In*rocess) erver 5 #his provides an O?E "utomation interface to applications that support O?E automation scripting such as ,isual Nasic (,N) "n Oracle %ata 8ontrol 5 #his is the ,isual Nasic custom control (,NO) #wo 8VV 8lass ?ibraries 5 85?ibraries for (icrosoft =oundation 8lasses ((=8) and Norland (OW?)

Aow does OO:O compare to O%N86 OO:O provides native access to Oracle and only Oracle databases. It is faster than O%N8 access but one can use O%N8 to connect to a variety of data sources. ince OO:O closely follows the O%N8 /uery interface model, one can retain over K;F code compatibility between the OO:O and O%N8 versions of the data layer procedures. #his translates to very short retooling times in porting between the two products. 8an I use OO:O to access Oracle data from (icrosoft applications6 Hes, you can use OO:O from any (icrosoft application that uses the ,N5style macro language. #his includes ,isual Nasic, E)cel, and ( 5"ccess. Aow does one connect to an Oracle %atabase6 ub =orm7?oad () %im Ora ession "s ObJect \%eclare variables as O?E ObJects %im Ora%atabase "s ObJect %im Ora%ynaset "s ObJect et Ora ession U 8reateObJect(]OracleIn*roc erver.OOra ession]) et Ora%atabase U Ora ession.%bOpen%atabase(] >?G+et78onnect7 tring], ]scott2tiger], L<) (sgNo) ]8onnected to ] < Ora%atabase.8onnect < ]c] < Ora%atabase.%atabase+ame \8reate the Ora%ynaset ObJect and display the first value et Ora%ynaset U Ora%atabase.%b8reate%ynaset(]select empno, ename from emp], L<) (sgNo) ]Employee ] < Ora%ynaset.=ields(]empno]).value < ], Q] < Ora%ynaset.=ields(]ename]).value End ub What are the maJor ,N2O%N8 limitations that OO:O overcomes6 (=rom the Oracle ObJects #echnical Overview by Beith (aJ&ut)0 ,isual Nasic 9.L database access is not very client2server oriented. In fact, the ,isual Nasic database access is really designed for flatfile databases, but ,isual Nasic can use O%N8 to access >? databases. -nfortunately, ,isual Nasic, by default, ma&es use of a local >? engine, called TE# to process /ueries (using the ( TE# >? implementation, +O# Oracle\s). Hou may bypass the TE# engine (using something called >?*" #A3O-!A, which causes the >? to be sent directly to the database), but doing so causes your dynaset to be read5only. Hou would then have to update data by constructing >? insert2delete2update statements. Hou would not be able to use the built in "dd+ew, %elete and -pdate methods. (+ote0 >? statements cannot contain te)t data P 94B and cannot contain binary data.) #he drawbac&s of the ,N2TE#2O%N8 combination are many0 3ows are accessed via a primary &ey (uni/ue inde)). Hour table (- # contain a uni/ue inde), or else the resulting dynaset will +O# be updatable. #his is an O%N8 feature related to the fact that O%N8 is based on (icrosoft\s >? erver. When a dynaset is created, only the primary &eys are fetched. rows are not fetched until they are needed. #his sounds reasonable until you reali'e that it results in multiple /ueries and many trips to the server. When a snapshot is created, all rows are immediately fetched. #his could potentially be millions of rows. #able Joins are performed locally. "lthough views and synonyms can be used, they will cause your dynaset to be read5only. 8olumn aliases and schema references (such as ] 8O##.E(*]) cannot be used without >?*" #A3O-!A. ObJect names are referenced in -**E3 case unless you use >?*" #A3O-!A. #his only wor&s for the (default) Oracle setting of case5insensitive obJects. #here is no support for >? bind variables (i.e. ] E?E8# G =3O( E(* WAE3E E+"(E U 0name]). If the value of your variable changes, you need to recreate the >? statement and dynaset. #his means that the

server must reparse the /uery and refetch the data. #here is no support for *?2 >? bind variables (in2out parameters). #he wor&around is to pass values in as literals, and store the return values in a temporary table that you can then /uery on to get the results. (ultiple data controls (or database opens) use multiple database connections, even if they all reference the same account on the same database. #his can be a serious problem with databases that have a limit on the total number of connections they will accept. Oracle ObJects has no such drawbac&s0 3ows are accessed via their rowid. If a rowid can be obtained, then the data is updatable. When creating a dynaset, some data is initially fetched and cached locally. %ata is fetched and stored locally as needed, as rows are traversed. "dmittedly, this can lead to a large local data cache, so many tunable cache parameters are provided to improve performance. napshots have not been implemented, since a read5only dynaset is a reasonable e/uivalent. #able Joins are performed by the server. ,iews, synonyms, column aliases and schema references can be used freely. #he updatability of database obJects is only dependent >? updatability rules and on the access you have been granted . ObJects names are not modified in any way. Hou may use upper or lower case in the names, which are case5 insensitive. upport for >? bind variables (i.e. ] E?E8# G =3O( E(* WAE3E E+"(E U 0name]) is offered via the *arameters collection. #he server does not have to reparse the /uery before refetching data. upport for *?2 >? bind variables is offered (in2out vars) via the *arameters collection. (ultiple data controls (or database opens) referencing the same account on the same database will all share a single Oracle connection. "t first, the ,N2TE#2O%N8 limitations may not sound serious, but consider a typical production Oracle environment where most users only have access to data via synonyms and views. #his means that ,N2TE#2O%N8 users can only read, not write data.

Das könnte Ihnen auch gefallen