Hi, it sound silly, but there it is. If I run this SQL from within DataManager (i'm using Pervasive V.8)
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE '2%'))
AND ((klnasl like '%'))
AND ((length(klklas) = 2))
ORDER BY klklas;
i get corect result, but when i try to get results from the stored procedure
CREATE PROCEDURE SP_KTSKLD(IN :klklas char (9), IN :klnasl CHAR(34), IN :tip CHAR(1), IN ORDER CHAR(20))
RETURNS(
klklas char(9),
klnasl char(34)
) with default handler
as
declare :dol integer
set :dol = lengthklklas)
set :klklas = :klklas + '%';
set :klnasl = :klnasl + '%';
if ol < 2 then
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 2) or tip = '0'))
ORDER BY klklas;
else if ol < 3 then
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 3) or tip = '0'))
ORDER BY klklas;
else if ol < 4 then
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 6) or tip = '0'))
ORDER BY klklas;
else
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 9) or tip = '0'))
ORDER BY klklas;
end if;
end if;
end if;
using call SP_KTSKLD('2', '', '1', '')
the first two (not allways, but there are allmost always duplicate key values) rows have IDENTICAL klklas values. Indexes are good, so i don't have a clue about what it might be the reason for such strange results.
My second question is : How can i use variables Var) from within DataManager since this is the only way to check whether sp will work the way it should? Any alternative editors ??
Thanks for your answers.
Andrej
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE '2%'))
AND ((klnasl like '%'))
AND ((length(klklas) = 2))
ORDER BY klklas;
i get corect result, but when i try to get results from the stored procedure
CREATE PROCEDURE SP_KTSKLD(IN :klklas char (9), IN :klnasl CHAR(34), IN :tip CHAR(1), IN ORDER CHAR(20))
RETURNS(
klklas char(9),
klnasl char(34)
) with default handler
as
declare :dol integer
set :dol = lengthklklas)
set :klklas = :klklas + '%';
set :klnasl = :klnasl + '%';
if ol < 2 then
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 2) or tip = '0'))
ORDER BY klklas;
else if ol < 3 then
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 3) or tip = '0'))
ORDER BY klklas;
else if ol < 4 then
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 6) or tip = '0'))
ORDER BY klklas;
else
SELECT
klklas, klnasl FROM ktskld
WHERE ((klklas LIKE :klklas) or klklas = ''))
AND ((klnasl like :klnasl) or klnasl = ''))
AND ((length(klklas) = 9) or tip = '0'))
ORDER BY klklas;
end if;
end if;
end if;
using call SP_KTSKLD('2', '', '1', '')
the first two (not allways, but there are allmost always duplicate key values) rows have IDENTICAL klklas values. Indexes are good, so i don't have a clue about what it might be the reason for such strange results.
My second question is : How can i use variables Var) from within DataManager since this is the only way to check whether sp will work the way it should? Any alternative editors ??
Thanks for your answers.
Andrej