chandra shekhar


{ City } london
< Country > united kingdom
* Profession *
User No # 50474
Total Questions Posted # 0
Total Answers Posted # 6

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 34
Users Marked my Answers as Wrong # 14
Questions / { chandra shekhar }
Questions Answers Category Views Company eMail




Answers / { chandra shekhar }

Question { iFlex, 5780 }

write a procedure to print a statement or number not
using "dbms_output.put_line" package.write a procedure
instead of it using procdure name as "print"
ex:-

declare
a number:=2;
begin
print(a);
end;
/* when U type above procedure 2 have to should be printed*/


Answer

As you said that DBMS_OUTPUT.PUT_LINE should not be used in given piece of your program, so it can be done by creating a procedure by name print as follows

create or replace procedure print(n number)
as
begin
dbms_output.put_line(n) ;
end ;

and then executing your piece of code i.e.

declare
a number:=2;
begin
print(a);
end;

Hope this is what u r question reflects ?

Is This Answer Correct ?    3 Yes 2 No

Question { Oracle, 9197 }

What are the attributes of SQL*PLUS ?


Answer

Dear Pushkar, SQL*PLUS commands are not used to manipulate the data in tables. Its DML commands in SQL are used to manipulate the date in the table like INSERT, UPDATE, DELETE, MERGE.

Table definition commands comes under DDL commands like CREATE, ALTER, DROP, TRUNCATE.

Some of the Attributes of SQL*PLUS commands are
1. It need not be terminated by semi colon
2. It can be abbreviated
Eg:- DESCRIBE can be written as DESC
APPEND can be written as a
RUN can be written as r

regards
j

Is This Answer Correct ?    11 Yes 0 No


Question { HP, 5084 }

cursor types? explain with example programs?


Answer

Cursor Types
- Implicit Cursor
- Explicit Cursor (Without parameters, With Parameters)


############################################
##### Implicit Cursor #####################
############################################

-- assuming there is a table emp in the schema
DECLARE
VENAME EMP.ENAME%TYPE ;
BEGIN
SELECT ENAME INTO VENAME FROM EMP WHERE EMPNO = &EMPLOYEENUMBER ;
IF SQL%FOUND THEN
DBMS_OUTPUT.PUT_LINE('EMPLOYEE NAME IS ' || VENAME);
END IF ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('NO EMPLOYEE WITH GIVE EMPLOYEE NUMBER ') ;
END ;
/

############################################
##### Explicit Cursor #####################
############################################

-- First method
===============

DECLARE
CURSOR C1 IS SELECT EMPNO, ENAME FROM EMP ;
BEGIN
FOR I IN C1
LOOP
DBMS_OUTPUT.PUT(I.EMPNO);
DBMS_OUTPUT.PUT_LINE(' -- ' || I.ENAME);
END LOOP ;
END ;
/

-- Second method
================

DECLARE
CURSOR C1 IS SELECT EMPNO, ENAME FROM EMP ;
E C1%ROWTYPE ;
BEGIN
OPEN C1 ;
LOOP
FETCH C1 INTO E ;
EXIT WHEN C1%NOTFOUND ;
DBMS_OUTPUT.PUT(E.EMPNO);
DBMS_OUTPUT.PUT_LINE(' -- ' || E.ENAME);
END LOOP ;
CLOSE C1 ;
END ;
/

-- With Parameters
==================

DECLARE
CURSOR C1(n number) IS SELECT EMPNO, ENAME FROM EMP where sal < n;
E C1%ROWTYPE ;
BEGIN
OPEN C1(&salary) ;
loop
FETCH C1 INTO E ;
exit when c1%notfound ;
DBMS_OUTPUT.PUT(E.EMPNO);
DBMS_OUTPUT.PUT_LINE(' -- ' || E.ENAME);
end loop ;
CLOSE C1 ;
END ;
/

Is This Answer Correct ?    4 Yes 1 No

Question { Cap Gemini, 13991 }

How will you delete a particular row from a Table?


Answer

Sorry guys this is not an answer to the asked question.
-- Just a small test --



TESTING THIS WEBSITE
All Interview website


Is This Answer Correct ?    2 Yes 5 No

Question { Satyam, 12062 }

how to eliminate null values in a column i.e
table vlaues
1 2 3
NULL 3 4
1 5 NULL
i want output like this
1 2 3
3 4
1 5
i dnt want to use nvl is null and i dnt want replace the
NULL value with any value i.e nvl(col,o);


Answer

Dear Lavanya,
You cannot equate the NULL with the operators like = and !=

NULLs can be equated with "IS NULL" or "IS NOT NULL"
(Double quotes " not included)

In u r query if u say IS NOT NULL, then also as per question asked in the very beginning it will not suffice.

As there are multiple columns with multiple NULLs in all the given columns .

Regards
J

Is This Answer Correct ?    3 Yes 1 No

Question { IBM, 10157 }

how to find the fifth highest salary?


Answer

Assuming that EMP table with Sal column

SELECT MIN(sal) FROM
(SELECT DISTINCT sal FROM emp WHERE
ROWNUM < 6
ORDER BY sal DESC )

- If fifth highest then ROWNUM < 6
- If n'th highest then ROWNUM < n+1

Regards
J

Is This Answer Correct ?    11 Yes 5 No