FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.24k stars 215 forks source link

Parametrized stored procedures and functions [CORE1214] #1638

Open firebird-automations opened 17 years ago

firebird-automations commented 17 years ago

Submitted by: Alexander Tyutik (tut)

Votes: 1

I propose to make something similar to templates in C++ and generics in Java/.NET.

1) Programmer can describe interfaces for different objects in database, for example: - RELATION(INTEGER AS ID, VARCHAR(100) AS NAME, NUMERIC(15,2) AS SUMMA) - TABLE(-//-) - VIEW(-//-) - PROCEDURE(INT AS ID, TIMESTAMP AS DATE_TIME RETURNS VARCHAR(100) AS RESULT) - FUNCTION(INT AS ID, TIMESTAMP AS DATE_TIME RETURN FLOAT)

2) Programmer can create parametrized procedures and functions, describe and use their parameters, for example:

CREATE PROCEDURE PROC<T>( ID INTEGER) RETURNS ( VALUE VARCHAR(100) WHERE T: RELATION(INT AS ID, VARCHAR(100) AS NAME) AS ... BEGIN FOR SELECT NAME FROM T WHERE ID = :ID INTO :VALUE DO SUSPEND; END

3) Call procedure with diffirent parameters:

SELECT VALUE FROM PROC<PARAMETERS_VIEW>(25)

I think such way we can solve millions of problems in type-safe way which now solved using EXECUTE STATEMENT only.

firebird-automations commented 17 years ago

Commented by: Sean Leyne (seanleyne)

I do not support this feature request.

I do not see how this feature provides any benefit above the flexibility current provided EXECUTE STATEMENT functionality.

firebird-automations commented 17 years ago

Commented by: Alexander Tyutik (tut)

I do not know anything about your programming expiriens, but you should know that statically compiled cod is more stable and faster. Yes, you can use EXECUTE STATEMENT instead of this, but:

1) This is much more slower 2) You have no syntax check in compile-time 3) You have no type check in compile-time 4) You have no many other different checks in compile-time

This is same if you will use only "object" type variables in Java/C#⁠ or "Variant" in pascal for all cases instead of int, strind, char, bool, ets...

firebird-automations commented 17 years ago

Commented by: Alexander Tyutik (tut)

PS I understand that this feature will not be implemented in next 5-10 years ;-) So i will use EXECUTE STATEMENT for this too. But EXECUTE STATEMENT does not check permissions (known old issue) and does not have ability to pass parameters into commands as i wrote before :-(

firebird-automations commented 16 years ago
Modified by: @pcisar Workflow: jira \[ 11886 \] =\> Firebird \[ 15517 \]
firebird-automations commented 15 years ago

Commented by: Cosmin Apreutesei (cosmin_ap2)

I would also add 5) Dependency tracking to your list.

I was thinking about the same feature, only I named it "table interfaces", similar to OOP interfaces. I remember been mentioned already in the architect list (?)... Anyway, I'd make them primitive types instead of the < > template syntax so I can pass them around, store them, etc.

And yea, it defeats strong typing to use eval() kinda' functions.

firebird-automations commented 15 years ago
Modified by: Sean Leyne (seanleyne) Component: Engine \[ 10000 \]