va_id es_product.id%type:= &请输入购买编号;
va_num NUMBER(5,0):=&请输入购买数量;
va_stockcount es_product.stockcount%type;
begin
select stockcount into va_stockcount from es_product where id =va_id ;
if va_stockcount< va_num then
dbms_output.put_line('库存'+va_stockcount+'无法购买');
end if;
commit;
end;
----------------------------
declare
va_id es_order.id%type:= &请输入订单编号;
status2 es_order.status%type;
begin
select status into status2 from es_order where id=1;
case status2
when 1 then
dbms_output.put_line('订单已提交');
when 2 then
dbms_output.put_line('已经付款');
when 3 then
dbms_output.put_line('货物已发出');
else
dbms_output.put_line('nnn');
end case;
end;
declare
va_id es_order.id%type:= &请输入订单编号;
status2 es_order.status%type;
begin
select status into status2 from es_order where id=1;
if status2=1 then
dbms_output.put_line('订单已提交');
else if status2=2 then
dbms_output.put_line('已经付款');
else
dbms_output.put_line('nnn');
end if;
end;
declare
va_num NUMBER(5,0):=0;
va_sum NUMBER(5,0):=0;
begin
loop
if va_num <=100 then
dbms_output.put_line(va_num);
end if;
va_sum:=va_num+1;
exit va_num > 100;
end loop;
dbms_output.put_line('zh'+va_sum);
end;
declare
va_num NUMBER(5):=0;
va_sum NUMBER(5):=0;
begin
while va_num<=100 loop
va_sum:=va_sum+va_num;
va_num:=va_num+1;
end loop;
dbms_output.put_line(va_sum);
end;
declare
va_sum NUMBER(5):=0;
begin
for va_num in 1..100 loop
va_sum:=va_sum+va_num;
end loop;
dbms_output.put_line('hh:'||va_sum);
end;
declare
va_num NUMBER(5):=0;
va_sum NUMBER(5):=0;
begin
loop
va_sum:=va_sum+va_num;
va_num:=va_num+1;
exit when va_num>100;
end loop;
dbms_output.put_line('hh:'||va_sum);
end;
declare
va_sum NUMBER(5):=0;
begin
for va_num in 1..100 loop
if mod(va_num,2)=0 then
va_sum:=va_sum+va_num;
end if;
end loop;
dbms_output.put_line(va_sum);
end;
declare
begin
for va_num in 5..7 loop
insert into es_sort values(va_num,'类别'||va_num,0);
end loop;
commit;
end;
package com.test;
public class demo1 {
public static void main(String[] args) {
method1();
method2();
method3();
}
public static void method1(){
int sum = 0;
for (int i = 1; i <= 100; i++)
{
sum += i;
}
System.out.println("1到100累加的和为:" + sum);
}
public static void method2(){
int sum = 0;
int i = 1;
while (i <= 100)
{
sum += i;
i++;
}
System.out.println("1到100累加的和为:" + sum);
}
public static void method3(){
int sum = 0;
int i = 1;
do {
sum += i;
i++;
} while (i <= 100);
System.out.println("1到100累加的和为:" + sum);
}
}
---------------------------------------------------------------
declare
pid number(10):=&请输入商品id;
stockcount number(12);
pname varchar2(16);
begin
select name,stockcount into pname,stockcount from ES_PRODUCT where id=pid;
dbms_output.put_line('商品名称:'||pname||' 库存:'||stockcount);
end;
declare
pid number(10):=&请输入商品id;
stockcount ES_PRODUCT.stockcount%type;
pname ES_PRODUCT.name%type;
begin
select name,stockcount into pname,stockcount from ES_PRODUCT where id=pid;
dbms_output.put_line('商品名称:'||pname||' 库存:'||stockcount);
end;
declare
pid number(10):=&请输入商品id;
resultji ES_PRODUCT%rowtype;
begin
select name ,stockcount into resultji from ES_PRODUCT where id=pid;
dbms_output.put_line('商品名称:'||resultji.name||' 库存:'||resultji.stockcount);
end;