declare  @id   varchar2(20); 
set  @id='1234'
select * from where id=@id
这是微软MSSQL的写法,请问,我现在使用的是 PLSQL 连接 ORACLE 。
那么, 这句话应该怎么写?谢谢!

解决方案 »

  1.   

    上面查询语句写错了, 应该是 select * from table—name where id=@id
      

  2.   


    declare 
      id varchar2(20) := '1234'; 
      temp table—name%ROWTYPE;
    begin
      select * into temp from table—name where id = id;
    end;
      

  3.   

    declare  @id   varchar2(20); 
    set  @id='1234'
    select * from where id=@id
    在oracle中使用如下:
       declare
         id varchar2(20) := '1234 '; 
       begin
          select * from table_name where id=id;
       exception
           when others then
              DBMS_OUTPUT.PUT_LINE('错误');
       end ;
      

  4.   

       declare
         id varchar2(20) := '1234 '; 
       begin
          select * from table_name where id=id;
       exception
           when others then
              DBMS_OUTPUT.PUT_LINE('错误');
       end ;就是这样写就好啦
      

  5.   

    没学过Oracle呢?
    暂时在学习SQL Server 2000呢,学完了之后再学Oracle
      

  6.   

    只学了 SQL Server 2000.还没学Oracle.
      

  7.   

    在oracle 10g中使用如下: declare 
    @id varchar2(20):='1234';
    begin
    select * from where id=@id;
    exception 
        when others then 
            DBMS_OUTPUT.PUT_LINE('错误'); 
    end;
      

  8.   

    declare
        sid varchar2(20);
    begin
        sid:='1234';
        select * from tableName where id =sid;
    end
      

  9.   

      declare 
        id varchar2(20) := '1234 '; 
      begin 
          select * from table_name where id=id; 
      exception 
          when others then 
              DBMS_OUTPUT.PUT_LINE('错误'); 
      end ; 
    就是这样写就好啦
      

  10.   

     declare 
        id varchar2(20) ; 
        Type v_cursor is ref cursor;
        m_cursor   v_cursor;
        m_temp     table_name%rowtype;
      begin 
          id:='1234';
         open m_cursor for select * from table_name where id=id; 
         loop
             fetch m_cursor into m_temp;
             exit when m_cursor%notfound;
             dbms_output.put_line(m_temp);
         end loop;
      exception 
          when others then 
              DBMS_OUTPUT.PUT_LINE('错误'); 
      end ;