0% found this document useful (0 votes)
21 views4 pages

KCB

Uploaded by

ananthojuraju5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

KCB

Uploaded by

ananthojuraju5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

-----------

SQL> create or replace function ftwa(paccno in kcb_acc_tab.accno%type)


2 return number
3 is
4 vtwa number(10);
5 begin
6 select sum(amt) into vtwa from kcb_tran_tab
7 where accno = paccno and ttype='W' and
8 to_char(dot,'dd-mon-yy')=to_char(sysdate,'dd-mon-yy')
9 and
10 exists(select 'Jagadish' from kcb_acc_tab
11 where accno=paccno
12 and acctype='S');
13 return vtwa;
14 end;
15 /

Function created.

--------------
SQL> select * from kcb_tran_tab
2 where accno=paccno;
where accno=paccno
*
ERROR at line 2:
ORA-00904: "PACCNO": invalid identifier

SQL> select (1001) from dual;

(1001)
----------
1001

SQL> select fnow(1001) from dual;

FNOW(1001)
----------
0

SQL> begin
2 if chk_bal(1001,3000) then
3 dbms_output.put_line('It is eligible');
4 else
5 dbms_output.put_line('It is not eligible');
6 end if;
7 end;
8 /

PL/SQL procedure successfully completed.

SQL> set serveroutput on;


SQL> begin
2 if chk_bal(1001,3000) then
3 dbms_output.put_line('It is eligible');
4 else
5 dbms_output.put_line('It is not eligible');
6 end if;
7end;
8/
It is eligible

PL/SQL procedure successfully completed.

SQL> exec upd_bal(1001,'D',5000);

PL/SQL procedure successfully completed.

SQL> select * from kcb_acc_tab;

ACCNO NAME A DOO BAL


-------------------- -------------------- - --------- ----------
1001 ward S 12-MAR-20 48000
1002 allen C 12-MAR-20 30000
1003 jones S 12-MAR-20 10000
1004 miller S 11-MAR-20 10000
1005 scott S 10-MAR-20 10000
1006 john S 10-MAR-20 20000

6 rows selected.

SQL> select * from kcb_tran_tab;

TID ACCNO T
---------- -------------------- -
DOT
AMT
---------------------------------------------------------------------------
----------
101 1001 D
12-MAR-20 12.34.28.000000 PM
5000

SQL> exec upd_bal(1002,'W',8000);

PL/SQL procedure successfully completed.

SQL> select * from kcb_acc_tab;

ACCNO NAME A DOO BAL


-------------------- -------------------- - --------- ----------
1001 ward S 12-MAR-20 48000
1002 allen C 12-MAR-20 30000
1003 jones S 12-MAR-20 10000
1004 miller S 11-MAR-20 10000
1005 scott S 10-MAR-20 10000
1006 john S 10-MAR-20 20000

6 rows selected.

SQL> exec upd_bal(1003,'W',8000);


BEGIN upd_bal(1003,'W',8000); END;

*
ERROR at line 1:
ORA-20345: The bal is too low so,no transaction
ORA-06512: at "SOS11.UPD_BAL", line 17
ORA-06512: at line 1

SQL> exec upd_bal(1001,'W',5000);

PL/SQL procedure successfully completed.

SQL> select nvl(null,null) ftom dual;


select nvl(null,null) ftom dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select nvl2(null,null,null) from dual;

N
-

SQL> select nullif(10,10) from dual;

NULLIF(10,10)
-------------

SQL> select coalesce(null,null,null) from dual;

C
-

SQL> select * from kcb_acc_tab;

ACCNO NAME A DOO BAL


-------------------- -------------------- - --------- ----------
1001 ward S 12-MAR-20 48000
1002 allen C 12-MAR-20 30000
1003 jones S 12-MAR-20 10000
1004 miller S 11-MAR-20 10000
1005 scott S 10-MAR-20 10000
1006 john S 10-MAR-20 20000

6 rows selected.

SQL> select * from kcb_tran_tab;

TID ACCNO T
---------- -------------------- -
DOT
AMT
---------------------------------------------------------------------------
----------
101 1001 D
12-MAR-20 12.34.28.000000 PM
5000
102 1002 W
12-MAR-20 12.36.45.000000 PM
8000

103 1001 W
12-MAR-20 12.39.16.000000 PM
5000

SQL> select fnow(1001) from dual;

FNOW(1001)
----------
1

SQL> select ftwa(1001) from dual;


select ftwa(1001) from dual
*
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "SOS11.FTWA", line 6

SQL> select sum(100) from dual


2 where1=2;
where1=2
*
ERROR at line 2:
ORA-00933: SQL command not properly ended

SQL> select sum(100) from dual


2 where 1=2;

SUM(100)
----------

You might also like