Subject RE: [firebird-support] Return Result from Stored Procedure
Author Jerry Sands
Assuming you have FB 2.1:



YYMM = RIGHT(EXTRACT(YEAR FROM DateParm),2) || RIGHT('0' || EXTRACT(MONTH
FROM DateParm),2)



You can put this into your stored procedure or just use it directly in a sql
select:



SELECT RIGHT(EXTRACT(YEAR FROM DateField),2) || RIGHT('0' || EXTRACT(MONTH
FROM DateField),2)

FROM Table



Jerry Sands





From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Kongthap Thammachat
Sent: Tuesday, March 20, 2012 6:46 AM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Return Result from Stored Procedure





Dear All

I wanna create a stored procedure to return 'YYMM' of the current date
for using as part of my document ID

This is my stored procedure PSQL so far

SET TERM ^ ;
CREATE PROCEDURE P_YEARMONTH_PREFIX
RETURNS (
YYMM Char(4) )
AS
declare YY char(2);
declare MM char(2);
BEGIN
select substring(cast(extract(year from current_date) + 543 as
char(4)) from 3 for 2)
from rdb$database
into :YY;

select cast(extract(month from current_date) as char(2))
from rdb$database
into :MM;

if (char_length(MM) = 1) then begin
MM = '0' || MM;
end

result = YY || MM; -- why is this line get error
END^
SET TERM ; ^

I really don't know why is that line get error, please help, I really
new to Firebird.

P.S. Firebird 2.5

Thanks.
Kongthap.





[Non-text portions of this message have been removed]