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.

Computed Field "Invalid Argument to Function"

8 posts in DataWindow Last posting was on 2009-04-03 15:18:38.0Z
Dan Cooperstock Posted on 2009-04-01 21:22:54.0Z
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Computed Field "Invalid Argument to Function"
From: Dan Cooperstock <info@Software4NonProfits.com>
Organization: Software4NonProfits.com
Message-ID: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 1 Apr 2009 13:22:54 -0800
X-Trace: forums-1-dub 1238620974 10.22.241.152 (1 Apr 2009 13:22:54 -0800)
X-Original-Trace: 1 Apr 2009 13:22:54 -0800, vip152.sybase.com
Lines: 19
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89092
Article PK: 418344

I have a global function gf_format_date(Date, String), returning String. (I
use it to return dates in English or French, depending on some criteria.)

If I try to use it as the expression for a DW computed field, as in:

gf_format_date(dateColumn, "a format")
or
gf_format_date(Date(Today()), "a format")

PB just keeps giving me "Invalid argument to function". I'm using PB 10.2.

This doesn't make any sense to me. Any bright ideas? Thanks.

---------------------------
Dan Cooperstock
DONATION web site: http://www.Software4Nonprofits.com
DONATION Support forums: http://forums.Software4Nonprofits.com
Email: mailto:info@Software4Nonprofits.com
Phone: 416-423-7722


Terry Dykstra [TeamSybase] Posted on 2009-04-01 23:05:44.0Z
Reply-To: "Terry Dykstra [TeamSybase]" <dontreply_tddykstra@forestoilca.x>
From: "Terry Dykstra [TeamSybase]" <tddykstra@forestoil.ca>
Newsgroups: sybase.public.powerbuilder.datawindow
References: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106>
In-Reply-To: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106>
Subject: Re: Computed Field "Invalid Argument to Function"
Lines: 31
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6001.18000
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18049
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49d3f348@forums-1-dub>
Date: 1 Apr 2009 15:05:44 -0800
X-Trace: forums-1-dub 1238627144 10.22.241.152 (1 Apr 2009 15:05:44 -0800)
X-Original-Trace: 1 Apr 2009 15:05:44 -0800, vip152.sybase.com
X-Authenticated-User: TeamSybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89093
Article PK: 418345

You're sure the gf takes a date and not a datetime?

--
--
Terry Dykstra (TeamSybase)
http://powerbuilder.codeXchange.sybase.com/
http://casexpress.sybase.com
product enhancement requests:
http://my.isug.com/cgi-bin/1/c/submit_enhancement

"Dan Cooperstock" <info@Software4NonProfits.com> wrote in message
news:Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106...
>I have a global function gf_format_date(Date, String), returning String. (I
> use it to return dates in English or French, depending on some criteria.)
>
> If I try to use it as the expression for a DW computed field, as in:
>
> gf_format_date(dateColumn, "a format")
> or
> gf_format_date(Date(Today()), "a format")
>
> PB just keeps giving me "Invalid argument to function". I'm using PB 10.2.
>
> This doesn't make any sense to me. Any bright ideas? Thanks.
>
> ---------------------------
> Dan Cooperstock
> DONATION web site: http://www.Software4Nonprofits.com
> DONATION Support forums: http://forums.Software4Nonprofits.com
> Email: mailto:info@Software4Nonprofits.com
> Phone: 416-423-7722


Dan Cooperstock Posted on 2009-04-01 23:13:49.0Z
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: Computed Field "Invalid Argument to Function"
From: Dan Cooperstock <info@Software4NonProfits.com>
References: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106> <49d3f348@forums-1-dub>
Organization: Software4NonProfits.com
Message-ID: <Xns9BE0C3A70C51EinfoSoftwareNonProfi@192.138.151.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 1 Apr 2009 15:13:49 -0800
X-Trace: forums-1-dub 1238627629 10.22.241.152 (1 Apr 2009 15:13:49 -0800)
X-Original-Trace: 1 Apr 2009 15:13:49 -0800, vip152.sybase.com
Lines: 32
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89094
Article PK: 418343

"Terry Dykstra [TeamSybase]" <tddykstra@forestoil.ca> wrote in
news:49d3f348@forums-1-dub:

> You're sure the gf takes a date and not a datetime?

Positive. And I tried it with the argument Today(), which is a DateTime
(as DW function), as well, same problem.

My observation, after some testing, is that no function that takes a Date
argument can be used in a DW expression without giving the "Invalid
argument to function" message. I tried it with a few of my functions that
take date arguments. Other types of argument worked.

