public void updatePostMetaValue ( final long postId , final String metaKey , final String metaValue ) throws SQLException { Meta currMeta = selectPostMetaValue ( postId , metaKey ) ; if ( currMeta == null ) { Connection conn = null ; PreparedStatement stmt = null ; Timer . Context ctx = metrics . setPostMetaTimer . time ( ) ; try { conn = connectionSupplier . getConnection ( ) ; stmt = conn . prepareStatement ( insertPostMetaSQL ) ; stmt . setLong ( 1 , postId ) ; stmt . setString ( 2 , metaKey ) ; stmt . setString ( 3 , metaValue ) ; stmt . executeUpdate ( ) ; } finally { ctx . stop ( ) ; SQLUtil . closeQuietly ( conn , stmt ) ; } } else { Connection conn = null ; PreparedStatement stmt = null ; Timer . Context ctx = metrics . setPostMetaTimer . time ( ) ; try { conn = connectionSupplier . getConnection ( ) ; stmt = conn . prepareStatement ( updatePostMetaValueSQL ) ; stmt . setString ( 1 , metaValue ) ; stmt . setString ( 2 , metaKey ) ; stmt . setLong ( 3 , postId ) ; stmt . executeUpdate ( ) ; } finally { ctx . stop ( ) ; SQLUtil . closeQuietly ( conn , stmt ) ; } } }
Updates a post meta value if it exists or inserts if it does not .