Parameterized SQL statement: Difference between revisions

Found incorrectnesses.
m (unused constants removed)
(Found incorrectnesses.)
Line 9:
 
=={{header|8th}}==
<lang forth>\ assuming the var 'db' contains an opened database with a schema matching the problem:
<lang forth>
\ assuming the var 'db' contains an opened database with a schema matching the problem:
db @
"UPDATE players SET name=?1,score=?2,active=?3 WHERE jerseyNum=?4"
Line 22 ⟶ 21:
 
\ execute the query
db @ swap db:exec</lang>
 
</lang>
=={{header|Ada}}==
<lang Ada>-- Version for sqlite
-- Version for sqlite
with GNATCOLL.SQL_Impl; use GNATCOLL.SQL_Impl;
with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec;
Line 64 ⟶ 60:
Free (Conn);
Free (DB_Descr);
end Prepared_Query;</lang>
 
</lang>
 
=={{header|C}}==
Line 72 ⟶ 66:
{{trans|Pascal}}
Compile with:
 
<pre>
gcc example.c -lsqlite3
 
</pre>
Tested with gcc version 4.9.2 (Raspbian 4.9.2-10) and SQLite 3.8.7.1
<lang c>#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
Line 207 ⟶ 200:
 
=={{header|C sharp|C#}}==
<lang csharp>using System.Data.Sql;
using System.Data.Sql;
using System.Data.SqlClient;
 
Line 231 ⟶ 223:
}
}
}</lang forth>
}
</lang>
 
=={{header|Clojure}}==
{{improve|Clojure|It just has to show exclusively the parametrized possibility. Definitely NOT the "GoTo" version.}},
<lang clojure>
<lang clojure>(require '[clojure.java.jdbc :as sql])
; Using h2database for this simple example.
(def db {:classname "org.h2.Driver"
Line 245 ⟶ 236:
 
; As an alternative to update!, use execute!
(sql/execute! db ["UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?" "Smith, Steve" 42 true 99])</lang>
</lang>
 
=={{header|F_Sharp|F#}}==
Line 336 ⟶ 326:
 
=={{header|Java}}==
{{incorrect|Java|javac Errors, compiler reports over 12 errors.}}
<lang java>import java.sql.DriverManager;
import java.sql.Connection;
Line 424 ⟶ 415:
 
=={{header|Mathematica}}==
{{incorrect|Mathematica|Executing a NON-parameterized update DML. This solution is exactly the opposite of the task. This example is what is explicitly warned in the task.}}
<lang Mathematica>Needs["DatabaseLink`"];
conn=OpenSQLConnection[JDBC["ODBC(DSN)", "testdb"], "Username" -> "John", "Password" -> "JohnsPassword"];
Line 969 ⟶ 961:
 
=={{header|Run BASIC}}==
{{incorrect|Run BASIC|Executing a NON-parameterized update DML. This solution is exactly the opposite of the task. This example is what is explicitly warned in the task.}}
<lang runbasic>sqliteconnect #mem, ":memory:"
#mem execute("CREATE table players (name, score, active, jerseyNum)")
Line 1,109 ⟶ 1,102:
=={{header|SQL}}==
{{works with|Oracle}}
<lang sql>-- This works in Oracle's SQL*Plus command line utility
<lang sql>
-- This works in Oracle's SQL*Plus command line utility
 
VARIABLE P_NAME VARCHAR2(20);
Line 1,149 ⟶ 1,141:
commit;
 
select * from players;</lang>
{{Out}}
</lang>
<pre>SQL> SQL>
 
<pre>
SQL> SQL>
NAME SCORE ACTIV JERSEYNUM
-------------------- ---------- ----- ----------
Line 1,167 ⟶ 1,157:
NAME SCORE ACTIV JERSEYNUM
-------------------- ---------- ----- ----------
Smith, Steve 42 TRUE 99</pre>
</pre>
 
=={{header|SQL PL}}==
{{works with|Db2 LUW}}
The following example is notindeed Parametrizedparameterized SQL, butwith named placeholders and it prevents SQL injections, and the SQL performs very well, because the execution plan is also precompiled.
<lang sql pl>
CREATE TABLE PLAYERS (
Line 1,229 ⟶ 1,218:
Maradona 600 1 10
 
1 record(s) selected.</pre>
</pre>
 
=={{header|Tcl}}==
Line 1,257 ⟶ 1,245:
$db close</lang>
 
{{omit from|360 Assembly}}
{{omit from|Maxima}}
{{omit from|PARI/GP}}
{{omit from|Pentium Assembly}}
{{omit from|X86 Assembly}}
{{omit from|6502 Assembly}}
{{omit from|ARM Assembly}}
{{omit from|MIPS Assembly}}
{{omit from|Assembly}}
{{omit from|Z80 Assembly}}
{{omit from|Computer/zero Assembly}}
{{omit from|OASYS Assembler}}
{{omit from|8086 Assembly}}
{{omit from|6800 Assembly}}
{{omit from|80386 Assembly}}
{{omit from|Jacquard Loom}}
{{omit from|DIV Games Studio}}
{{omit from|LC3 Assembly}}
{{omit from|8051 Assembly}}
{{omit from|VAX Assembly}}
{{omit from|68000 Assembly}}
{{omit from|PDP-11 Assembly}}
{{omit from|REXX}}
{{omit from|TI-83 BASIC|No network access or built-in SQL}}
{{omit from|TI-89 BASIC|No network access or built-in SQL}}
{{omit from|Unlambda|No network access or built-in SQL}}
{{omit from|XSLT 1.0}}
Anonymous user