有一表Myinfor.db字段信息如下:
   MyName(姓名),StudyNo(学号),Sex(姓别),Age(年龄)等等要求写一存储过程,对该表作单条件查询或复合查询.请问和位该怎么写这一存储过程

解决方案 »

  1.   

    create procedure test 
    @ID
    as
    select MyName(姓名),StudyNo(学号),Sex(姓别),Age(年龄) From Myinfor
    where ID like Rtrtim(@ID)
      

  2.   

    To   helodd(真可爱)ID like Rtrtim(@ID)  这个啥意思。我的意思是这样的。
    create procedure Mysp
     ( @MyName varchar(10)
       @StudyNo varchar(8) 
       @Sex varchar(2)
       @Age varcar(3)
     )
    select * from Myinfor where ...... 注(where 后面的条件要根据传入的参数来决定,如果只传入MyName(姓名), 则为 :
       select * from Myinfor where MyName = @MyName如果传入有两个或以上参数则用 and 过行边接。
      

  3.   

    创建一个结构类型的变量,结构中包括你所有的字段。在查询前判断,结构中的各个变量是否付值,在生成SQL.如果嫌结构麻烦,也可以多定义几个输入变量,如
    vA,vB,vC...................
    伪代码:
    var
      sSQL:varchar2;
    begin
      if vA is not null then
        sSQL:=' A_Field= vA'  if vB is not null then
        if length(sSQL)>0 then
           sSQL:=sSQL+' and B_Field=vB';
        else
           sSQL:='B_Field=vB';  if vC is not null then
        if length(sSQL)>0 then
           sSQL:=sSQL+' and C_Field=vC';
        else
           sSQL:=' C_Field=vC'.....................sSQL:='select * from Table where '+ sSQL;
    搞定
      

  4.   

    我是想在存储过程中搞定,在delphi中可以改变存储过程中的语句吗?