New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subquery in CASE [CORE1200] #1625
Comments
Modified by: Matyas Novak (logik)description: Complex query failed on error: Tables: CREATE TABLE clenstvi ( select Nazev, RegistracniKategorieId => Complex query failed on error: SQL Script: CREATE TABLE registracnikategorie ( CREATE TABLE clenstvi ( select Nazev, RegistracniKategorieId |
Commented by: Sean Leyne (seanleyne) The error the SQL is bad. The SQL has 2 references to the "registracniKategorie" but without alias -- in order to have 2 distinct references, you need to use aliases. This is expected behaviour. |
Modified by: Sean Leyne (seanleyne)status: Open [ 1 ] => Resolved [ 5 ] resolution: Won't Fix [ 2 ] |
Commented by: Matyas Novak (logik) I don't think so select Nazev, RegistracniKategorieId 2) IMHO aliases in subqueries shouldn't be required, inner table should be preffered. I'm wrong? 3) The query dosen't work even with aliases are specified. , try: select r1.Nazev, r1.RegistracniKategorieId Best regards PS: Even if the query was wrong, the error message should be different (clearer). |
Modified by: @dyemanovstatus: Resolved [ 5 ] => Reopened [ 4 ] assignee: Dmitry Yemanov [ dimitr ] resolution: Won't Fix [ 2 ] => |
Commented by: Claudio Valderrama C. (robocop) This entry has nothing to do with isql, hence I assigned it to "Engine" instead. |
Modified by: Claudio Valderrama C. (robocop)Component: Engine [ 10000 ] Component: ISQL [ 10003 ] => |
Modified by: @pcisarWorkflow: jira [ 11749 ] => Firebird [ 15540 ] |
Submitted by: Matyas Novak (logik)
Votes: 1
Complex query failed on error:
"ISC ERROR CODE:335544343
invalid request BLR at offset 282
context already in use (BLR error)"
The complex query contains subquery in case statement. If I replace
the subquery by constant no error is reported, same as if I try run
the subquery separately.
SQL Script:
CREATE TABLE registracnikategorie (
RegistracniKategorieID integer NOT NULL PRIMARY KEY,
Nazev VARCHAR(32) NOT NULL COLLATE WIN1250,
Rok NUMERIC(4) default 0000 ,
JednotkaID NUMERIC(18) NOT NULL,
Typ INTEGER default 0 Check (Typ IN (0,1,2)),
UNIQUE (JednotkaID,Rok,Nazev)
);
CREATE TABLE clenstvi (
ClenstviID integer NOT NULL PRIMARY KEY,
JednotkaID NUMERIC(18) NOT NULL,
OsobaID integer NOT NULL,
Typ integer NOT NULL,
Vznik DATE ,
Zanik DATE
);
select Nazev, RegistracniKategorieId
FROM RegistracniKategorie
WHERE
JednotkaID = :JednotkaID AND
Rok=:Rok AND
Typ <=
(CASE
(
SELECT MAX(Typ) FROM Clenstvi
WHERE OsobaID = :OsobaID AND
JednotkaID = :JednotkaID AND
(Vznik IS NULL OR EXTRACT(Year FROM Vznik) <= :Rok) AND
(Zanik IS NULL OR EXTRACT(Year FROM Zanik) >= :Rok)
)
WHEN 2 THEN IIF(EXISTS(SELECT RegistracniKategorieID FROM registracniKategorie WHERE JednotkaId = :JednotkaID AND Rok =:Rok AND Typ=1),2,3)
WHEN 3 THEN 3
ELSE 1
END
)
The text was updated successfully, but these errors were encountered: