title: SQL Primary Key validation in a stored procedure
body: <p>I have scoured the internet with no luck. I have attached links to the practice set I am working on, but I am creating a stored procedure that needs to update a row after checking if a foreign key from the one table matches with a corresponding primary key in another table. I'll attach my code so far (which isn't much), but I am honestly lost. I know how to create foreign key constraints like: </p>
  
  <pre><code>ALTER TABLE DRIVE
  ADD CONSTRAINT TRUCK_NUM_FK FOREIGN KEY (TRUCK_NUM) REFERENCES TRUCK;
  </code></pre>
  
  <p>But I don't know how to do these things and more from a stored procedure.
  Thank you!</p>
  
  <p>Practice Description:
  <a href="http://tinypic.com/r/2djxq4w/8" rel="nofollow">http://tinypic.com/r/2djxq4w/8</a>
  <a href="http://tinypic.com/r/sq61i1/8" rel="nofollow">http://tinypic.com/r/sq61i1/8</a></p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE TRUCK_RETURN (TR_NUM IN NUMBER,TR_MILE IN NUMBER) AS
  BEGIN
  IF
  UPDATE
  </code></pre>