Question:
Rectify the errors for the following PL/SQL. program?
Pragathi sneha
2011-04-05 07:43:02 UTC
declare
account_number number;
bal number;
deposit number;
withdr number;
begin
account_number:=&account_number;
select balance into bal from sbaccount where acct_number=account_number;
deposit:=&deposit;
update sbaccount set balance=balance+deposit where acct_number=account_number;
select balance into bal from sbaccount where acct_number=account_number;
if bal>1000 then
withdr:=&withdr;
update sbaccount set balance=balance-withdr where acct_number=account_number
end if;
end;
Four answers:
vinay
2011-04-08 05:23:59 UTC
you are getting the balance value in "bal" but still using the keyword "balance" in the lines 11 nd 14 respectively.....



"update sbaccount set balance=balance+deposit where acct_number=account_number;"



thats why it ll show error.....it will not even execute the line....

Solution:



declare

account_number number;

bal number;

deposit number;

withdr number;

begin

account_number:=&account_number;

select balance into bal from sbaccount where acct_number=account_number;

deposit:=&deposit;

update sbaccount set balance=BAL+deposit where acct_number=account_number;

select balance into bal from sbaccount where acct_number=account_number;

if bal>1000 then

withdr:=&withdr;

update sbaccount set balance=BAL-withdr where acct_number=account_number

end if;

end;





-monish and vinay
TheMadProfessor
2011-04-05 08:10:20 UTC
Was this a procedure, stand-alone program or what?



On a syntax basis, your host variables need to be prefixed with colons in the SQL statements. Your program also has no declaration of passed parameters (assuming a procedure).
?
2016-12-02 11:39:43 UTC
hi Arathi Pls. verify with under application of C to reveal even & peculiar numbers and notice the place you have made a mistake am not sure no count in case you relatively need to have take a decide on the flow huge type once you may define with an integer. Programme: reveal no count if an excellent determination is peculiar or maybe #contain int substantial() { int huge type ; printf("enter an entire numbern"); scanf("%d",&huge type); if(huge type % 2 == 0) printf("Your huge type is even.n"); else printf("Your huge type is peculiar.n"); return 0; }
2011-04-06 21:00:45 UTC
guess u cn specify oly a condition in an update statement....rather performin an operation der!!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...