Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

oracle - SQL Query from different tables

I'm trying to query the C_CONTENT of a specific patient. When I run the query it appears as blank, even though I have populated the relevant tables

select c.C_ID,
       c.C_CONTENT,
       c.PP_ID
  from COMMENTS c, EXIST_IN ei
  where ei.P_ID = :P7_P_ID and ei.PP_ID = c.PP_ID

These are the relevant tables

CREATE TABLE  "COMMENTS" 
   (    "C_ID" NUMBER(10,0), 
    "C_CONTENT" VARCHAR2(1200) NOT NULL ENABLE, 
    "PP_ID" NUMBER(10,0), 
     CHECK ( c_id > 0 ) ENABLE, 
     PRIMARY KEY ("C_ID")
  USING INDEX  ENABLE
   )
/
ALTER TABLE  "COMMENTS" ADD FOREIGN KEY ("PP_ID")
      REFERENCES  "PATIENT_PROFILE" ("PP_ID") ENABLE
/
CREATE TABLE  "PATIENT_PROFILE" 
   (    "PP_ID" NUMBER(10,0), 
    "DIAGRAM1" NUMBER(10,0), 
    "DIAGRAM2" NUMBER(10,0), 
     CHECK ( pp_id > 0 ) ENABLE, 
     PRIMARY KEY ("PP_ID")
  USING INDEX  ENABLE
   )
/
CREATE TABLE  "EXIST_IN" 
   (    "P_ID" NUMBER(10,0), 
    "PP_ID" NUMBER(10,0), 
     PRIMARY KEY ("P_ID", "PP_ID")
  USING INDEX  ENABLE
   )
/
ALTER TABLE  "EXIST_IN" ADD FOREIGN KEY ("P_ID")
      REFERENCES  "PATIENTS" ("P_ID") ENABLE
/
ALTER TABLE  "EXIST_IN" ADD FOREIGN KEY ("PP_ID")
      REFERENCES  "PATIENT_PROFILE" ("PP_ID") ENABLE
question from:https://stackoverflow.com/questions/65841793/sql-query-from-different-tables

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Without sample data, it is difficult to tell whether your query returns something or not. A few possible causes:

  • after INSERT, you didn't COMMIT - do so
  • as you use Apex, is :P7_P_ID in session state? If not, put it. How? Depending on what you do.
    • If this query is source for e.g. interactive report, put P7_P_ID into Page items to submit report property
    • If there's a button on the page, it usually submits (unless you changed its behavior), and submit will store item's value into session state

If I had to bet, I'd put my money on "Page items to submit" property.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...