简体   繁体   中英

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

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 eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM