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.

expression must match error

3 posts in General Discussion Last posting was on 2013-03-22 20:34:04.0Z
Javed Rehman Posted on 2013-03-22 19:07:37.0Z
Sender: 78eb.514caba6.846930886@sybase.com
From: Javed Rehman
Newsgroups: sybase.public.powerbuilder.general
Subject: expression must match error
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <514cabf9.790b.1681692777@sybase.com>
NNTP-Posting-Host: 172.20.134.41
X-Original-NNTP-Posting-Host: 172.20.134.41
Date: 22 Mar 2013 11:07:37 -0800
X-Trace: forums-1-dub 1363979257 172.20.134.41 (22 Mar 2013 11:07:37 -0800)
X-Original-Trace: 22 Mar 2013 11:07:37 -0800, 172.20.134.41
Lines: 19
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.general:250048
Article PK: 1308575

I am building a search expression for one of my data window,
below is the code i am using:

ls_dr_no = string(ld_dr_no)
ls_posting_date = string(ld_posting_date)
ll_rowfound = a_dw.find('dr_no="' + ls_dr_no + '" and
audit_posting_date="' + ls_posting_date +
'"',1,a_dw.rowcount())

a_dw has both columns dr_no and audit_posting_date in it.
When I use the above expression I get an error message that
expression types must match. If I try to build string with
ld_dr_no(decimal datatype) and ld_posting_date (date
datatype) the program won't even compile beause compiler
tells me that I am building a string by concatenating date
or decimal datatype to it. Is not possible to search thru
the datawindow columns whose datatype is other then string?
If it is how do I build my search string? Can someone please
help. Thanks.


Scott Morris Posted on 2013-03-22 19:37:35.0Z
Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes
Newsgroups: sybase.public.powerbuilder.general
Subject: Re: expression must match error
References: <514cabf9.790b.1681692777@sybase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: "Scott Morris" <bogus@abc.def>
Message-ID: <op.wuc4svv9q59cbq@scott-win7.divinv.net>
User-Agent: Opera Mail/11.51 (Win32)
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 22 Mar 2013 11:37:35 -0800
X-Trace: forums-1-dub 1363981055 172.20.134.152 (22 Mar 2013 11:37:35 -0800)
X-Original-Trace: 22 Mar 2013 11:37:35 -0800, vip152.sybase.com
Lines: 45
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.general:250049
Article PK: 1308574


On Fri, 22 Mar 2013 15:07:37 -0400, Javed <Rehman> wrote:

> I am building a search expression for one of my data window,
> below is the code i am using:
>
> ls_dr_no = string(ld_dr_no)
> ls_posting_date = string(ld_posting_date)
> ll_rowfound = a_dw.find('dr_no="' + ls_dr_no + '" and
> audit_posting_date="' + ls_posting_date +
> '"',1,a_dw.rowcount())
>
> a_dw has both columns dr_no and audit_posting_date in it.
> When I use the above expression I get an error message that
> expression types must match. If I try to build string with
> ld_dr_no(decimal datatype) and ld_posting_date (date
> datatype) the program won't even compile beause compiler
> tells me that I am building a string by concatenating date
> or decimal datatype to it. Is not possible to search thru
> the datawindow columns whose datatype is other then string?
> If it is how do I build my search string? Can someone please
> help. Thanks.

In the future, it will help if you post the actual string that you are
providing to the function, rather than the code. This will eliminate a
lot of guessing about the actual content. You are assuming that you can
compare a date/datetime column to a string. You cannot and that is the
problem. In your expression, you must convert your date literal to the
appropriate datatype within the expression itself. Your expression should
end up like:

dr_no=5 and audit_date = date('2013-03-22')

Note that somewhere, IIRC, the documentation states that YYYY-MM-DD format
is considered safe for conversion regardless of regional settings. Below
is one example of how I do this for a filter - same rules apply for both
find and filter functions. Also note that I assign the expression to a
string and the supply that string to the filter function. This makes it
easier to see what the actual string is and allows me to manipulate it in
the debugger if needed.

