Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #1 
SelectSql() has a very useful feature that allows you to use parameters instead of trying to format variables correctly for SQL. What is not commonly known is that you can use select SQL for all database activities not just for select statements.

For example you can easily use the following statement:
Quote:
SelectSql(null, "UPDATE eSession SET eLastActivityTime = @Now WHERE eUserName = @UserName", SQLArg("@Now", ProcessContext.CurrentTime), SQLArg("@UserName", "bo'brien"));
which saves a lot of messing about formatting time and text variables.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Nappy

Avatar / Picture

Guru
Registered:
Posts: 1,087
Reply with quote  #2 

is this supported behaviour or a "hack" (that will break in the future?)


__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.

PS that's for V6/7 for V9 the problem is V9 at the moment ;)
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #3 
I see no reason for it not to be fully supported.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
jsuijker

Senior Member
Registered:
Posts: 93
Reply with quote  #4 
Any tips about using the response of a selectsql with an update or insert statement?

0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #5 
Well, if you do a select scope_identity() (I think) after the SQL you will get the last identity field created returned.

Try "SET NOCOUNT ON INSERT ... SELECT scope_identity() " for example. You will also need to add .ReturnType such as SelectSql( ... ).Integer to get an integer returned. .List will return a list (in 9.0.2 anyway), etc.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
jsuijker

Senior Member
Registered:
Posts: 93
Reply with quote  #6 
When executing an insert or update statement in SQL studio. The response is X rows affected. I want to use this reponse. How to obtain this?
using version v9.0.2.1
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #7 
Sorry, no idea on that. There is probably some obscure thing, but you will need the set nocount on in my experience too.

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Tomination

New Member
Registered:
Posts: 7
Reply with quote  #8 
Quote:
Originally Posted by jsuijker
Any tips about using the response of a selectsql with an update or insert statement?



Use a stored procedure?
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!