My work-around was to create a 2nd function that takes a String argument
instead, and converts that String to a Date to do its work. Then in the
DW expression, I pass in String(dateColumn) instead of dateColumn, and it
all works.

BTW, my first approach at a work-around was to convert the Date arg to an
Any arg, pass that in, determine its type with Classname(arg), and do an
appropriate conversion. But the function always received a null value in
the Any arg, despite the fact that the column definitely had a value in
it.

Seems like two bugs, if you ask me!

---------------------------
Dan Cooperstock
DONATION web site: http://www.Software4Nonprofits.com
DONATION Support forums: http://forums.Software4Nonprofits.com
Email: mailto:info@Software4Nonprofits.com
Phone: 416-423-7722


Chris Werner Posted on 2009-04-02 07:46:46.0Z
From: "Chris Werner" <cwAT{PleaseNoSpam}f-s.de>
Newsgroups: sybase.public.powerbuilder.datawindow
References: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106> <49d3f348@forums-1-dub> <Xns9BE0C3A70C51EinfoSoftwareNonProfi@192.138.151.106>
Subject: Re: Computed Field "Invalid Argument to Function"
Lines: 63
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: <49d46d66$1@forums-1-dub>
Date: 1 Apr 2009 23:46:46 -0800
X-Trace: forums-1-dub 1238658406 10.22.241.152 (1 Apr 2009 23:46:46 -0800)
X-Original-Trace: 1 Apr 2009 23:46:46 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89095
Article PK: 418352

Hi Dan,

first of all I think the date() datawindow expression function takes a
String argument instead of a DateTime argument. This is explained
in the documentation.

Second I believe the problem you've observed has to do with the
limited return values of datawindow expressions. PB help states:

"An expression has a more limited set of datatypes than the functions
that can be part of the expression. Although the Date function returns
a date value, the whole expression is promoted to a DateTime value.
Therefore, if your expression consists of a single Date function, it will
appear that Date returns the wrong datatype. To display the date without
the time, choose an appropriate display format."

Although that isn't enough to explain the behaviour I guess that the
the promotion to DateTime takes place when an expression is given
as argument of a global function already.

Working with DateTime arguments may be a proper workaround
and prevent you from fiddling with Strings.


Chris Werner
f+s software gmbh

"Dan Cooperstock" <info@Software4NonProfits.com> schrieb im Newsbeitrag
news:Xns9BE0C3A70C51EinfoSoftwareNonProfi@192.138.151.106...

> "Terry Dykstra [TeamSybase]" <tddykstra@forestoil.ca> wrote in
> news:49d3f348@forums-1-dub:
>
>> You're sure the gf takes a date and not a datetime?
>
> Positive. And I tried it with the argument Today(), which is a DateTime
> (as DW function), as well, same problem.
>
> My observation, after some testing, is that no function that takes a Date
> argument can be used in a DW expression without giving the "Invalid
> argument to function" message. I tried it with a few of my functions that
> take date arguments. Other types of argument worked.
>
> My work-around was to create a 2nd function that takes a String argument
> instead, and converts that String to a Date to do its work. Then in the
> DW expression, I pass in String(dateColumn) instead of dateColumn, and it
> all works.
>
> BTW, my first approach at a work-around was to convert the Date arg to an
> Any arg, pass that in, determine its type with Classname(arg), and do an
> appropriate conversion. But the function always received a null value in
> the Any arg, despite the fact that the column definitely had a value in
> it.
>
> Seems like two bugs, if you ask me!
>
> ---------------------------
> Dan Cooperstock
> DONATION web site: http://www.Software4Nonprofits.com
> DONATION Support forums: http://forums.Software4Nonprofits.com
> Email: mailto:info@Software4Nonprofits.com
> Phone: 416-423-7722


Dan Cooperstock Posted on 2009-04-02 11:46:45.0Z
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: Computed Field "Invalid Argument to Function"
From: Dan Cooperstock <info@Software4NonProfits.com>
References: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106> <49d3f348@forums-1-dub> <Xns9BE0C3A70C51EinfoSoftwareNonProfi@192.138.151.106> <49d46d66$1@forums-1-dub>
Organization: Software4NonProfits.com
Message-ID: <Xns9BE14F27969B9infoSoftwareNonProfi@192.138.151.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 2 Apr 2009 03:46:45 -0800
X-Trace: forums-1-dub 1238672805 10.22.241.152 (2 Apr 2009 03:46:45 -0800)
X-Original-Trace: 2 Apr 2009 03:46:45 -0800, vip152.sybase.com
Lines: 43
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89097
Article PK: 418347

