Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Pass Null values through the retrieval argument

2 posts in DataWindow Last posting was on 2009-04-15 22:39:01.0Z
Bojarajan Posted on 2009-04-15 21:12:16.0Z
From: "Bojarajan" <tbojarajan@gmail.com>
Newsgroups: sybase.public.powerbuilder.datawindow
Organization: 65.112.250.245
X-Newsreader: AspNNTP 1.50 (JodoHost)
Subject: Pass Null values through the retrieval argument
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49e64db0$1@forums-1-dub>
Date: 15 Apr 2009 14:12:16 -0700
X-Trace: forums-1-dub 1239829936 10.22.241.152 (15 Apr 2009 14:12:16 -0700)
X-Original-Trace: 15 Apr 2009 14:12:16 -0700, vip152.sybase.com
Lines: 61
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89170
Article PK: 418422

Hi,

I am trying to pass the null values through Powerbuilder datawindow select
query, but i am not getting the correct result when i pass null values and also
passing values in the retrieval argument. I would like to execute the select
query either way,

For example
I would like to get data based on some model code, so i am passing like
@model = 'BN'
some time the user don't want to pass model code value but they need to see all
the values. this case @model = null. The below query is working in sybase but it
is not working in PB.

Query 1
declare @model char(10),
@vers char(5)
select @model = 'BN'
select @vers = 'TRI'
select convert(char(8),c_date,1), b.defect_demerit,count(distinct
a.unit_serial_nbr) from dbo.UNIT a, dbo.UNIT_DEFECT b
where a.unit_serial_nbr *= b.unit_serial_nbr
and a.complete_date between '04/01/2009 00:00:00' and '04/14/2009 23:23:23'
and (@model = null or a.model_code = @model)
and (@vers = null or a.model_version = @vers)
group by convert(char(8),complete_date,1),b.defect_demerit
order by convert(char(8),complete_date,1)

Query 2
declare @model char(10),
@vers char(5)
select @model = null
select @vers = null
select convert(char(8),c_date,1), b.defect_demerit,count(distinct
a.unit_serial_nbr) from dbo.UNIT a, dbo.UNIT_DEFECT b
where a.unit_serial_nbr *= b.unit_serial_nbr
and a.complete_date between '04/01/2009 00:00:00' and '04/14/2009 23:23:23'
and (@model = null or a.model_code = @model)
and (@vers = null or a.model_version = @vers)
group by convert(char(8),complete_date,1),b.defect_demerit
order by convert(char(8),complete_date,1)

The above query extracting the data from sybase. The same i am using this query
in PB like


select convert(char(8),c_date,1), b.defect_demerit,count(distinct
a.unit_serial_nbr) from dbo.UNIT a, dbo.UNIT_DEFECT b
where a.unit_serial_nbr *= b.unit_serial_nbr
and a.complete_date between '04/01/2009 00:00:00' and '04/14/2009 23:23:23'
and (:model = null or a.model_code = :model)
and (:vers = null or a.model_version = :vers)
group by convert(char(8),complete_date,1),b.defect_demerit
order by convert(char(8),complete_date,1)

This is not working it is giving the result sets only when i pass the model
code. Please let me know if you have any idea about this.


---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp


"Paul Horan[Sybase]" <phoran_remove Posted on 2009-04-15 22:39:01.0Z
From: "Paul Horan[Sybase]" <phoran_remove@remove_sybase.com>
Newsgroups: sybase.public.powerbuilder.datawindow
References: <49e64db0$1@forums-1-dub>
Subject: Re: Pass Null values through the retrieval argument
Lines: 80
Organization: Sybase
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49e66205$1@forums-1-dub>
Date: 15 Apr 2009 15:39:01 -0700
X-Trace: forums-1-dub 1239835141 10.22.241.152 (15 Apr 2009 15:39:01 -0700)
X-Original-Trace: 15 Apr 2009 15:39:01 -0700, vip152.sybase.com
X-Authenticated-User: teamsybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89171
Article PK: 418419

Don't use "= NULL", use "is NULL"

--
Paul Horan[Sybase]
paulhoran.pbdjmagazine.com

"Bojarajan" <tbojarajan@gmail.com> wrote in message
news:49e64db0$1@forums-1-dub...
> Hi,
>
> I am trying to pass the null values through Powerbuilder datawindow select
> query, but i am not getting the correct result when i pass null values and
> also
> passing values in the retrieval argument. I would like to execute the
> select
> query either way,
>
> For example
> I would like to get data based on some model code, so i am passing like
> @model = 'BN'
> some time the user don't want to pass model code value but they need to
> see all
> the values. this case @model = null. The below query is working in sybase
> but it
> is not working in PB.
>
> Query 1
> declare @model char(10),
> @vers char(5)
> select @model = 'BN'
> select @vers = 'TRI'
> select convert(char(8),c_date,1), b.defect_demerit,count(distinct
> a.unit_serial_nbr) from dbo.UNIT a, dbo.UNIT_DEFECT b
> where a.unit_serial_nbr *= b.unit_serial_nbr
> and a.complete_date between '04/01/2009 00:00:00' and '04/14/2009
> 23:23:23'
> and (@model = null or a.model_code = @model)
> and (@vers = null or a.model_version = @vers)
> group by convert(char(8),complete_date,1),b.defect_demerit
> order by convert(char(8),complete_date,1)
>
> Query 2
> declare @model char(10),
> @vers char(5)
> select @model = null
> select @vers = null
> select convert(char(8),c_date,1), b.defect_demerit,count(distinct
> a.unit_serial_nbr) from dbo.UNIT a, dbo.UNIT_DEFECT b
> where a.unit_serial_nbr *= b.unit_serial_nbr
> and a.complete_date between '04/01/2009 00:00:00' and '04/14/2009
> 23:23:23'
> and (@model = null or a.model_code = @model)
> and (@vers = null or a.model_version = @vers)
> group by convert(char(8),complete_date,1),b.defect_demerit
> order by convert(char(8),complete_date,1)
>
> The above query extracting the data from sybase. The same i am using this
> query
> in PB like
>
>
> select convert(char(8),c_date,1), b.defect_demerit,count(distinct
> a.unit_serial_nbr) from dbo.UNIT a, dbo.UNIT_DEFECT b
> where a.unit_serial_nbr *= b.unit_serial_nbr
> and a.complete_date between '04/01/2009 00:00:00' and '04/14/2009
> 23:23:23'
> and (:model = null or a.model_code = :model)
> and (:vers = null or a.model_version = :vers)
> group by convert(char(8),complete_date,1),b.defect_demerit
> order by convert(char(8),complete_date,1)
>
> This is not working it is giving the result sets only when i pass the
> model
> code. Please let me know if you have any idea about this.
>
>
> ---== Posted via the PFCGuide Web Newsreader ==---
> http://www.pfcguide.com/_newsgroups/group_list.asp