教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> Oracle >> 备份恢复 >> 返回一个最终记录 - sys_context RSS订阅
返回一个最终记录 - sys_context
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   

  here is the table:
  create table t1 (code varchar2(10), language varchar2(10),
  dscr varchar2(10));
  
  with this data:
  insert into t1 values ('X','EN','english_dscr');
  insert into t1 values ('X','FR','french_dscr');
  
  how can i write a query or create a view to return the english record
  when i do not in clude the language column in the where part of the query.
  
  example.
  select * from t1 where code='X';
  to return the english record.
  or
  select * from t1 where code='X' and language='FR'
  to return the french record.
  
  thanks for your solution.
  Unfortunately, it won't solve my problem.
  i need to query, not based on my default language but on the language as
  requested by the user who desires the info.
  
  ------------------------------------------------------------------------------------
  
  You can use your "own" context as well via create context -- this uses the
  default one that is there for all (but could be unreliable for the same reason
  -- anything could change it) -- but shows the concept:
  
  ops$tkyte@ORA9IR2> drop table t1;
  
  Table dropped.
  
  ops$tkyte@ORA9IR2>
  ops$tkyte@ORA9IR2>
  ops$tkyte@ORA9IR2> create table t1 (code varchar2(10), language varchar2(10),
  2 dscr varchar2(20));
  
  Table created.
  
  ops$tkyte@ORA9IR2>
  ops$tkyte@ORA9IR2> insert into t1 values ('X','EN','english_dscr');
  
  1 row created.
  
  ops$tkyte@ORA9IR2> insert into t1 values ('X','FR','french_dscr');
  
  1 row created.
  
  ops$tkyte@ORA9IR2>
  ops$tkyte@ORA9IR2> create or replace view v
  2 as
  3 select * from t1
  4 where language = case when sys_context( 'userenv', 'client_info') in (
  'EN', 'FR' )
  5            then sys_context( 'userenv', 'client_info' )
  6            else 'EN'
  7          end;
  
  View created.
  
  ops$tkyte@ORA9IR2>
  ops$tkyte@ORA9IR2> select * from v;
  
  CODE    LANGUAGE  DSCR
  ---------- ---------- --------------------
  X     EN     english_dscr
  
  ops$tkyte@ORA9IR2> exec dbms_application_info.set_client_info( 'FR' );
  
  PL/SQL procedure successfully completed.
  
  ops$tkyte@ORA9IR2> select * from v;
  
  CODE    LANGUAGE  DSCR
  ---------- ---------- --------------------
  X     FR     french_dscr
  
  ops$tkyte@ORA9IR2>

来源:upschool.com.cn
作者:
关键字:返回一,最终记录,sys,context
发表日期:2007-1-6 0:48:40

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:ORA-01555 快照过旧--详细解释   下一篇:RMAN命令


2008-12-4 8:56:01
本文的相类似文章
  • sys不能以管理员的身份登陆
  • 返回一个最终记录 - sys_context
  • 如何解决无法以SYSDBA的身份远程登陆ORACLE数据库
  • Oracle10g新特性-SYSAUX表空间
  • 如何处理syslogd升级后qmgr突然停止写日志的问题
  • 系统启动脚本分析(5)--syslog脚本
  • system table
  • 查看哪些用户拥有SYSDBA、SYSOPER权限
  • [经验]FORM6i 及 sys_context
  • Linux上的sysctl
  • 在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com