Sunday 15 January 2012

Select stmt queries


BBC Country Profiles

This tutorial introduces SQL as a query language. We will be using the SELECT command on the table bbc:
nameregionareapopulationgdp
AfghanistanSouth Asia65222526000000
AlbaniaEurope2872832000006656000000
AlgeriaMiddle East24000003290000075012000000
AndorraEurope46864000
...

Exercises

Using the SELECT statement.
1a.Read the notes about this table. Issue the command: SELECT name, region, population FROM bbc. Look at the output.

Well Done, that is correct.
nameregionpopulation
AfghanistanSouth Asia26000000
AlbaniaEurope3200000
AlgeriaMiddle East32900000
AndorraEurope64000
AngolaAfrica14500000
Antigua and BarbudaAmericas77000
ArgentinaSouth America39300000
ArmeniaEurope3000000
AustraliaAsia-Pacific20300000
AustriaEurope8100000
AzerbaijanEurope8500000
BahamasAmericas321000
BahrainMiddle East754000
BangladeshSouth Asia152600000
BarbadosAmericas272000
BelarusEurope9800000
BelgiumEurope10300000
BelizeAmericas266000
BeninAfrica7100000
BhutanSouth Asia2400000
BoliviaSouth America9100000
Bosnia-HercegovinaEurope4200000
BotswanaAfrica1800000
BrazilSouth America182800000
BruneiAsia-Pacific374000
BulgariaEurope7800000
Burkina FasoAfrica13800000
BurmaAsia-Pacific50700000
BurundiAfrica7300000
CambodiaAsia-Pacific14800000
CameroonAfrica16600000
CanadaNorth America32000000
Cape VerdeAfrica482000
Central African RepublicAfrica3900000
ChadAfrica9100000
ChileSouth America16200000
ChinaAsia-Pacific1300000000
ColombiaSouth America45600000
ComorosAfrica812000
Costa RicaAmericas4300000
CroatiaEurope4400000
CubaAmericas11300000
CyprusEurope807000
Czech RepublicEurope10200000
Democratic Republic of CongoAfrica56000000
DenmarkEurope5400000
DjiboutiAfrica721000
DominicaAmericas71000
Dominican RepublicAmericas9000000
East TimorAsia-Pacific857000
Results truncated...
Before attempting the following questions read this! How to use WHERE to filter records.
2a.Show the name for the countries that have a population of at least 200 million. (200 million is 200000000, there are eight zeros)

Well Done, that is correct.
NAME
China
India
Indonesia
United States of America
2b.Give the name and the per capita GDP for those countries with a population of at least 200 million.
per capita GDP is the GDP divided by the populationGDP/population

Well Done, that is correct.
NAMEGDP/POPULATION
China1290
India620
Indonesia1140
United States of America41400
2c.Show the name and population in millions for the countries of 'Middle East'
Divide the population by 1000000 to get population in millions.

Well Done, that is correct.
NAMEPOPULATION/1000000
Algeria32.9
Bahrain.754
Egypt74.9
Iran70.7
Iraq26.5
Israel and Palestinian territories3.8
Jordan5.7
Kuwait2.7
Lebanon3.8
Mauritania3.1
Morocco31.6
Oman3
Qatar.628
Saudi Arabia25.6
Sudan35
Syria18.6
Tunisia10
United Arab Emirates3.1
Yemen21.5
2d.Show the name and population for'France', 'Germany', 'Italy'

Well Done, that is correct.
NAMEPOPULATION
France60700000
Germany82500000
Italy57200000
2e.Identify the countries which have names including the word 'United'

Well Done, that is correct.
NAME
United Arab Emirates
United Kingdom
United States of America

Friday 13 January 2012

oracle solved paper-2


1. What is a visual attribute?

ANS:-Visual Attributes are the font, color and pattern characteristics of objects that operators see and interact with in our application.

2. What are the types of visual attribute settings?

ANS:-Custom Visual attributesDefault visual attributes ,Named Visual attributes.

3. What is a window?

ANS:-A window, by itself , can be thought of as an empty frame. The frame provides a way to interact with the window, including the ability to scroll, move, and resize the window. The content of the window ie. what is displayed inside the frame is determined by the canvas View or canvas-views displayed in the window at run-time.

