title: Postgres - How to automatically call ST_SetSRID(ST_MakePoint(lng, lat), 4326) on inserts?
body: <p>I'm using postGIS, and I'm not very familiar with SQL.</p>
  
  <p>I can successfully insert into my <code>markers</code> table as long as I do something like this (<em>pseudocode!)</em>:</p>
  
  <pre><code>'INSERT INTO markers(created_by, title, description, lat, lng, geography)\
         values($1, $2, $3, $4::decimal, $5::decimal, ST_SetSRID(ST_MakePoint($5::decimal, $4::decimal), $6))',
        [
          data.created_by,
          data.title,
          data.description,
          data.lat,
          data.lng,
          4326
        ]'
  </code></pre>
  
  <p>As you can see, I am doing <code>ST_SetSRID(ST_MakePoint($5::decimal, $4::decimal), $6)</code> from my application code.</p>
  
  <p>I want to avoid that, and instead put this on the database side.  Since I can do things like auto time stamps on the db side, I'm wondering if I can also do <code>ST_SetSRID(ST_MakePoint(lng, lat), 4326)</code> on the table itself.</p>
  
  <p>This way, the application only needs to provide lat and lng, and the database will do the <code>ST_SetSRID(ST_MakePoint())</code> operation.</p>
  
  <p>Thanks</p>
  
  <p>Edit: I'm not sure whose answer to mark as +1 since both offered tremendously good help and advice.  I hope future readers will read both and hopefully learn something!</p>