国产探花免费观看_亚洲丰满少妇自慰呻吟_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>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富阳市| 曲阳县| 和平区| 普安县| 军事| 泉州市| 云南省| 壶关县| 锡林郭勒盟| 沭阳县| 龙川县| 六安市| 四会市| 义乌市| 北宁市| 余庆县| 临沂市| 卓资县| 望谟县| 佛学| 炎陵县| 葫芦岛市| 张家口市| 仁化县| 合水县| 元江| 二连浩特市| 高安市| 耒阳市| 沭阳县| 绥棱县| 谷城县| 凤山县| 玉林市| 长沙县| 巩留县| 榕江县| 南溪县| 永川市| 崇义县| 沾益县|