【问题标题】:i want to generate a patient details report based on the input (input should be operators like '>','<','=') given by the user我想根据用户给出的输入(输入应该是'>','<','='之类的运算符)生成患者详细信息报告
【发布时间】:2016-03-03 09:08:12
【问题描述】:

//根据用户给出的输入生成患者详细信息报告的程序

CREATE or REPLACE  procedure XX_TEAM18_PROc2
    (Admit_date in date,
    Bill_amt in number,
    action in varchar2)
    is
    cursor c 
    is 
    SELECT P.Patient_name,ph.Symptom_issue Symptom,ph.Consulted_dr Doctor,ph.Diagnosis,ph.Bill_Amount 
    FROM
    XX_Patient_Master_Team18 P,XX_Patient_History_Team18 ph
    WHERE

p.Patient_Id=ph.Patient_id
AND
bill_amount action bill_amount;
rec c%rowtype;
cursor c1
 is
SELECT P.Patient_name,ph.Symptom_issue Symptom,ph.Consulted_dr Doctor,ph.Diagnosis,ph.Admitted_date Admitted_date
FROM
XX_Patient_Master_Team18 P,XX_Patient_History_Team18 ph
WHERE
p.Patient_Id=ph.Patient_id 
AND
Admitted_date action admit_date ;

rec1 c1%rowtype;
begin
open c;
dbms_output.put_line('  records belongs to '||Bill_Amt);
fetch c into rec ;
 loop
exit when c%notfound;
dbms_output.put_line(rec.Symptom||' '||rec. Doctor||' '||rec.Diagnosis||' '||rec.bill_Amount);
end loop;
close c;
 open c1;
   dbms_output.put_line('  records belongs to given '||Admit_date);
fetch c1 into rec1 ;
loop
exit when c1%notfound;
dbms_output.put_line(rec1.Symptom||' '||rec1.Doctor||' '||rec1.Diagnosis||' '||rec1.Admitted_date);
end loop;
close c1;
end ;

【问题讨论】:

  • 您遇到的问题是什么?
  • 在编译这段代码时它给出了无效的关系运算符

标签: plsql


【解决方案1】:

您必须使用动态 SQL 作为参数 action 不能用于 PL/SQL 中的固定 SQL 语句。参数只能用作替换值,不能用作列名或运算符,除非您使用的是动态 SQL。

您需要创建一个 varchar2 变量来保存 SQL 语句,然后使用 DBMS_SQL 包创建游标。 DBMS_SQL 里面有很好的文档,用完别忘了关闭游标。

【讨论】:

  • 大家好,感谢您的所有建议...我根据您的建议想通了
猜你喜欢
  • 2020-04-24
  • 2023-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多