4. What are the different types of windows?

ANS:-
Root window, secondary window.

5. Can a root window be made modal?

ANS:- No.

6. List the buil-in routine for controlling window during run-time?

Find_window,
get_window_property,
hide_window,
move_window,
resize_window,
set_window_property,
show_View

7. List the windows event triggers available in Forms 4.0?

ANS:-When-window-activated, when-window-closed, when-window-deactivated, when-window-resized

8. What built-in is used for changing the properties of the window dynamically?

ANS:- Set_window_property

9. What is a canvas-view?

ANS:-A canvas-view is the background object on which you layout the interface items (text-items, check boxes, radio groups, and so on.) and boilerplate objects that operators see and interact with as they run your form. At run-time, operators can see only those items that have been assigned to a specific canvas. Each canvas, in term, must be displayed in a specific window.

10. Give the equivalent term in forms 4.0 for the following. Page, Page 0?

ANS:-Page - Canvas-View
Page 0 - Canvas-view null.

11. What are the types of canvas-views?

ANS:-Content View, Stacked View.
12. What is the content view and stacked view?

ANS:-A content view is the "Base" view that occupies the entire content pane of the window in which it is displayed. A stacked view differs from a content canvas view in that it is not the base view for the window to which it is assigned

13. List the built-in routines for the controlling canvas views during run-time?

ANS:-Find_canvas
Get-Canvas_property
Get_view_property
Hide_View
Replace_content_view
Scroll_view
Set_canvas_property
Set_view_property
Show_view

14. What is an Alert?

ANS:-An alert is a modal window that displays a message notifies the operator of some application condition

15. What are the display styles of an alert?

ANS:-Stop, Caution, note

16. Can you attach an alert to a field?

ANS:- No

17. What built-in is used for showing the alert during run-time?

ANS:-Show_alert.

18. Can you change the alert messages at run-time? If yes, give the name of the built-in to change the alert messages at run-time.

ANS:-Yes. Set_alert_property.

19. What is the built-in function used for finding the alert?

ANS:-Find_alert

20. List the editors available in forms 4.0?

ANS:-Default editorUser defined editorssystem editors.

21. What built-in routines are used to display editor dynamically?

ANS:- Edit_text item , show_editor

22.. What is an Lov?

ANS:-A list of values is a single or multi column selection list displayed in a pop-up window

23. Can you attach an lov to a field at design time?

ANS:-Yes.

24:- Can you attach an lov to a field at run-time? if yes, give the build-in name.

ANS:-Yes. Set_item_proprety

25. What is the built-in used for showing lov at runtime?

ANS:-Show_lov

26. What is the built-in used to get and set lov properties during run-time?

ANS:-Get_lov_property , Set_lov_property

27. What is a record Group?

ANS:-A record group is an internal oracle forms data structure that has a similar column/row frame work to a database table

28. What are the different type of a record group?

ANS:-Query record groupStatic record groupNon query record group

29. Give built-in routine related to a record groups?

ANS:- Create_group (Function)
Create_group_from_query(Function)
Delete_group(Procedure)
Add_group_column(Function)
Add_group_row(Procedure)
Delete_group_row(Procedure)
Populate_group(Function)
Populate_group_with_query(Function)
Set_group_Char_cell(procedure)

30. What is the built_in routine used to count the no of rows in a group?

ANS:-Get_group _row_count

31. List system variables available in forms 4.0, and not available in forms 3.0?

ANS:-System.cordination_operation
System Date_threshold
System.effective_Date
System.event_window
System.suppress_working

32. System.effective_date system variable is read only True/False

ANS:- False
33. What is a library in Forms 4.0?

ANS:-A library is a collection of Pl/SQL program units, including user named procedures, functions & packages

34. Is it possible to attach same library to more than one form?

ANS:-Yes

35. Explain the following file extension related to library:- .pll,.lib,.pld?

ANS:-The library pll files is a portable design file comparable to an fmb form file
The library lib file is a plat form specific, generated library file comparable to a fmx form file
The pld file is Txt format file and can be used for source controlling your library files

36. How do you pass the parameters from one form to another form?

