473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Error in following query

CREATE OR REPLACE FUNCTION efi_etl.AAA(in SYSID varchar, in periods varchar) RETURNS VOID AS '
DECLARE walker integer; startPeriod integer; endPeriod integer; tmpStr varchar; periodStr varchar; periodLabel varchar;
BEGIN
periodStr = periods;
if (periodStr != '''') AND (substr(periodStr, 1, 1) != ''0'') then
periodStr = ''0;'' || periodStr;
end if;
walker = 1;
LOOP
tmpStr = split_part(periodStr, '';'', walker);
if tmpStr = '''' then
startPeriod = 0;
endPeriod = 9999;
else
startPeriod = cast(tmpStr as integer);
if (startPeriod = 0) then
tmpStr = split_part(periodStr, '';'', walker + 1);
if ((tmpStr = '''') OR (tmpStr = ''0'')) then
endPeriod = 9999;
else
endPeriod = cast(tmpStr as integer);
end if;
else
startPeriod = startPeriod + 1;
tmpStr = split_part(periodStr, '';'', walker + 1);
if (tmpStr = '''') then
endPeriod = 9999;
else
endPeriod = cast(tmpStr as integer);
end if;
end if;
end if;
if ((startPeriod = 0) AND (endPeriod = 9999)) then
periodLabel = ''Current'';
elseif (endPeriod = 9999) then
periodLabel = ''Over '' || cast(startPeriod as varchar);
else
periodLabel = cast(startPeriod as varchar) || '' to '' || cast(endPeriod as varchar);
end if;
insert into efi_etl."T$AgingPeriodAP" (systemid, startingperiod, endingperiod, label)
values (SYSID, startPeriod, endPeriod, periodLabel);
if (endPeriod = 9999) then
exit;
else
walker = walker + 1;
end if;
END LOOP;
END;
' LANGUAGE plpgsql VOLATILE;

When I execute the above function with hard-coded values - it runs
example:- select AAA('ABC','0;30')

But when I run the same with database values - it fails
example:-
Select
APC."System-ID" as SYSID,
PRO_ELEMENT(APC."Aging-Categories", 1, 1) as AGING1,
PRO_ELEMENT(APC."Aging-Categories", 2, 2) as AGING2,
PRO_ELEMENT(APC."Aging-Categories", 3, 3) as AGING3,
PRO_ELEMENT(APC."Aging-Categories", 4, 4) as AGING4,
PRO_ELEMENT(APC."Aging-Categories", 5, 5) as AGING5
from PUB."AP-Ctl" APC
where 1=1

select AAA((SYSID, 'AGING1 || '';'' || AGING2 || '';'' || AGING3 || '';'' || AGING4 || '';'' || AGING5'))
Oct 5 '07 #1
1 2444
rski
700 Expert 512MB
But when I run the same with database values - it fails
example:-
Select
APC."System-ID" as SYSID,
PRO_ELEMENT(APC."Aging-Categories", 1, 1) as AGING1,
PRO_ELEMENT(APC."Aging-Categories", 2, 2) as AGING2,
PRO_ELEMENT(APC."Aging-Categories", 3, 3) as AGING3,
PRO_ELEMENT(APC."Aging-Categories", 4, 4) as AGING4,
PRO_ELEMENT(APC."Aging-Categories", 5, 5) as AGING5
from PUB."AP-Ctl" APC
where 1=1

select AAA((SYSID, 'AGING1 || '';'' || AGING2 || '';'' || AGING3 || '';'' || AGING4 || '';'' || AGING5'))
I am not sure what the above code sholud do?
Could u explain it (i know what are select, as, from , where)?
Oct 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Bryan Tang | last post by:
I built an ASP to search the content in index server. It is ok if search in English. Whenever I search in Chinese, I will got the following error message, CreateRecordset ?u?~ '80004005' ...
1
by: Sean C. | last post by:
Helpful folks, I have recently migrated our test server, which runs Win NT 4, from V7.2 FP11 to V8.1.3. Just about everything works wondefully, except I am having major problems getting the...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
4
by: Polly | last post by:
I had a macro that ran a parameter query and created and opened an Excel file with the system date as part of the file name, but I had to change the file name by hand. So I converted the macro to...
18
by: William | last post by:
I have the following javascript function that updates a scroll_list and sends the updated entry (with its index) to a server script ( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further...
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
5
by: Omer | last post by:
Hi, I am using C# 2.0 along with MS Access database. All my queries are working perfectly fine, but one inner join query is ocntinously throwing. I ahve tried it both from code and running...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
2
by: salvadorvp | last post by:
Hi, I have the following code that gives me this odd error message at a line of code inside the PEAR libraries: "Fatal error: Call to undefined function: MDB2_Driver_mssql::getMessage(). in...
7
by: Yesurbius | last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.