how to do validation for duplicate primary key in database
What you are doing is:


Show a "select" form element containing a list of nodes whose content type is "product"
Show an error if there is a row in a database about the node the user selected


That is poor UX.
Suppose that there are 20 nodes of that content type, and only two nodes don't have a row in the database table where you save the data; there is a high probability the user gets the error message about the data being already present at least two times. Imagine what would happen when all the nodes have a corresponding row in the other database table. 

What you need to do is showing only the nodes for which there isn't a row in the other database table. That means, for example, using a query like the following one.

$result = db_query("SELECT n.nid, n.title FROM {node} n WHERE n.type = 'product' AND n.nid NOT IN (SELECT s.productid from {formModule_stock} s)");


The module should also show a message in the case all the nodes have a row in the other database table. In this case, the user should not see the form to select a node, rather than seeing a "select" form without any item.

As side note, avoid using upper case letters in the short name of modules. While PHP is case insensitive, you would have problems when you write update functions for your module.