国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

返回一個最終記錄

2024-07-21 02:34:03
字體:
來源:轉載
供稿:網友

  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>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 镇赉县| 泗阳县| 垫江县| 保山市| 天长市| 青铜峡市| 阿尔山市| 会昌县| 鄢陵县| 翁源县| 红原县| 新干县| 时尚| 郓城县| 时尚| 顺昌县| 治多县| 五寨县| 道真| 轮台县| 齐河县| 乐清市| 崇文区| 开平市| 东乌珠穆沁旗| 澄城县| 九江市| 尼勒克县| 年辖:市辖区| 龙里县| 阜平县| 衡阳县| 威宁| 宝鸡市| 泾阳县| 新宁县| 新源县| 玛纳斯县| 大理市| 富阳市| 伊金霍洛旗|