sql*plus中的变量问题

[复制链接]
查看11 | 回复5 | 2005-10-30 17:05:33 | 显示全部楼层 |阅读模式
我在SQL*PLUS中建立了一个变量,并以它为条件成功建立了一个视图
SQL>DEFINE A='60'
SQL>CREATE OR REPLACE VIEW V1 AS SELECT * FROM T1
WHERE F1='&A';
同时,我测试在前台调用这个视图,结果数据都有。
不知该变量A的值什么时候改变?如何改变?在前台能否改变?

回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
也许有别的方法去实现。
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
You're supposed to get the data that meet the criteria, right? The variable got replaced when the CREATE VIEW statement was compiled and executed. You'll find it by SELECT TEST FROM UER_VIEWS WHERE VIEW_NAME='V1'.
To use the variable from front end, you need to include the CREATE VIEW in a procedure, which is only supported by Oracle 8 and up. For old version,DBMS_SQL package should work.
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
&name不是变量,只是sqlplus的替代符,在执行该语句的时候会提示你输入name的值的。
不过你不应该把他放在''里,这样oracle会认为他是一个字符串。
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
why not check the view's source to see what the hall it is like.
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
why not check the view's source to see what the hall it is like.A's change can't effect the view in your writing.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行