This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Name already used by an existing object in VBA
I am using Oradynaset object to fetch the results from data base in VBA but the same object i.e OraDynaset does not work to create new table as i use the following query
strsql="create table abs.test as (select * from emp)"
Oradynaset=objDatabase.DBCreatedynaset(strsql,o&)
after running this query i get the error - ORA 009955:Object is used by an existing object.
can you please help me on this.
If you want to create/alter/drop databases and tables(ie. DDL), you should use the ExecuteSQL function of Objectdatabase object.
Oradynaset function of obdatabase objectis used for executing DML command in case of which it stores the fetched result that can be used later by looping through it.
Try by using object database object with sql query as parameter
Related
I am trying to write the following statement in Acumatica using PXDatabase.Update:
UPDATE MyTable SET MyField2 = MyField1
I want to use PXDatabase.Update for an upgrade process. I have used PXDatabase.Update many times using PXDataFieldAssign and PXDataFieldRestrict and this works well. I cannot find the correct syntax to have a field set from another field in the same DAC (only specific values).
What is the correct Syntax using PXDatabase.Update?
Edit: I am open to other calls that allow for a bulk update other than PXDatabase.Update (1 update for the entire table by company).
The following should do what you're looking for.
using (PXTransactionScope ts = new PXTransactionScope())
{
PXDatabase.Update<MyTable>(new PXDataFieldAssign<MyTable.myField2>(PXDbType.DirectExpression, "MyField1"));
ts.Complete();
}
This question already has answers here:
Node.js - Mongoose - Check if a collection exists
(4 answers)
Closed 8 years ago.
I am new to mongo Db and need to see if schema is already been created or not. I am using mongoose and node.js. If its not created i need to somehow run the creation script for once or else proceed with other stuff.
TIA
Assuming that by schema you mean that you want a check if the collection is already created in mongoDB, you should check this question here that explains the solution.
Quoting it:
Assuming you have a Mongoose Connection object named conn that's been opened using mongoose.createConnection, you can access the native mongo Db object via conn.db. From there you can call collectionNames which should provide what you're looking for:
conn.db.collectionNames(function (err, names) {
// names contains an array of objects that contain the collection names
});
You can also pass a collection name as a parameter to
collectionNames to filter the results to just what you're looking for.
This question already has answers here:
Mongoose update/upsert?
(5 answers)
Closed 7 years ago.
What is the best method of updating a row in a Mongo DB from NodeJS (preferably with Mongoose) while row if it does not already exist, create it. I've tried multiple functions, save findOneAndUpdate update. They are all dependant on one another, the row has to exist to be able to update it, for instance.
How can we combine these features into a function:
If the entry does not exist by 'name', create it, and then...
If the entry does exist, update 'password' with 'data'
Assuming a mongo collection that could look like:
{
"_id": ObjectId("5357c8e0b12b6c375bb0217b"),
"name": "Kimberly",
"password": "data"
}
My current code is a mess with a lot of if statements and relying on err responses to call database functions. (Check if a user exists before adding them, for example) Is there a better way to make sure there are no duplicate entries in the database after updating or saving something?
Many thanks
you may use findAndModify with upsert=true
http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/
This question already has answers here:
MongoDB Regular Expression Search - Starts with using javascript driver and NodeJS
(2 answers)
Closed 9 years ago.
i am trying to do the equivaleny in mongodb to sql LIKE search, but i cant have the results that i expected, i am follow this mappig sql to monog, but the result json is always empty. if i use a literal string works , but when pass a variable nothing happens
app.get("/questions/search/:query", function(req,res){
var querySearch = req.params.query;
//res.send(querySearch)
Question.find({title: /querySearch/ },function(err,docs){
if(err) res.json(err)
res.json(docs)
});
})
That find command will search for documents where the title contains the string "querySearch". This doesn't seem to be what you want to do. When you want to use find with a regular expression created at runtime, pass a RegExp object.
But please note that searching with regular expressions is slow. When you don't need all the features of regular expressions and only search for whole words, a text index might be the better choice.
I want to create a "prepared statement" in postgres using the node-postgres module. I want to create it without binding it to parameters because the binding will take place in a loop.
In the documentation i read :
query(object config, optional function callback) : Query
If _text_ and _name_ are provided within the config, the query will result in the creation of a prepared statement.
I tried
client.query({"name":"mystatement", "text":"select id from mytable where id=$1"});
but when I try passing only the text & name keys in the config object, I get an exception :
(translated) message is binding 0 parameters but the prepared statement expects 1
Is there something I am missing ? How do you create/prepare a statement without binding it to specific value in order to avoid re-preparing the statement in every step of a loop ?
I just found an answer on this issue by the author of node-postgres.
With node-postgres the first time you issue a named query it is
parsed, bound, and executed all at once. Every subsequent query issued
on the same connection with the same name will automatically skip the
"parse" step and only rebind and execute the already planned query.
Currently node-postgres does not support a way to create a named,
prepared query and not execute the query. This feature is supported
within libpq and the client/server protocol (used by the pure
javascript bindings), but I've not directly exposed it in the API. I
thought it would add complexity to the API without any real benefit.
Since named statements are bound to the client in which they are
created, if the client is disconnected and reconnected or a different
client is returned from the client pool, the named statement will no
longer work (it requires a re-parsing).
You can use pg-prepared for that:
var prep = require('pg-prepared')
// First prepare statement without binding parameters
var item = prep('select id from mytable where id=${id}')
// Then execute the query and bind parameters in loop
for (i in [1,2,3]) {
client.query(item({id: i}), function(err, result) {...})
}
Update: Reading your question again, here's what I believe you need to do. You need to pass a "value" array as well.
Just to clarify; where you would normally "prepare" your query, just prepare the object you pass to it, without the value array. Then where you would normally "execute" your query, set the value array in the object and pass it to the query. If it's the first time, the driver will do the actual prepare for you the first time around, and simple do binding and execution for the rest of the iteration.