I am trying to use xquery for a project and I cannot see why this query is not working. It gives me the following error:
err:XPDY0002: undefined value for variable $skill
I am new to xquery and I am using EXIST DB as a database and I have tried using base x db and this works there perfectly. Is there anything i am missing in existdb? Any help would be appeciated.
for $endorsement in doc('/db/users.xml')/LOUser/Endorsements
for $endorsed_skill in $endorsement/Skills
let $skill := $endorsed_skill/text()
for $user in doc('/db/users.xml')/LOUser/User[#URL = $endorsement/URL2/text()]
let $Name := $user/Name/text()
where not($user/Skills/text() = $skill)/* I am getting the error here*/
group by
$Name, $skill
return {$Name}
Related
I am able to successfully create adapter for creation and insertion in sql but updation i have doubt below is my code where i want to update a certain field values based on wrkname and i am getting in or out error.
var updateStatement = WL.Server.createSQLStatement("UPDATE office1 SET wrkid=?, wrkname=?, empref=? WHERE wrkname=?");
function updateoffice(wrkid,wrkname,empref,wrkname) {
return WL.Server.invokeSQLStatement({
preparedStatement : updateStatement,
parameters : [wrkid,wrkname,empref,wrkname]
});
}
Aren't you missing the fourth parameter, wrkname (which you're using twice...)?
For example, this worked well for me:
var update = WL.Server.createSQLStatement("UPDATE users SET stdid=? WHERE userId=?");
function updatevaluesprocedure(stdId,userId) {
return WL.Server.invokeSQLStatement({
preparedStatement : update,
parameters : [stdId,userId]
});
}
Two parameters are expected, two parameters were received.
In your case four parameters are expected...
I have calling a function. get table number (result=0) results and updated same table value 0 to 1. i am using update query.i have run this function to return error :: Missing argument 2 for CDbCommand::update().
public function newdisplaycontent()
{
$count = Yii::app()->db->createCommand()
->select()
->from('scrolltable')
->where('result=:result', array(':result'=>0))
->queryAll();
$rs=array();
//print_r($count);
foreach($count as $item){
//process each item here
$rs=$item['ID'];
$user=Yii::app()->db->createCommand()
->update("scrolltable SET result = 1")
->where('ID=:id', array(':id'=>$rs));
}
return $rs;
}
thanks for your feature help..
The correct syntax of update() would be like below:
$user=Yii::app()->db->createCommand()
->update("scrolltable",array("result" => "1"))
->where('ID=:id', array(':id'=>$rs));
As official document:
update() Creates and executes an UPDATE SQL statement. The method will properly escape the column names and bind the values to be updated.
public integer update(string $table, array $columns, mixed $conditions='', array $params=array ( ))
I tried updating a column value using sql command, but it show general failure. Below is my code for update:
$name = 'ABC';
$id = 2;
$command = Yii::$app->db->createCommand()
->update('companies', ['company_name' => $name], 'company_id ='.$id.'');
$result = $command->queryAll();
When I execute this code below message is shown to me.
SQLSTATE[HY000]: General error
The SQL being executed was: UPDATE companies SET company_name='ABC' WHERE company_id =2
Error Info: Array
(
[0] => HY000
)
I cant find out why. Does anybody have any idea, what am I doing wrong here?
UPD
$command = Yii::$app->db->createCommand()
->update('companies', ['company_name' => $name], 'company_id ='.$id.'')->execute();
Can not use $command->queryAll() with update command.
There are couple of errors in your code.
First of all, why you are using queryAll() with UPDATE operation? Remove this line:
$result = $command->queryAll();
Second error - missing call of execute() command. Should be:
$command = Yii::$app->db
->createCommand()
->update('companies', ['company_name' => $name], 'company_id ='.$id.'')
->execute();
Check out documentation for yii\db\Command, especially execute() and queryAll() methods.
When executing the following piece of code:
def xml = new XmlSlurper().parse(url)
title = rss.chanel.title
rss.channel.item.each {
sql.firstRow("SELECT COUNT(*) FROM news WHERE title = ? ", [it.title])
}
I get the following error:
Invalid argument value: java.io.NotSerializableException
What may cause it?
The problem was that it.title was a NodeChild object.
In order to get the serializable text of this object I had to use it.title.text(). It was quite tricky since I could use print it.title successfully
I'm trying to build a query to get the numbers of rows that have the same data on a column (my column is ESTADO).
var db = Database.Open("MyDB");
var selectedData = db.Query("SELECT COUNT (*) FROM graficos WHERE ESTADO='FECHADO'");
var data = db.QueryValue(selectedData);
But when i try to run it gives the following error:
Compiler Error Message: CS1502: The best overloaded method match for 'WebMatrix.Data.Database.QueryValue(string, params object[])' has some invalid arguments
Line 51: var data = db.QueryValue(selectedData);
Pass the query directly to the QueryValue() method.
var data = db.QueryValue("SELECT COUNT (*) FROM graficos WHERE ESTADO='FECHADO'");
Read this documentation for more information on how to use the Database.QueryValue() method.