| Author |
Topic |
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-06 : 08:14:36
|
| Hi all. How could i trigger the result in select statement? If the query does not return a value, there must be a prompt message to appear. thanks-Ron- |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-06 : 08:19:51
|
| Do it in the front-end.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-06 : 09:05:12
|
| Use @@ROWCOUNT.Peter LarssonHelsingborg, Sweden |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-08 : 02:16:29
|
| @@ROWCOUNT?where can i insert this to my query?for example.select lastname from pspersonaldata where dcno ='206756'thanks-Ron- |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-08 : 02:27:31
|
| Is this ad-hoc query? or contained in stored proc?If inside SP, after query check the value of @@Rowcount. If > 0 then there are records else no records. Return appropriate status value (1 or 0 ) back to the caller of the SP and show the message accordingly.If ad-hoc query, check whether your recordset (or some similar object) on the front-end contain any record and show the message accordingly.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-08 : 02:27:43
|
quote: Originally posted by harsh_athalye Do it in the front-end.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
Yes ! live it up to Madhi's spirit He can't be here but his spirit sure is. KH |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-08 : 02:31:48
|
I see that Madhi's style has haunted you too, Khtan. [url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80235[/url]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-08 : 02:39:15
|
| not ad hoc. i think its stored procedure.I don't know how to store a value to a variable.select lastname, @@rowcount as rownumber pspersonaldata where dcno = '111222333'declare @rowcounter intset @rowcounter = rownumberis it right?thanks.-Ron- |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-08 : 02:42:59
|
[code]declare @rowcounter intselect lastname, @@rowcount as rownumber from pspersonaldata where dcno = '111222333'set @rowcounter = @@rowcountrownumber[/code] KH |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-08 : 02:44:05
|
NNNNNoooooooooooooooooooo!!Create Proc SomeThingasdeclare @count intselect lastname from pspersonaldata where dcno ='206756'set @count = @@RowcountIf @count > 0 Return 1else Return 0GO Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-08 : 02:45:15
|
or if you are only instereted in the number of rows declare @rowcounter intselect @rowcounter = count(*) from pspersonaldata where dcno = '111222333' KH |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-08 : 02:48:41
|
or even better:Create Proc SomeThingasIf Exists(select * from pspersonaldata where dcno ='206756') Return 1else Return 0GO Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-08 : 02:51:24
|
| KH. It doesnt work. there is no rownumber inside the select statement.declare @rowcounter intselect lastname from pspersonaldata where dcno = '111222333'set @rowcounter = @@rownumberHarsh. I don't know how to use your query/SP. I will try that later if I can't do it in KH's style. But thanks-Ron- |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-08 : 03:12:55
|
sorry. it is @@rowcount. I have updated the post KH |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-08 : 05:03:27
|
| yes. I got it. What im trying to do now is pass the variable to my windows application. Im halfway for that.Thanks.-Ron- |
 |
|
|
|