"Chris Werner" <cwAT{PleaseNoSpam}f-s.de> wrote in
news:49d46d66$1@forums-1-dub:

> PB help states:
>
> "An expression has a more limited set of datatypes than the functions
> that can be part of the expression. Although the Date function returns
> a date value, the whole expression is promoted to a DateTime value.
> Therefore, if your expression consists of a single Date function, it
> will appear that Date returns the wrong datatype. To display the date
> without the time, choose an appropriate display format."
>
> Although that isn't enough to explain the behaviour I guess that the
> the promotion to DateTime takes place when an expression is given
> as argument of a global function already.
>
> Working with DateTime arguments may be a proper workaround
> and prevent you from fiddling with Strings.
>
> Chris Werner
> f+s software gmbh

I thought you were right about this, so I wrote another method
gf_format_datetime(datetime, string), and it works when I pass in the
Today() function as the first arg.

Unfortunately, when I pass in a column with type Date as the first arg,
the painter allows it, but in the debugger I see that the new function is
receiving null as its argument, and thus the display is always the empty
string! And I know that the column's value isn't null, both because it's
coming from a non-nullable field in the DB, and because when I converted
it to a String, and passed it to a method that expected a String, it
worked perfectly.

So, this is 1/2 of a solution. I still think there's a bug passing Date
columns as arguments.

---------------------------
Dan Cooperstock
DONATION web site: http://www.Software4Nonprofits.com
DONATION Support forums: http://forums.Software4Nonprofits.com
Email: mailto:info@Software4Nonprofits.com
Phone: 416-423-7722


Dan Cooperstock Posted on 2009-04-02 12:01:53.0Z
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: Computed Field "Invalid Argument to Function"
From: Dan Cooperstock <info@Software4NonProfits.com>
References: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106> <49d3f348@forums-1-dub> <Xns9BE0C3A70C51EinfoSoftwareNonProfi@192.138.151.106> <49d46d66$1@forums-1-dub> <Xns9BE14F27969B9infoSoftwareNonProfi@192.138.151.106>
Organization: Software4NonProfits.com
Message-ID: <Xns9BE151B8942AinfoSoftwareNonProfi@192.138.151.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 2 Apr 2009 04:01:53 -0800
X-Trace: forums-1-dub 1238673713 10.22.241.152 (2 Apr 2009 04:01:53 -0800)
X-Original-Trace: 2 Apr 2009 04:01:53 -0800, vip152.sybase.com
Lines: 22
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89098
Article PK: 418349

Dan Cooperstock <info@Software4NonProfits.com> wrote in
news:Xns9BE14F27969B9infoSoftwareNonProfi@192.138.151.106:

> I wrote another method
> gf_format_datetime(datetime, string), and it works when I pass in the
> Today() function as the first arg.
>
> Unfortunately, when I pass in a column with type Date as the first
> arg, the painter allows it, but in the debugger I see that the new
> function is receiving null as its argument, and thus the display is
> always the empty string!

OK, I figured out how to work around that too. Instead of calling
gf_format_datetime(dateField, "format"), I call gf_format_datetime(DateTime
(dateField), "format"), and it works!

---------------------------
Dan Cooperstock
DONATION web site: http://www.Software4Nonprofits.com
DONATION Support forums: http://forums.Software4Nonprofits.com
Email: mailto:info@Software4Nonprofits.com
Phone: 416-423-7722


Jeremy Lakeman Posted on 2009-04-02 11:59:51.0Z
From: Jeremy Lakeman <jeremy.lakeman@gmail.com>
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: Computed Field "Invalid Argument to Function"
Date: Thu, 2 Apr 2009 04:59:51 -0700 (PDT)
Organization: http://groups.google.com
Lines: 53
Message-ID: <f87284b5-ee8a-407d-9d3f-ac7486c38777@f1g2000prb.googlegroups.com>
References: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106> <49d3f348@forums-1-dub> <Xns9BE0C3A70C51EinfoSoftwareNonProfi@192.138.151.106> <49d46d66$1@forums-1-dub> <Xns9BE14F27969B9infoSoftwareNonProfi@192.138.151.106>
NNTP-Posting-Host: 114.30.106.123
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1238673604 3278 127.0.0.1 (2 Apr 2009 12:00:04 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 2 Apr 2009 12:00:04 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: f1g2000prb.googlegroups.com; posting-host=114.30.106.123; posting-account=euaBtgoAAAC_vDxfsxmpMKlBxHaHpmRS
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1b3) Gecko/20090305 Firefox/3.1b3,gzip(gfe),gzip(gfe)
Path: forums-1-dub!forums-master!newssvr.sybase.com!news-sj-1.sprintlink.net!news-peer1.sprintlink.net!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!f1g2000prb.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89100
Article PK: 418351

