gpt4 book ai didi

javascript - php ocibindbyname 在 javascript 中等效

转载 作者:行者123 更新时间:2023-12-03 07:36:21 25 4
gpt4 key购买 nike

我正在使用用 javascript 编写的 hta 页面来监视一些 Oracle 表。

我想使用绑定(bind)变量来优化 oracle 查询缓存,就像我在 php 环境中使用以下代码所做的那样:

$sql = "select m1_master from CEDWORK.hd_anag where account = :utente";
$s = OCIParse($c, $sql);
ocibindbyname($s, ":utente", $utente);
if ( OCIExecute($s, OCI_DEFAULT) == false ){
gsterr($sql, "record not found");
}
while (ocifetch($s)) {
$codmec = OCIResult($s, "M1_MASTER");
}

在 hta javascript 中我使用了以下代码:

function test1(idUtente){
var adOpenDynamic = 2
var adLockOptimistic = 3
var conn_str = "Provider=OraOLEDB.Oracle;Password=xxxx;Persist Security Info=True;User ID=xxxx;Data Source=sgo01";
var conn = new ActiveXObject("ADODB.Connection")
conn.open(conn_str)
var rsPass = new ActiveXObject("ADODB.Recordset");
var arrPass = new Array();
var rs2arr = new Array();
var SQLpass = "SELECT cod_operatore, a.cognome, a.nome, a.account, m1_master ";
SQLpass += "from cedwork.hd_operatori a, cedwork.hd_anag b " ;
SQLpass += "where a.account = b.account " ;
SQLpass += "and a.account = '" + idUtente + "'" ;

rsPass.open(SQLpass, conn, adOpenDynamic, adLockOptimistic);
alert(rsPass.fields("m1_master").value);
rsPass.close();

}

我想用绑定(bind)变量替换“idUtente”变量,但我没有找到 javascript sintiax....

感谢您的帮助,马可

最佳答案

警告 - 我不使用 ADODB,但对“ADODB”“准备好的语句”和“绑定(bind)变量”进行一些明智的搜索,得到了答案:

这表明了这个答案:

var conn = new ActiveXObject("ADODB.Connection");
var cmd = new ActiveXObject("ADODB.Command");
var rs = new ActiveXObject("ADODB.Recordset");
conn.open( "Provider=OraOLEDB.Oracle;Password=xxxx;Persist Security Info=True;"
+ "User ID=xxxx;Data Source=sgo01" );
cmd.ActiveConnection = conn;
cmd.CommandText = "SELECT cod_operatore, a.cognome, a.nome, a.account, m1_master "
+ "FROM cedwork.hd_operatori a "
+ "INNER JOIN cedwork.hd_anag b "
+ "ON ( a.account = b.account ) "
+ "WHERE a.account = ?";
cmd.Parameters.Append(
cmd.CreateParameter( "id", adChar, adParamInput, 20, idUtente )
);
rs = cmd.Execute();

关于javascript - php ocibindbyname 在 javascript 中等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35597113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com