【问题标题】:sql statement binding result with detailsql语句绑定结果详细
【发布时间】:2014-03-04 14:10:28
【问题描述】:

我有以下疑问:

select s.ST_SAMPLE_ID, s.st_cn_no as CNNumber,
s.st_smptyp as SampleType,
s.st_wasgrp as WasteCode,
s.st_wascod as WasteCategory,
s.st_received_dt as ReceivedDate,
s.st_wastyp_name as WasteType,
s.st_status as SampleStatus,
s.st_dispose_ind as DisposalStatus,
s.st_container as SampleContainer,
s.st_smppnt as SamplePoint,
s.st_nature as SampleNature,
c.scm_name as Color,cm_client_name 
from sample_txn s,sample_color_mstr c,client_mstr cm  
where s.st_color=scm_auto_no (+) and st_client_id=cm_client_id 
and st_year='13' and s.st_lab_id='R'and to_char(s.st_received_dt, 'MON') = 'FEB'

还有第二个查询

select TC.CM_COMPO_NAME as "COMPONENT",CM_SYMBOL as SYM,
CT_UNIT_Name as UOM,CT_METHOD_NAME as "METHOD",
ct_det_status as "REP. LIMITS",
  ct_ts_status as "TEST SPEC.", c.ct_due_dt as "DUE DATE",
  ct_result as "RESULT",ct_rep as "REP",ct_version as "VER",
FROM COMPONENT_TXN C,CODES_MSTR CM, SAMPLE_TXN S, 
  COMPONENT_MSTR TC,  INSTRUMENT_MSTR I 

每个结果:

result of query 1 and 2 抱歉,由于声誉较低,无法插入图片和链接

我想将查询 1 和 2 绑定到一个查询中,因此可以选择所有值,如下所示:

system show 抱歉,由于声誉较低,无法插入图片和链接

我已经尝试像这样组合这些查询

select s.ST_SAMPLE_ID, s.st_cn_no as CNNumber,
s.st_smptyp as SampleType,
s.st_wasgrp as WasteCode,
s.st_wascod as WasteCategory,
s.st_received_dt as ReceivedDate,
s.st_wastyp_name as WasteType,
s.st_status as SampleStatus,
s.st_dispose_ind as DisposalStatus,
s.st_container as SampleContainer,
s.st_smppnt as SamplePoint,
s.st_nature as SampleNature,
c.scm_name as Color,cm_client_name 
TC.CM_COMPO_NAME as "COMPONENT",CM_SYMBOL as SYM,
CT_UNIT_Name as UOM,CT_METHOD_NAME as "METHOD",
ct_det_status as "REP. LIMITS",
  ct_ts_status as "TEST SPEC.", o.ct_due_dt as "DUE DATE",
  ct_result as "RESULT",ct_rep as "REP",ct_version as "VER"
from sample_txn s,sample_color_mstr c,client_mstr cm, component_txn o,codes_master cm,
component_mstr tc, instrument_mstr i
where s.st_color=scm_auto_no (+) and st_client_id=cm_client_id 
and st_year='13' and s.st_lab_id='R'and to_char(s.st_received_dt, 'MON') = 'FEB'

然后出现错误

Error at Command Line:13 Column:2
Error report:
SQL Error: ORA-00923: FROM keyword not found where expected
00923. 00000 -  "FROM keyword not found where expected"
*Cause:    
*Action:

谢谢

【问题讨论】:

  • 逗号,在 cm_client 名称之后!

标签: sql oracle data-binding master-detail


【解决方案1】:

intrument_mstrcomponent_txn 表永远不会连接,这将为您提供 Catersian 连接。

select s.ST_SAMPLE_ID, s.st_cn_no as CNNumber,
s.st_smptyp as SampleType,
s.st_wasgrp as WasteCode,
s.st_wascod as WasteCategory,
s.st_received_dt as ReceivedDate,
s.st_wastyp_name as WasteType,
s.st_status as SampleStatus,
s.st_dispose_ind as DisposalStatus,
s.st_container as SampleContainer,
s.st_smppnt as SamplePoint,
s.st_nature as SampleNature,
c.scm_name as Color,
cm_client_name,
TC.CM_COMPO_NAME as "COMPONENT",
CM_SYMBOL as SYM,
CT_UNIT_Name as UOM,
CT_METHOD_NAME as "METHOD",
ct_det_status as "REP. LIMITS",
ct_ts_status as "TEST SPEC.",
o.ct_due_dt as "DUE DATE",
ct_result as "RESULT",
ct_rep as "REP",
ct_version as "VER"
from sample_txn s,
     sample_color_mstr c,
     client_mstr cm,
     component_txn o,
     codes_master cm,
     component_mstr tc,
     instrument_mstr i
where s.st_color=scm_auto_no (+)
 and st_client_id=cm_client_id 
 and st_year='13' 
 and s.st_lab_id='R'
 and to_char(s.st_received_dt, 'MON') = 'FEB'

【讨论】:

    猜你喜欢
    • 2011-02-26
    • 1970-01-01
    • 2013-04-04
    • 2011-02-26
    • 1970-01-01
    • 2011-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多