Subject | Re: [firebird-support] Re: Stored Procedures? |
---|---|
Author | Helen Borrie |
Post date | 2003-10-23T00:13:49Z |
At 03:04 PM 22/10/2003 -0400, you wrote:
1) If you are using Firebird, you need to qualify all columns in join
statements. Even if you are not using Fb, you still should. IB simply
lets you pass join statements with potential ambiguity and makes mad guesses.
2) The error message points to this line in your code:
ORDER BY UpperTitle
Is this actually a column in either of the tables? If so, then it's the
ambiguity that is causing the problem.
If not, then you could try declaring a local variable for it to include it
in the intermediate set that is operated on before passing the output row
(see second source fragment).
In fact, it's impossible to tell from your SP code which tables are
supplying which columns. I'll guess them, you fix them:
CREATE PROCEDURE MY_PROC(CAT_ID INTEGER)
RETURNS (ID INTEGER, TITLE VARCHAR(100),EXP_DATETIME TIMESTAMP)
AS
BEGIN
FOR SELECT
f.id,
f.title,
fc.ExpirationDateTime
FROM forms f
JOIN formcategory fc
ON f.id=fc.form_id
WHERE fc.category_id=:CAT_ID
ORDER BY f.UpperTitle /* is this really "UpperTitle" i.e. quoted? */
INTO :ID, :TITLE, :EXP_DATETIME;
DO BEGIN
SUSPEND;
END
END
Possible solution for the ORDER BY problem:
CREATE PROCEDURE MY_PROC(CAT_ID INTEGER)
RETURNS (ID INTEGER, TITLE VARCHAR(100),EXP_DATETIME TIMESTAMP)
AS
declare variable uTitle varchar(100);
BEGIN
FOR SELECT
f.id,
f.title,
f.UpperTitle, /* or f."UpperTitle" if needed */
fc.ExpirationDateTime
FROM forms f
JOIN formcategory fc
ON f.id=fc.form_id
WHERE fc.category_id=:CAT_ID
ORDER BY 3
INTO :ID, :TITLE, :uTitle, :EXP_DATETIME;
DO BEGIN
SUSPEND;
END
END
heLen
>Hi Martijn,Two things.
>
>Yep, tried that already, and still get the same message!
>
>Any other ideas?
1) If you are using Firebird, you need to qualify all columns in join
statements. Even if you are not using Fb, you still should. IB simply
lets you pass join statements with potential ambiguity and makes mad guesses.
2) The error message points to this line in your code:
ORDER BY UpperTitle
Is this actually a column in either of the tables? If so, then it's the
ambiguity that is causing the problem.
If not, then you could try declaring a local variable for it to include it
in the intermediate set that is operated on before passing the output row
(see second source fragment).
In fact, it's impossible to tell from your SP code which tables are
supplying which columns. I'll guess them, you fix them:
CREATE PROCEDURE MY_PROC(CAT_ID INTEGER)
RETURNS (ID INTEGER, TITLE VARCHAR(100),EXP_DATETIME TIMESTAMP)
AS
BEGIN
FOR SELECT
f.id,
f.title,
fc.ExpirationDateTime
FROM forms f
JOIN formcategory fc
ON f.id=fc.form_id
WHERE fc.category_id=:CAT_ID
ORDER BY f.UpperTitle /* is this really "UpperTitle" i.e. quoted? */
INTO :ID, :TITLE, :EXP_DATETIME;
DO BEGIN
SUSPEND;
END
END
Possible solution for the ORDER BY problem:
CREATE PROCEDURE MY_PROC(CAT_ID INTEGER)
RETURNS (ID INTEGER, TITLE VARCHAR(100),EXP_DATETIME TIMESTAMP)
AS
declare variable uTitle varchar(100);
BEGIN
FOR SELECT
f.id,
f.title,
f.UpperTitle, /* or f."UpperTitle" if needed */
fc.ExpirationDateTime
FROM forms f
JOIN formcategory fc
ON f.id=fc.form_id
WHERE fc.category_id=:CAT_ID
ORDER BY 3
INTO :ID, :TITLE, :uTitle, :EXP_DATETIME;
DO BEGIN
SUSPEND;
END
END
heLen