ANS:-To pass one or more parameters to a called form, the calling form must perform the following steps in a trigger or user named routine execute the create_parameter_list built_in function to programmatically. Create a parameter list to execute the add parameter built_in procedure to add one or more parameters list. Execute the call_form, New_form or run_product built_in procedure and include the name or id of the parameter list to be passed to the called form.

oracle solved paper-1


1.void main()
{
struct a
{
char ch[10];
char *str;
};
struct a s1={"Hyderabad","Bangalore"};
printf("\n%c%c",s1.ch[0],*s1.str);
printf("\n%s%s",s1.ch,s1.str);
getch();
}
Ans: HB, HyderabadBangalor
2. main(int argc,int *argv[])
{
int i;
for(i=1;i<argc;i++)
printf("\n%s%s",argv[i],(i<argc-1)?"":"");
return 0;
getch();
}
Ans: I work for oracle
3.void main()
{
int i,j,k;
for(i=0;i<3;i++)
k=sum(i,i);
printf("\n%d",k);
getch();
}
sum(s,t)
{
static int m;
m+=s+t;
return m;
}
Ans: 6
4.void main()
{
int i;
clrscr();
for(i=1;i<6;++i)
switch(i)
{
case 1:
case 2: printf("%d,",i++);break;
case 3: continue;
case 4: printf("%d,",i);
}
printf("%d",i);
getch();
}
Ans: 1,4,6
5.Which of the storage class(es) becomes the global variables for the entire Program
(A) Extern
(B) Static
(C) Auto
(D) Register
Ans: A
6. What is the output of the program
void main()
{
char s[]="oracle is the best";
char t[40];
char *ss,*tt;
while(*tt++=*ss++);
printf("%s",t);
getch();
}
// A. oracle is the best
// B. Core dump
// c. Error Message
// D. Goes into infinite loop
Ans: B. core dump (Garbage value)

