排序字段能否用于变量绑定?

[复制链接]
查看11 | 回复6 | 2005-7-16 18:49:11 | 显示全部楼层 |阅读模式
如select * from tab1 order by :col1[/COLOR] ;
将:col1[/COLOR] 绑定为col1,col2
我在PHP中试验不成功
回复

使用道具 举报

千问 | 2005-7-16 18:49:11 | 显示全部楼层
根本就不可以的。
而且在ddl时也不允许用bind var的。
回复

使用道具 举报

千问 | 2005-7-16 18:49:11 | 显示全部楼层
绑定变量是值,而不能是字段名称
回复

使用道具 举报

千问 | 2005-7-16 18:49:11 | 显示全部楼层
--------------------------------------------------------
-- free.sql
--
-- This SQL Plus script lists freespace by tablespace
--------------------------------------------------------
column dummy noprint
columnpct_used format 999.9 heading "%|Used"
columnnameformat a16heading "Tablespace Name"
columnKbytes format 999,999,999heading "KBytes"
columnusedformat 999,999,999 heading "Used"
columnfreeformat 999,999,999heading "Free"
columnlargestformat 999,999,999heading "Largest"
break on report
compute sum of kbytes on report
compute sum of free on report
compute sum of used on report
select nvl(b.tablespace_name,

nvl(a.tablespace_name,'UNKOWN')) name,
kbytes_alloc kbytes,
kbytes_alloc-nvl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
((kbytes_alloc-nvl(kbytes_free,0))/

kbytes_alloc)*100 pct_used,
nvl(largest,0) largest
from ( select sum(bytes)/1024 Kbytes_free,

max(bytes)/1024 largest,

tablespace_name
fromsys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,

tablespace_name
from sys.dba_data_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by &1
回复

使用道具 举报

千问 | 2005-7-16 18:49:11 | 显示全部楼层
最初由 Silentman 发布
[B]绑定变量是值,而不能是字段名称 [/B]

当然也不允许是表名.
回复

使用道具 举报

千问 | 2005-7-16 18:49:11 | 显示全部楼层
楼主需要的不过是动态sql的功能而已
回复

使用道具 举报

千问 | 2005-7-16 18:49:11 | 显示全部楼层
谢谢各位!
我用php做应用,免不了要对各列排序,不能用绑定,每次要生成新SQL命令,岂不很郁闷。
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行