I'm experimenting with Java and Couchbase 6.0 Community edition using Java 2.7 SDK.
I'm trying to execute a simple update query from my java application the Couchbase Java 2.7 SDK:
String query ="UPDATE admin SET FIELDNAME='TEST'"
N1qlParams params = N1qlParams.build().adhoc(false);
N1qlQuery nquery = N1qlQuery.simple(query, params);
N1qlQueryResult nqr= this.rbucket.query(nquery);
And I am getting the following exception (the most meaningful part):
com.couchbase.client.core.CouchbaseException: N1qlQuery Error - {"msg":"syntax error - at UPDATE","code":3000}
The actual exception starts like this:
Exception in thread "main" com.couchbase.client.core.CouchbaseException: Error while preparing plan
Of course - this query works fine through the Couchbase web UI and I can update without problem.
Just for info: I tried escaping the single quotes, even tried setting the column to be equal to itself - same error.
Select queries are executed in a similar manner without any problem.
"admin' is not a good name for a bucket, as it is usually related to some reserved keywords, if you still want to use this name, you have to use backticks around it:
update `admin` set FIELDNAME = 'TEST'
It also might ask you to create a primary index if you don't have one yet.
Related
Using Java, I have built many CRUD applications but I need an idea of how to create an endpoint to invoke the procedure in TempDB -- for development I can create a small procedure in dev env and invoke it from java.
I am using SQL developer, Oracle database, and Java language. I tried to look at other docs as well but could not find any article related to that. Can anyone point me to the correct link?
UPDATE:
I wrote one simple stored procedure in SQL Developer. I get an error
ORA-01422: exact fetch returns more than requested number of rows
CREATE OR REPLACE PROCEDURE GETWORKFLOWINPUTRECORDS
IS
R_DATA reorg_automation_workflowinput%ROWTYPE;
BEGIN
SELECT * INTO R_DATA FROM reorg_automation_workflowinput where REORG_ID = 'S-CFO-FULL-65';
END GETWORKFLOWINPUTRECORDS;
When I run the below query, it gives only 1 result but in the procedure, I am getting the above error.
SELECT *
FROM reorg_automation_workflowinput
WHERE REORG_ID = 'S-CFO-FULL-65';
Let's resolve this issue and then we can move forward with building API for calling a stored procedure.
UPDATE 2
It is fetching empty result while running this procedure. Any suggestion on this?
create or replace PROCEDURE GETWORKFLOWINPUTRECORDS
AS
c1 SYS_REFCURSOR;
BEGIN
open c1 for
SELECT * FROM reorg_automation_workflowinput;
END GETWORKFLOWINPUTRECORDS;
First of all, things were working perfectly in my previous laptop, when I shifted my code to the new laptop I am getting this error, Basically, I am calling finder method in my EJB and code of it was working fine as in EJB-jar it looks like this
<query>
<query-method>
<method-name>finduserrightsonform</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>select object(o) from UserRightsOnForm o where o.ser_groups_users_id=?1 and o.ser_form_id=?2</ejb-ql>
</query>
as both columns in DB are integers so as in my previous laptop Postgres auto-cast it's there, but what I am missing is strange.
so far as I tried
cast using cast(columnname as character varying) e.g. it also
through error
change method param to Integer it will not work as well, in fact,
stoped deployed the jar
changing the Postgress versions to the previous one.
casting like using ::smallint
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: integer = character varying
ERROR [stderr] (EJB default - 3) Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
its look like the environment maybe jar issue but what I am missing not catching it.
calling code:
sms.viewUserRightsOnFormImpl(userId, "validationForm", groupId);
defination:
Collection findUserRightOnForm(String user_id, String form_id) throws FinderException;
using
Jdevelper 11g
postgress 9.2
Jboss 6
EJB 2.1
Note: Tried all google links and stackover links almost wasted my 2 days.
Greetings to the community! I am using alfresco community edition 6.0.0 and I just faced a very weird problem. I am using the Java API to access my alfresco repository by running CMIS queries. I successfully fetched documents using cmis-strict like shown below:
Example 1)
select * from cmis:document WHERE cmis:name like '%doc%' AND cmis:objectId = 'e318a431-0ff4-4a4a-9537-394d2bd761af' "
Example 2)
SELECT * FROM cmis:document WHERE IN_FOLDER('63958f9c-819f-40f4-bedf-4a2e402f8b9f') AND cmis:name like '%temp%'
which work perfectly, what I would like to do is retrieve files/folders under a specific path (f.e fetch all folders under /app:company_home/app:user_homes)
what I do is running from the node browser of alfresco the following cmis-strict query
SELECT * FROM cmis:folder WHERE CONTAINS('PATH:"//app:company_home/app:user_homes//*"')
but even though there are existing folders under that directory nothing is returned. It seems that the PATH argument is not recognized as it should does, as when i run the query
SELECT * FROM cmis:folder I get back many results that have as parent the
app:company_home/app:user_homes
node
Any idea what may be the problem? Any help would be greatly appreciated, thanks :)
EDIT:
I have also tried to use lucene query like
PATH:"/app:company_home/app:user_homes//*") but no results returned too
Your user homes contains query works for me in both 5.2 and 6.1.1.
I like #Lista's suggestion of checking into your index. If that doesn't bear fruit, you might go get the CMIS object ID of the user homes folder, then use it with the IN_FOLDER clause you've already proven works.
I think both Lucene and CMIS queries (if using CONTAINS) end up on the index (not database), so it's not weird to assume something is off with the index itself. Have you tried rebuilding them? Are your nodes even in index (there's a SOLR admin console you can use to see this)?
https://docs.alfresco.com/6.0/concepts/query-lang-support.html
I am trying to aggregate a MongoDB (3.6) using Morphia (1.3.2).
Currently it is a simple match and unwind to understand Morphia's API.
The problem that I am facing however is related to MongoDB 3.6:
Changed in version 3.4: MongoDB 3.6 removes the use of aggregate command without the cursor option unless the command includes the explain option. Unless you include the explain option, you must specify the cursor option.
This paragraph comes directly from the MongoDB documentation. MongoDB Aggregate.
This means that a cursor is mandatory for the aggregate to work. However, I can't find a way to do this using Morphia. Therefore my aggregate does not work.
AggregationPipeline data = aggregation.match(query).unwind("data");
Iterator<LoraHourData> out = data.aggregate(Data.class);
The error that is produced using above code is as follows :
Command failed with error 9: The cursor option is required, except for aggregate with the explain argument on server localhost:27017. The full response is { ok : 0.0, errmsg: The cursor option is required, except for aggregate with the explain argument", code : 9, codeName : FailedToParse }
I am trying to doing some SQL queries out of Oracle 11g and am having issues using ora:contains. I am using Spring's JDBC implementation and my code generates the sql statement:
select *
from view_name
where column_a = ?
and column_b = ?
and existsNode(xmltype(clob_column),
'record/name [ora:contains(text(), "name1") > 0]',
'xmlns:ora="http://xmlns.oralce.com/xdb"') = 1
I have removed the actual view / column names obviously, but when I copy that into sqlplus and substitute in random values, the select executes properly. When I try to run it in my DAO code I get this stack trace:
org.springframework.jdbc.UncatergorizedSQLException: PreparedStatementCallback;
uncatergorizedSQLException for SQL [the big select above]; SQL state [99999];
error code [31011];
ORA-31011: XML parsing failed.
ORA-19202: Error occured in XML processing
LPX-00607: Invalid reference: 'contains';nested exception is java.sql.SQLException:
ORA-31011: XML parsing failed
ORA-19202: Error occured in XML processing
LPX-00607: Invalid reference: 'contains'
(continues on like this for awhile....)
I think it is worth mentioning that I am using Maven and it is possible I am missing some dependency that is required for this. Sorry the post is so long, but I wanted to err on the side of too much info.
Thanks for taking the time to read this at least =)
-Windle
You appear to have a spelling mistake in your namespace declaration:
'xmlns:ora="http://xmlns.oralce.com/xdb"'
^^
If that really is a typo in your code (rather than just in your posting here) it can't hurt to fix it.