Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Need Postgres answer

Started 1 year, 11 months ago by NancyDru
I don't have Postgres and I'd like to make a change to a module that I support. For MySql, I know I can use "INSERT ... ON DUPLICATE KEY UPDATE ..." for part of my change and it will make the code so much simpler. ( http://dev.mysql.com/doc/refman/5.0/en/insert-on-d uplicate.html ) Does Postgres support this syntax? How about all the other DBs that are being considered for Drupal?
Site: Forums | drupal.org  Forums | drupal.org - site profile
Forum: Deprecated - Database compatibility  Deprecated - Database compatibility - forum profile
Total authors: 6 authors
Total thread posts: 11 posts
Thread activity: no new posts during last week
Domain info for: drupal.org

Other posts in this thread:

NancyDru replied 1 year, 11 months ago

havran replied 1 year, 11 months ago
Here is some "sort of" solution: http://www.thescripts.com/forum/thread423068.html . -- My blog - Havran's mini-blog My first drupal site - http://www.enigma.sk/

NancyDru replied 1 year, 11 months ago
That tells me I can't do it the easy way... :( Nancy W. Drupal Cookbook (for New Drupallers) Adding Hidden Design or How To notes in your database

easy12 replied 1 year, 11 months ago
If you like things easy, you'll have difficulties; if you like problems, you'll succeed

jmpoure replied 1 year, 11 months ago
I recommand doing an INSERT. If it fails, then UPDATE.

shobika replied 1 year, 11 months ago
use UPDATE, it should help in this

fmatias replied 1 year, 11 months ago
Use transactions. Example (a psql session) : First case, no matching record : rsln_devel_drupal=# begin ; BEGIN rsln_devel_drupal=# select count(*) from node where vid=1000 ; count ------- 0 (1 ligne) rsln_devel_drupal=# insert into node (vid, title) values (1000, 'my title') ; INSERT 0 1 rsln_devel_drupal=# commit ; COMMIT Second case, matching record : rsln_devel_drupal=# ...

fmatias replied 1 year, 11 months ago
The previous examples are just wrong. First case, no matching record : rsln_devel_drupal=# begin ; BEGIN rsln_devel_drupal=# lock table node ; LOCK TABLE rsln_devel_drupal=# select count(*) from node where vid=1000 ; count ------- 0 (1 ligne) rsln_devel_drupal=# insert into node (vid, title) values (1000, 'my title') ; INSERT 0 1 rsln_devel_drupal=# commit ; COMMIT Second case, ...

NancyDru replied 1 year, 11 months ago
Nancy W. Drupal Cookbook (for New Drupallers) Adding Hidden Design or How To notes in your database

shobika replied 1 year, 10 months ago
wrongly posted. *deleted*

 

Top contributing authors

Name
Posts
NancyDru
4
user's latest post:
Need Postgres answer
Published (2008-01-07 22:19:00)
shobika
2
user's latest post:
Need Postgres answer
Published (2008-01-18 10:20:00)
use UPDATE, it should help in this
fmatias
2
user's latest post:
Need Postgres answer
Published (2008-01-22 20:42:00)
The previous examples are just wrong. First case, no matching record : rsln_devel_drupal=# begin ; BEGIN rsln_devel_drupal=# lock table node ; LOCK TABLE rsln_devel_drupal=# select count(*) from node where vid=1000 ; count -------      0 (1 ligne) rsln_devel_drupal=# insert into node (vid, title) values (1000, 'my title') ; INSERT 0 1 rsln_devel_drupal=# commit ; COMMIT Second case,...
havran
1
user's latest post:
Need Postgres answer
Published (2008-01-07 22:42:00)
Here is some "sort of" solution: http://www.thescripts.com/forum/thread423068.html . -- My blog - Havran's mini-blog My first drupal site - http://www.enigma.sk/
easy12
1
user's latest post:
Need Postgres answer
Published (2008-01-11 19:34:00)
If you like things easy, you'll have difficulties; if you like problems, you'll succeed
jmpoure
1
user's latest post:
Need Postgres answer
Published (2008-01-17 14:04:00)
I recommand doing an INSERT. If it fails, then UPDATE.

Related threads on "Forums | drupal.org":

Related threads on other sites:

Thread profile page for "Need Postgres answer" on http://drupal.org. This report page is a snippet summary view from a single thread "Need Postgres answer", located on the Message Board at http://drupal.org. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity