im having a problem integrating an SQL statement with my program,
it works fine when theres a result but throws an error when there is
no result,
is there anyway in SQL to make up a row if there isnt one that matches
the query for example in this i could put indicator values in the
returned fields then a simple check to see if its a proper field of my
indicator field
I know ISNULL works with single values but that only works if there is
a row returned
Does anyone know of any SQL syntax for MS SQL that when no row is
returned it makes on up and parses it back
Thank you in advance for your help!!
BenAm Tue, 20 Nov 2007 02:57:06 -0800 (PST) schrieb Ben:
Quote:
Originally Posted by
Hello,
>
im having a problem integrating an SQL statement with my program,
it works fine when theres a result but throws an error when there is
no result,
... and what is the error message ??
Quote:
Originally Posted by
Does anyone know of any SQL syntax for MS SQL that when no row is
returned it makes on up and parses it back
I don't see any sense in this, but anyway, you can do something like:
if (select count(*) from persontable where id < 17) 0
select id, lastname, street1, city from persontable where id < 17
else select 0 as id, 'testperson' as lastname, 'noStreet' as street1,
'noCity' as city
bye,
Helmut|||What language is your "Program" in? Check the recordcount on the
dataset returned and go from there, don't return the dummy record.
Cheers,
Jason Lepack
On Nov 20, 5:57 am, Ben <bor...@.gmail.comwrote:
Quote:
Originally Posted by
Hello,
>
im having a problem integrating an SQL statement with my program,
it works fine when theres a result but throws an error when there is
no result,
is there anyway in SQL to make up a row if there isnt one that matches
the query for example in this i could put indicator values in the
returned fields then a simple check to see if its a proper field of my
indicator field
>
I know ISNULL works with single values but that only works if there is
a row returned
>
Does anyone know of any SQL syntax for MS SQL that when no row is
returned it makes on up and parses it back
>
Thank you in advance for your help!!
>
Ben
Quote:
Originally Posted by
What language is your "Program" in? Check the recordcount on the
dataset returned and go from there, don't return the dummy record.
>
Cheers,
Jason Lepack
>
On Nov 20, 5:57 am, Ben <bor...@.gmail.comwrote:
>
>
>
Quote:
Originally Posted by
Hello,
>
Quote:
Originally Posted by
im having a problem integrating an SQL statement with my program,
it works fine when theres a result but throws an error when there is
no result,
is there anyway in SQL to make up a row if there isnt one that matches
the query for example in this i could put indicator values in the
returned fields then a simple check to see if its a proper field of my
indicator field
>
Quote:
Originally Posted by
I know ISNULL works with single values but that only works if there is
a row returned
>
Quote:
Originally Posted by
Does anyone know of any SQL syntax for MS SQL that when no row is
returned it makes on up and parses it back
>
Quote:
Originally Posted by
Thank you in advance for your help!!
>
Quote:
Originally Posted by
Ben- Hide quoted text -
>
- Show quoted text -
The Error Message is: exception : System.NullReferenceException:
Object reference not set to an instance of an object.
and its not really programming its a prebuilt assembly which has to be
used i can only alter the code around it, but this assembly throws an
error if there is nothing there so waht i need is, if there are no
values returned that it creats a dummy value, im not sure if you can
do that using a MS SQL statement
All that this assembly returns is either one record or nothing, pretty
useless i know :/ doesnt even return a recordset
Cheers
Ben|||On 20 Nov, 14:34, Ben <bor...@.gmail.comwrote:
Quote:
Originally Posted by
On 20 Nov, 13:33, Jason Lepack <jlep...@.gmail.comwrote:
>
>
>
>
>
Quote:
Originally Posted by
What language is your "Program" in? Check the recordcount on the
dataset returned and go from there, don't return the dummy record.
>
Quote:
Originally Posted by
Cheers,
Jason Lepack
>
Quote:
Originally Posted by
On Nov 20, 5:57 am, Ben <bor...@.gmail.comwrote:
>
Quote:
Originally Posted by
Quote:
Originally Posted by
Hello,
>
Quote:
Originally Posted by
Quote:
Originally Posted by
im having a problem integrating an SQL statement with my program,
it works fine when theres a result but throws an error when there is
no result,
is there anyway in SQL to make up a row if there isnt one that matches
the query for example in this i could put indicator values in the
returned fields then a simple check to see if its a proper field of my
indicator field
>
Quote:
Originally Posted by
Quote:
Originally Posted by
I know ISNULL works with single values but that only works if there is
a row returned
>
Quote:
Originally Posted by
Quote:
Originally Posted by
Does anyone know of any SQL syntax for MS SQL that when no row is
returned it makes on up and parses it back
>
Quote:
Originally Posted by
Quote:
Originally Posted by
Thank you in advance for your help!!
>
Quote:
Originally Posted by
Quote:
Originally Posted by
Ben- Hide quoted text -
>
Quote:
Originally Posted by
- Show quoted text -
>
The Error Message is: exception : System.NullReferenceException:
Object reference not set to an instance of an object.
>
and its not really programming its a prebuilt assembly which has to be
used i can only alter the code around it, but this assembly throws an
error if there is nothing there so waht i need is, if there are no
values returned that it creats a dummy value, im not sure if you can
do that using a MS SQL statement
>
All that this assembly returns is either one record or nothing, pretty
useless i know :/ doesnt even return a recordset
>
Cheers
>
Ben- Hide quoted text -
>
- Show quoted text -
Hey!
nevermind, my stupid brain thought of another idea, appologies for the
post it seems really stupid now >.< why didint i think of count...
Sigh
Thanks for your help anyway! :D
Regards
Ben
No comments:
Post a Comment