How to execute a simple SQL

Questions and answers regarding general SQL and backend databases

How to execute a simple SQL

Postby ttmgybta » Wed Oct 12, 2011 9:48 am

How to execute a simple SQL statement in the code?
Not just a select also an update or so.

The rawSql needs in the second parameter a table name which I don’t know when I dynamically create a SQL statement.
ttmgybta

Servoy Version: 6.0.5 - build 1230
ttmgybta
 
Posts: 163
Joined: Thu Nov 11, 2010 10:39 am
Location: Da-vos schön isch

Re: How to execute a simple SQL

Postby mboegem » Wed Oct 12, 2011 9:22 pm

My experience is that this tablename doesn't really matter, as long as your sql is correct...
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: How to execute a simple SQL

Postby Bonkie » Thu Oct 13, 2011 11:25 am

ttmgybta wrote:How to execute a simple SQL statement in the code?
Not just a select also an update or so.

The rawSql needs in the second parameter a table name which I don’t know when I dynamically create a SQL statement.


But you do have the table name in the dynamicly create SQL statement I suppose? Then you can also add the table name into a variable which you serve as the second parameter:

rawsql...execute...(vSQL, vTable).

But if you want to select data, why dont you use a dataset or foundset created in mem?
Rick Bonkestoter
Certified Servoy 7 Developer

Direct ICT / ServoyCamp
User avatar
Bonkie
 
Posts: 68
Joined: Wed Jun 27, 2007 11:05 am
Location: Den Ham, The Netherlands

Re: How to execute a simple SQL

Postby ttmgybta » Thu Oct 13, 2011 2:38 pm

I made now two forms.
One to select which gifs me back a Dataset. (with databaseManager.getDataSetByQuery())
The second one is to delete and update and this just shows me if the update/delete was successful. (with plugins.rawSQL.executeSQL())

I have to break it apart anyway, the selecting and the update/delete part, because of user rights.
Thanks for your help
ttmgybta

Servoy Version: 6.0.5 - build 1230
ttmgybta
 
Posts: 163
Joined: Thu Nov 11, 2010 10:39 am
Location: Da-vos schön isch


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 6 guests