有一个表 a_stu 
写了如下语句
create or replace procedure s1(nid in a_stu.id%type)
   is
   begin
   select name from a_stu where nid=id
   end s1;
   /
但是创建不成功,这是为什么啊?
谢谢大家了

解决方案 »

  1.   

    create or replace procedure s1(nid in a_stu.id%type) 
      is 
      xx a_stu.name%type
      begin 
      select name 
      into xx
      from a_stu where id = nid
      end s1; 
      

  2.   

    create or replace procedure s1(nid in a_stu.id%type) 
      is 
      xx a_stu.name%type; 
      begin 
      select name 
      into xx 
      from a_stu where id = nid; 
      end s1; 
      

  3.   

    create or replace procedure s1(nid in a_stu.id%type) 
      is 
      begin 
      select name from a_stu where id=nid; 
      end s1; 
      

  4.   

    你写的过程里面的select语句有什么用的
    至少需要定义一个变量,然后select...into...,把需要返回的值赋给变量
      

  5.   

    create or replace procedure s1(id in a_stu.id%type)
      is
      begin
        execute immediate 'select name from a_stu where id=:id' using id;
      end s1;这样也可以
      

  6.   

    create or replace procedure s1(nid in a_stu.id%type) 
      is 
      xx a_stu.name%type; 
      begin 
      select name 
      into xx 
      from a_stu where id = nid; 
      end s1; 
    为什么第三行需要加上一个‘;’ 才正确?
      

  7.   

    create or replace procedure s1(nid in a_stu.id%type) 
      is 
      xx a_stu.name%type; 
      begin 
      select name 
      into xx 
      from a_stu where id = nid; 
      end s1; 
    为什么第三行需要加上一个‘;’ 才正确?
    ==========================
    这个是语法规范 :-)