lua-users home
lua-l archive

Prepared statements in LuaSQL (was: Re: string dollar literals (for luamacro or tokenf))

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


	Hi Jay
(Lua SQL still makes me very sad by lacking parameterized queries
though. Yes, it's better than nothing, Which backends can't support a
norrmalized form for the most common statements?
	DBMS's are very different in this aspect.
	PostgreSQL [1]:
PREPARE fooplan (int, text, bool, numeric) AS
 INSERT INTO foo VALUES(1,ドル 2,ドル 3,ドル 4ドル);
EXECUTE fooplan(1, 'Hunter Valley', 't', 200.00);
	MySQL [2]:
PREPARE stmt1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
SET @a = 3;
SET @b = 4;
EXECUTE stmt1 USING @a, @b;
	Oracle OCI8 [3]:
INSERT INTO emp VALUES
 (:empno, :ename, :job, :sal, :deptno)
	I think LuaSQL should not define any of these forms, thus exposing
the incompatibilities between the databases. Anyway, to offer an API
for prepared statements, LuaSQL must define a _standard_ way to declare,
bind the values and execute a prepared statement. We have discussed that
before, but anyone had time to spend on that front :-(
	Regards,
		Tomás
[1] http://www.postgresql.org/docs/9.1/static/sql-prepare.html
[2] http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html
[3] http://docs.oracle.com/cd/B12037_01/appdev.101/b10779/oci04sql.htm 

AltStyle によって変換されたページ (->オリジナル) /