7. What is the output of the program
void main()
{
int j[10]={9,7,5,3,1,2,4,6,9};
int i=1;
clrscr();
for(;i<9;i++)
printf("%d ",--j[i++]);
getch();
}
// A. 6,2,1,5
// B. 6,2,1,5,7
// c. Error Message
// D. core dump
Ans: A. 6,2,1,5
8. What is the output of the program
void main()
{
int i,j,k,n=5;
clrscr();
for(i=5;i>0;i--)
{
j=1<i;
k=n&j;
k==0?printf("0"):printf("1");
}
getch();
}
// A. 00011
// B. 11110
// c. 11001
// D. 11100
Ans: B. 11110
9.Which of the following storage class(es) became the global variable for the entire program
A. Extern
B. Static=20
C. Auto
D. Register
Ans: A
10.//What is the output of the program, if integer occupies 2 bytes memory?
union
{
int a;
char b;
char c[10];
}u1;
void main()
{
int l=sizeof(u1);
printf("%d",l);
getch();
}
// A. 13
// B. 10
// c. 16
// D. None of the above
Ans: B. 10
11.//What is the output of the program
void main()
{
fork();
printf(" Hello World");
getch();
}
// A. Hello World
// B. Hello World Hello World
// c. Error Message
// D. None of these
Ans: B
12. What is the output of the program
void main()
{
struct a
{
int i;
char *st1;
};
typedef struct a ST;
ST *str1;
str1=(ST*)malloc(100);
str1->i=100;
strcpy(str1->st1,"Welcome to Oracle");
printf(" %d%s\n",str1->i,str1->st1);
getch();
}
// A. core dump
// B. will not compile
// c. 100,Welcome to Oracle
// D. None of these
Ans: C
13. What is the output of the program
void main()
{
int i,j,k;
i=2;
j=4;
k=i++>j&2;
printf("%d\n",k);
if(++k && ++i<--j|| i++)
{
j=++k;
}
printf(" %d %d %d",i,-j--,k);
getch();
}
// A. 4,-3,2
// B. 5,-3,2
// c. 4,-2,2
// D. 5,-2,2
Ans: D
14.Which of the following is not true incase of Command line arguments
A. The argc parameter is used to hold the number of arguments in the = command line and is an integer
B. The argv parameter is a pointer to an array of a character = pointer and each one points to command line arguments
C. The argv[1] always point to program name
D. None of above
Ans: C
15. A function without any return type declares return=20
A. Integer
B. Float
C. Void
D. Syntax Error
Ans: A
16.What is the output of the program
#include<stdio.h>
#include<conio.h>
#define sqr(a) a*a
void main()
{
int a=10,b=1,c;
c=sqr(10+1);
printf("Sqr Root of (10+1)is %d",c );
getch();
}
// A. 121
// B. 21
// c. 13
// D. Syntax Error
Ans: B
17. What is the output of the program
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j=20;
clrscr();
for(i=1;i<3;i++)
{
printf("%d,",i);
continue;
printf("%d",j);
break;
}
getch();
}
// A. 1,20
// B. 1,20,1,20
// c. 1,2
// D. 1,2,20,20
Ans: c
18. What is the output of the program
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1*4/3-27%3^2+100*0.5-(4>3?1:2);
clrscr();
printf("%d",i);
getch();
}
// A. 49
// B. compile error
// c. 51
// D. 48
Ans: b
19. What is the output of the program
#include<stdio.h>
#include<conio.h>
void main()
{
char *st1[3]= {"Hello","World","Oracle"};
*st1=st1[2];
st1[1]=*st1;
free(st1[0]);
free(st1[1]);
clrscr();
printf("%s %s %s",st1,st1[1],st1[2]);
getch();
}
// A. Garbage Garbage Oracle
// B. oracle oracle oracle
// C. Hello World Oracle
// D. Core Dump:cannot Print after freeing the memory
Ans: D
20.Consider the following structure
Struct {
int data;
struct node *prev;
struct node *next;
}NODE;
NULL <-- 5 --> 8 --> 10 --> NULL
p <-- q <-- r=20
WHAT WILL BE THE VALUE OF r-->prev-->-->next-->data
?
A. 8
B. Null
C. 5
D. 10
Ans: 10
21. What will be the output of the fallowing SELECT statement ?
SELECT count(*)
FROM emp
Where exist (select 'X' From dept
Where dept_name ='Stores' and dept.dept_id=emp.dept_id)
A. select total number of employees belonging to department " stores "
B. select all employees belonging to department "X"
C. select all employees belonging to department "stores"
D. select total number of employees belonging to department "X"
22. Denormalisation is done to
A. Check for Data Integrity
B. Reduce Data Redundancy
C. Intoduce Security Check
D. Increase Query performance .
23. How many columns are retrived from this query:
SELECT address1 || ',' ||address2 ||','
||address2 "Address" FROM =
employee;
A. 3
B. 2
C. 1
D. 0
24. What is the is the result of the fallowing Code
Piece=20
Insert into table A value(a1):
CREATE TABLE B AS SELECT * FROM A;
ROLLBACK ;
A. Table B gets created with the row inserted in the first statement.
B. Table B is not created
C. Table B gets created , but no row gets inserted into Table A
D. Rollback throws up an exception .
25. The key word used in Oracle for string searching is
A. SOUNDEX
B. DECODE
C. LIKE
D. HAVING
26. What does the ROLLBACK statement will do in the fool segment of code
PROGRAM STARTS HERE
........
SOME DML STAT.
...SAVEPOINT1
SOME DML STAT.
...SAVEPOINT2
SOME DML STAT.
...ROLLBACK
A. Rollback Dml changes to savepoint 1
B. Rollback Dml changes to savepoint 2
C. Rollback Dml changes of the last DML ststs. just before = ROllback stats
D. Rollback DML changes to the place whre the program starts
27. Which clause u use to exclude the rows before grouping them?
A. Group By
B. Having
C. Where
D. Minus
28. Which of the following statements is not true about views?
A. you can create a index on views
B. Views do not have permanent data
C. Views can be based on one or more tables
D. Views can be dropped without dropping
tables
29 How many JION conditions are needed in JOIN query to avoid a Cartesian Product?
A. No of tables + 1
B. No of tables - 1
C. No of colums + 1
D. No of colums - 1
30. "An item could be either a component or spare ".
How can you represent this scenerio in a E-R=20
A. Subtype Relation
B. Arc Relation
C. Recursive Relation
D. Many to Many Relationscription