Postgresql, what am i doing wrong?

BlitzMax Forums/Brucey's Modules/Postgresql, what am i doing wrong?

Space_guy(Posted 2009) [#1]
Im gettings some time again to work convert my projekt to postgre and atleast I can create posts and tables without problems.
BUt i cant seem to make a prepared update to change values of already created posts.
I looked through all the examples and i couldnt find anythign on this and not much on google either. Its probbably simple but im pulling my hair here. So how does one set values in a prepared statement?
Thanks if anyone can help out with a small example.


Brucey(Posted 2009) [#2]
test_03.bmx and test_04.bmx show how to use prepared statements.

Parameters should be defined as $n, where 'n' is a number starting with 1, then 2, etc.

The bindValue() method is zero based, and accepts a TDBType object for its second parameter, like so :
		query.bindValue(0, TDBString.Set("Fish"))


To do an update you might do something like this:
	Local query:TDatabaseQuery = TDatabaseQuery.Create(db)
	query.prepare("UPDATE mytable SET name = $1 WHERE id = $2")

	query.bindValue(0, TDBString.Set("Fred"))
	query.bindValue(1, TDBInt.Set(25))

	query.execute()

Binds and executes can be called multiple times against a single prepare.


Space_guy(Posted 2009) [#3]
Well. it doesnt look all that different than i did. but i will look at it today with fresh eyes. Thanks alot!


Space_guy(Posted 2009) [#4]
Thanks. It turned out it was my sql statement that was wrong. silly me. Anyway thanks alot for the support!


Brucey(Posted 2009) [#5]
Glad you got it sorted out :-)