On Apr 2, 9:46 pm, Dan Cooperstock <i...@Software4NonProfits.com>

wrote:
> "Chris Werner" <cwAT{PleaseNoSpam}f-s.de> wrote innews:49d46d66$1@forums-1-dub:
>
>
>
> > PB help states:
>
> > "An expression has a more limited set of datatypes than the functions
> > that can be part of the expression. Although the Date function returns
> > a date value, the whole expression is promoted to a DateTime value.
> > Therefore, if your expression consists of a single Date function, it
> > will appear that Date returns the wrong datatype. To display the date
> > without the time, choose an appropriate display format."
>
> > Although that isn't enough to explain the behaviour I guess that the
> > the promotion to DateTime takes place when an expression is given
> > as argument of a global function already.
>
> > Working with DateTime arguments may be a proper workaround
> > and prevent you from fiddling with Strings.
>
> > Chris Werner
> > f+s software gmbh
>
> I thought you were right about this, so I wrote another method
> gf_format_datetime(datetime, string), and it works when I pass in the
> Today() function as the first arg.
>
> Unfortunately, when I pass in a column with type Date as the first arg,
> the painter allows it, but in the debugger I see that the new function is
> receiving null as its argument, and thus the display is always the empty
> string! And I know that the column's value isn't null, both because it's
> coming from a non-nullable field in the DB, and because when I converted
> it to a String, and passed it to a method that expected a String, it
> worked perfectly.
>
> So, this is 1/2 of a solution. I still think there's a bug passing Date
> columns as arguments.
>
> ---------------------------
> Dan Cooperstock
> DONATION web site:http://www.Software4Nonprofits.com
> DONATION Support forums:http://forums.Software4Nonprofits.com
> Email: mailto:i...@Software4Nonprofits.com
> Phone: 416-423-7722

Have you tried;
f_func(date(today()))

Or
f_func(datetime(column,00:00:00))


Dan Cooperstock Posted on 2009-04-03 15:18:38.0Z
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: Computed Field "Invalid Argument to Function"
From: Dan Cooperstock <info@Software4NonProfits.com>
References: <Xns9BE0B0D884DAEinfoSoftwareNonProfi@192.138.151.106> <49d3f348@forums-1-dub> <Xns9BE0C3A70C51EinfoSoftwareNonProfi@192.138.151.106> <49d46d66$1@forums-1-dub> <Xns9BE14F27969B9infoSoftwareNonProfi@192.138.151.106> <f87284b5-ee8a-407d-9d3f-ac7486c38777@f1g2000prb.googlegroups.com>
Organization: Software4NonProfits.com
Message-ID: <Xns9BE27311668EEinfoSoftwareNonProfi@192.138.151.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 3 Apr 2009 07:18:38 -0800
X-Trace: forums-1-dub 1238771918 10.22.241.152 (3 Apr 2009 07:18:38 -0800)
X-Original-Trace: 3 Apr 2009 07:18:38 -0800, vip152.sybase.com
Lines: 25
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:89113
Article PK: 418362

Jeremy Lakeman <jeremy.lakeman@gmail.com> wrote in
news:f87284b5-ee8a-407d-9d3f-ac7486c38777@f1g2000prb.googlegroups.com:

> Have you tried;
> f_func(date(today()))
>
> Or
> f_func(datetime(column,00:00:00))

I think I said early on that passing Date(Today()) to a function expecting
a Date still gets "Invalid Argument to Function". I'm pretty well convinced
at this point that there is no way to use functions expecting Date
arguments in DW expressions.

Your 2nd suggestion is what I came up with (after others' suggestions), but
the function has to be expecting a DateTime argument, and the 2nd argument
to the DateTime conversion function isn't really needed unless you care
what the time component is (which I don't).

---------------------------
Dan Cooperstock
DONATION web site: http://www.Software4Nonprofits.com
DONATION Support forums: http://forums.Software4Nonprofits.com
Email: mailto:info@Software4Nonprofits.com
Phone: 416-423-7722