ls_filter = "ror_start_date >= datetime(date('" +
string(lr_periods[li_x].start_date, "yyyy-mm-dd") + "')) "
li_ret = nds_inhouse_returns.Setfilter (ls_filter)

Cumbersome, isn't it!


Javed Rehman Posted on 2013-03-22 20:34:04.0Z
Sender: 7e13.514cbfa3.846930886@sybase.com
From: Javed Rehman
Newsgroups: sybase.public.powerbuilder.general
Subject: Re: expression must match error
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <514cc03c.7e26.1681692777@sybase.com>
References: <op.wuc4svv9q59cbq@scott-win7.divinv.net>
NNTP-Posting-Host: 172.20.134.41
X-Original-NNTP-Posting-Host: 172.20.134.41
Date: 22 Mar 2013 12:34:04 -0800
X-Trace: forums-1-dub 1363984444 172.20.134.41 (22 Mar 2013 12:34:04 -0800)
X-Original-Trace: 22 Mar 2013 12:34:04 -0800, 172.20.134.41
Lines: 73
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.general:250051
Article PK: 1308577


> On Fri, 22 Mar 2013 15:07:37 -0400, Javed <Rehman> wrote:
>
> > I am building a search expression for one of my data
> > window, below is the code i am using:
> >
> > ls_dr_no = string(ld_dr_no)
> > ls_posting_date = string(ld_posting_date)
> > ll_rowfound = a_dw.find('dr_no="' + ls_dr_no + '" and
> > audit_posting_date="' + ls_posting_date +
> > '"',1,a_dw.rowcount())
> >
> > a_dw has both columns dr_no and audit_posting_date in
> > it. When I use the above expression I get an error
> > message that expression types must match. If I try to
> > build string with ld_dr_no(decimal datatype) and
> > ld_posting_date (date datatype) the program won't even
> > compile beause compiler tells me that I am building a
> > string by concatenating date or decimal datatype to it.
> > Is not possible to search thru the datawindow columns
> > whose datatype is other then string? If it is how do I
> > build my search string? Can someone please help. Thanks.
>
> In the future, it will help if you post the actual string
> that you are providing to the function, rather than the
> code. This will eliminate a lot of guessing about the
> actual content. You are assuming that you can compare a
> date/datetime column to a string. You cannot and that is
> the problem. In your expression, you must convert your
> date literal to the appropriate datatype within the
> expression itself. Your expression should end up like:
>
> dr_no=5 and audit_date = date('2013-03-22')
>
> Note that somewhere, IIRC, the documentation states that
> YYYY-MM-DD format is considered safe for conversion
> regardless of regional settings. Below is one example
> of how I do this for a filter - same rules apply for both
> find and filter functions. Also note that I assign the
> expression to a string and the supply that string to the
> filter function. This makes it easier to see what the
> actual string is and allows me to manipulate it in the
> debugger if needed.
>
> ls_filter = "ror_start_date >= datetime(date('" +
> string(lr_periods[li_x].start_date, "yyyy-mm-dd") + "')) "
> li_ret = nds_inhouse_returns.Setfilter (ls_filter)
>
> Cumbersome, isn't it!

Scott: thanks as always for your advice, you were abs right
my expression had basic flaw and bruce armstrong also
responded to my same question over at snc.com, here is the
response I wrote to him and I am adding this here for future
refrence:

"Bruce thank you very much Scott Moris has also answered in
sybase forum and you both are correct I had to build
expression by passing the PB fucntions also so when the
expression is evaluated it actually converts the literal to
the desired datatype my new expression is something like
this:


ls_search = "dr_no= dec('" + ls_dr_no + "') and
audit_posting_date=date('" + ls_posting_date + "')"


and this eventually returns:


dr_no=dec('5') and audit_posting_date=date('02/13/2013') and
this works perfectly. Thanks to both of you.
"