Example1:
DECLARE
V_EMPNO NUMBER(4);
BEGIN
SELECT EMPNO INTO V_EMPNO FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(V_EMPNO);
END;
Example2:
DECLARE
V_EMPNO NUMBER(4);
V_ENAME VARCHAR2(20);
V_JOB VARCHAR2(15);
BEGIN
SELECT EMPNO,ENAME,JOB INTO V_EMPNO,V_ENAME,V_JOB FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(V_EMPNO || CHR(9)|| V_ENAME ||CHR(9) ||V_JOB);
END;
Example3:
DECLARE
V_EMPNO NUMBER(4);
V_ENAME VARCHAR2(10);
V_JOB VARCHAR2(9);
BEGIN
SELECT EMPNO,ENAME,JOB INTO V_EMPNO,V_ENAME,V_JOB FROM EMP;
DBMS_OUTPUT.PUT_LINE(V_EMPNO||CHR(9)||V_ENAME||CHR(9)||V_JOB);
EXCEPTION
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE('TOO MANY ROWS');
END;
Example4:
DECLARE
V_EMPNO EMP.EMPNO%TYPE;
V_ENAME EMP.ENAME%TYPE;
V_JOB EMP.JOB%TYPE;
V_MGR EMP.MGR%TYPE;
V_HIREDATE EMP.HIREDATE%TYPE;
V_SAL EMP.SAL%TYPE;
V_COMM EMP.COMM%TYPE;
V_DEPTNO EMP.DEPTNO%TYPE;
BEGIN
SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
INTO V_EMPNO,V_ENAME,V_JOB,V_MGR,V_HIREDATE,V_SAL,V_COMM,V_DEPTNO
FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(V_EMPNO||CHR(9)||V_ENAME||CHR(9)||V_JOB);
END;
Example5:
DECLARE
EMP_REC EMP%ROWTYPE;
BEGIN
SELECT * INTO EMP_REC FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(EMP_REC.EMPNO || CHR(9)|| EMP_REC.ENAME ||CHR(9) ||EMP_REC.JOB);
END;
DECLARE
V_EMPNO NUMBER(4);
BEGIN
SELECT EMPNO INTO V_EMPNO FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(V_EMPNO);
END;
Example2:
DECLARE
V_EMPNO NUMBER(4);
V_ENAME VARCHAR2(20);
V_JOB VARCHAR2(15);
BEGIN
SELECT EMPNO,ENAME,JOB INTO V_EMPNO,V_ENAME,V_JOB FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(V_EMPNO || CHR(9)|| V_ENAME ||CHR(9) ||V_JOB);
END;
Example3:
DECLARE
V_EMPNO NUMBER(4);
V_ENAME VARCHAR2(10);
V_JOB VARCHAR2(9);
BEGIN
SELECT EMPNO,ENAME,JOB INTO V_EMPNO,V_ENAME,V_JOB FROM EMP;
DBMS_OUTPUT.PUT_LINE(V_EMPNO||CHR(9)||V_ENAME||CHR(9)||V_JOB);
EXCEPTION
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE('TOO MANY ROWS');
END;
Example4:
DECLARE
V_EMPNO EMP.EMPNO%TYPE;
V_ENAME EMP.ENAME%TYPE;
V_JOB EMP.JOB%TYPE;
V_MGR EMP.MGR%TYPE;
V_HIREDATE EMP.HIREDATE%TYPE;
V_SAL EMP.SAL%TYPE;
V_COMM EMP.COMM%TYPE;
V_DEPTNO EMP.DEPTNO%TYPE;
BEGIN
SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
INTO V_EMPNO,V_ENAME,V_JOB,V_MGR,V_HIREDATE,V_SAL,V_COMM,V_DEPTNO
FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(V_EMPNO||CHR(9)||V_ENAME||CHR(9)||V_JOB);
END;
Example5:
DECLARE
EMP_REC EMP%ROWTYPE;
BEGIN
SELECT * INTO EMP_REC FROM EMP WHERE ENAME='KING';
DBMS_OUTPUT.PUT_LINE(EMP_REC.EMPNO || CHR(9)|| EMP_REC.ENAME ||CHR(9) ||EMP_REC.JOB);
END;
No comments:
Post a Comment