- create table tablea(id int,ip varchar(15),apps varchar(10))
- insert into tablea select 23,"127.0.0.1","aaa"
- go
- declare @Variable1 varchar(15),@Variable2 varchar(10)
- select @Variable1 = ip ,@Variable2 = apps from tablea where id = 23
-
- select @Variable1,@Variable2
- /*
- --------------- ----------
- 127.0.0.1 aaa
-
- (1 行受影响)
-
- */
- go
- drop table tablea
SQLSERVER的多字值赋值方式如上所示,直接SELECT就可以但在Oracle的PLSQL下 select into 只能赋值单个变量,不能进行多变量同时赋值。 如 : select count(*) into nb_count from t_khz where fzbh=V_fzbh;多变量赋值一般采取游标FETCH的方式:
- cursor c_rw is
- select * from t_kh
-
- r_rw c_rw%rowtype;
- open c_rw;
- loop
- fetch c_rw into r_rw;
- exit when c_rw%notfound;
- dbms_output.put_line(r_rw.khbh||" "||r_rw.khxm||" "||r_rw.yzbm);
- end loop;
- close c_rw;
还有就一种方式就是用ROWTYPE
- -- Local variables here
- i integer;
- v_kh t_kh%rowtype;
- gin
- -- Test statements here
-
-
- select * into v_kh from t_kh where rownum=1;
- dbms_output.put_line(v_kh.khbh||" "||v_kh.khxm||" "||v_kh.yzbm);
-
-
-
- d;
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12MySQL在NoSQL的缓存变革关于解决Oracle登录:ora-12154:tns:无法解析指定的连接标识符相关资讯 Oracle入门教程
- 使用SQLT来构建Oracle测试用例 (08/28/2014 06:17:41)
- Oracle AUTOTRACE 统计信息 (02/18/2013 08:25:40)
- Linux Oracle服务启动&停止脚本与 (12/16/2012 14:42:37)
| - Oracle入门教程:把表和索引放在不 (07/13/2013 11:21:40)
- Oracle直接路径加载--append的深度 (02/07/2013 08:26:36)
- Oracle Connect By用法 (12/16/2012 13:36:10)
|
本文评论 查看全部评论 (0)