Skip to content
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

"no current record for fetch operation" when "INNER" joining with stored procedure [CORE6124] #6373

Closed
firebird-automations opened this issue Aug 13, 2019 · 9 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @livius2

SET TERM ^ ;

CREATE PROCEDURE PSTRID1
( IN_ID1 VARCHAR(100))
RETURNS
( ID1 VARCHAR(100))
AS
BEGIN
ID1 = IN_ID1;
SUSPEND;
END^

SET TERM ; ^

--------------------------------------------------

SELECT
*
FROM
RDB$RELATIONS R
INNER JOIN PSTRID1(R.RDB$RELATION_NAME) P ON P.ID1 = R.RDB$RELATION_NAME

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

description: SET TERM ^ ;

CREATE PROCEDURE PSTRID
( IN_ID1 VARCHAR(100), IN_ID2 VARCHAR(100))
RETURNS
( ID1 VARCHAR(100), ID2 VARCHAR(100))
AS
BEGIN
ID1 = IN_ID1;
ID2 = IN_ID2;
SUSPEND;
END^

SET TERM ; ^

SELECT
*
FROM
RDB$RELATIONS R
INNER JOIN
(SELECT
*
FROM
RDB$RELATION_FIELDS F
INNER JOIN PSTRID(F.RDB$RELATION_NAME, F.RDB$FIELD_NAME) P ON P.ID1 = F.RDB$RELATION_NAME AND P.ID2 = F.RDB$FIELD_NAME ROWS 2) F2 ON R.RDB$RELATION_NAME = F2.RDB$RELATION_NAME

=>

SET TERM ^ ;

CREATE PROCEDURE PSTRID
( IN_ID1 VARCHAR(100), IN_ID2 VARCHAR(100))
RETURNS
( ID1 VARCHAR(100), ID2 VARCHAR(100))
AS
BEGIN
ID1 = IN_ID1;
ID2 = IN_ID2;
SUSPEND;
END^

SET TERM ; ^

SELECT
*
FROM
RDB$RELATIONS R
INNER JOIN PSTRID(R.RDB$RELATION_NAME, R.RDB$RELATION_NAME) P ON P.ID1 = R.RDB$RELATION_NAME AND P.ID2 = R.RDB$RELATION_NAME

summary: "no current record for fetch operation" when joining with stored procedure inside derived table => "no current record for fetch operation" when joining with stored procedure

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

description: SET TERM ^ ;

CREATE PROCEDURE PSTRID
( IN_ID1 VARCHAR(100), IN_ID2 VARCHAR(100))
RETURNS
( ID1 VARCHAR(100), ID2 VARCHAR(100))
AS
BEGIN
ID1 = IN_ID1;
ID2 = IN_ID2;
SUSPEND;
END^

SET TERM ; ^

SELECT
*
FROM
RDB$RELATIONS R
INNER JOIN PSTRID(R.RDB$RELATION_NAME, R.RDB$RELATION_NAME) P ON P.ID1 = R.RDB$RELATION_NAME AND P.ID2 = R.RDB$RELATION_NAME

=>

SET TERM ^ ;

CREATE PROCEDURE PSTRID1
( IN_ID1 VARCHAR(100))
RETURNS
( ID1 VARCHAR(100))
AS
BEGIN
ID1 = IN_ID1;
SUSPEND;
END^

SET TERM ; ^

--------------------------------------------------

SELECT
*
FROM
RDB$RELATIONS R
INNER JOIN PSTRID1(R.RDB$RELATION_NAME) P ON P.ID1 = R.RDB$RELATION_NAME

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

summary: "no current record for fetch operation" when joining with stored procedure => "no current record for fetch operation" when "INNER" joining with stored procedure

@firebird-automations
Copy link
Collaborator Author

Commented by: Attila Molnár (e_pluribus_unum)

Use LEFT OUTER insted of INNER JOIN.

SELECT
*
FROM
RDB$RELATIONS R
LEFT OUTER JOIN PSTRID1(R.RDB$RELATION_NAME) P ON P.ID1 = R.RDB$RELATION_NAME

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

Attila is correct, only LEFT JOINs to SPs are supported.

An INNER JOIN can be emulated by adding a condition to the WHERE clause, as in:

SELECT *
FROM RDB$RELATIONS R
INNER JOIN PSTRID1(R.RDB$RELATION_NAME) P ON 1 = 1
WHERE
P.ID1 IS NOT NULL

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

Are you sure that "no current record for fetch operation" is proper way of raporting this to the user?

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

I am not saying that. But improving/adding an error message would be a separate "feature request" or "Improvement" issue type, not this "bug" issue.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant