熟悉SQL进来看一下,轻松拿100分。

thinkhejie 2009-05-12 09:47:17

declare @id varchar2(20);
set @id='1234'
select * from where id=@id


这是微软MSSQL的写法,请问,我现在使用的是 PLSQL 连接 ORACLE 。
那么, 这句话应该怎么写?谢谢!
...全文
201 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
kevinpan2009 2009-05-13
  • 打赏
  • 举报
回复
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 ;
renxingyangzi 2009-05-13
  • 打赏
  • 举报
回复
学习
manbu3269 2009-05-13
  • 打赏
  • 举报
回复
declare
id varchar2(20) := '1234 ';
begin
select * from table_name where id=id;
exception
when others then
DBMS_OUTPUT.PUT_LINE('错误');
end ;


就是这样写就好啦
songjingsmile 2009-05-12
  • 打赏
  • 举报
回复
只学了 SQL Server 2000.还没学Oracle.
as11qwer 2009-05-12
  • 打赏
  • 举报
回复
学习~~
catici 2009-05-12
  • 打赏
  • 举报
回复
没学过Oracle呢?
暂时在学习SQL Server 2000呢,学完了之后再学Oracle。。。
KingZChina 2009-05-12
  • 打赏
  • 举报
回复
学习了
zzh307924323 2009-05-12
  • 打赏
  • 举报
回复
declare
id varchar2(20) := '1234 ';
begin
select * from table_name where id=id;
exception
when others then
DBMS_OUTPUT.PUT_LINE('错误');
end ;



就是这样写就好啦
devin-deng 2009-05-12
  • 打赏
  • 举报
回复
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 ;
sjzhong 2009-05-12
  • 打赏
  • 举报
回复
3L
ET郭强 2009-05-12
  • 打赏
  • 举报
回复
学习~~~~~
kimi 2009-05-12
  • 打赏
  • 举报
回复
友情帮顶
a252353632 2009-05-12
  • 打赏
  • 举报
回复

declare
id varchar2(20) := '1234';
temp table—name%ROWTYPE;
begin
select * into temp from table—name where id = id;
end;
justinavril 2009-05-12
  • 打赏
  • 举报
回复
抱歉 你这一解释我反而晕倒了
thinkhejie 2009-05-12
  • 打赏
  • 举报
回复
上面查询语句写错了, 应该是 select * from table—name where id=@id
qsrock 2009-05-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 dengkai_java 的回复:]
declare  @id  varchar2(20);
set  @id='1234'
select * from where id=@id


在oracle中使用如下:

SQL codedeclareidvarchar2(20) :='1234';beginselect*fromtable_namewhereid=id;
exceptionwhenothersthenDBMS_OUTPUT.PUT_LINE('错误');end;
[/Quote]
顶贴!
xmlchd 2009-05-12
  • 打赏
  • 举报
回复
declare
sid varchar2(20);
begin
sid:='1234';
select * from tableName where id =sid;
end
gao512008 2009-05-12
  • 打赏
  • 举报
回复
帮顶
GeekZFZ 2009-05-12
  • 打赏
  • 举报
回复
在oracle 10g中使用如下:

declare
@id varchar2(20):='1234';
begin
select * from where id=@id;
exception
when others then
DBMS_OUTPUT.PUT_LINE('错误');
end;

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