I used identity column in oracle 12c:
col1 NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1)
I use Spring + mybatis, how to get generated value, useGeneratedKeys seems doesn't work.
Thanks!
Anyway, the question has been asked and answered here.
You might not notice the generated value is not returned by the insert statement, but stored in the input parameter in the keyProperty.
Related
I'm trying to have some specific information on a mariadb.Error. After the execution of an INSERT, with executemany(), I want to have, every time, the information about the problematical line. But I received two different types of errors.
For example when I have an error about a wrong data type, I have something like:
Invalid parameter type at row 2, column 4
When I have an error about a constraint not respected, I have something like:
Cannot add or update a child row: a foreign key constraint fails
But on the second case, I would like to have something like :
Cannot add or update a child row: a foreign key constraint fails at row X, column Y
Is it possible ? Can I configure mariadb.Error to have, always, the row/column detail ?
No, this is not possible.
The first error (Invalid parameter type at row 2, column 4) is generated by the MariaDB python driver: Before sending the execution request and data to the server, the driver checks if all columns have the same datatype, if not he will raise the exception above.
Afterwards, the driver sends a COM_STMT_BULK_EXECUTE command followed by all data to the server. The second error message (a foreign key constraint fails) was generated by the server, since the specified data violated one or more constraints. Unfortunately, the server doesn't give any hint which value in which row caused this error, so the driver can only raise this exception.
I agree, that this would be a useful feature and have submitted an issue (MDEV-29945) to the MariaDB bug tracking system.
I have a Password's column in a table, stored in OracleDB 11g.
In order to store hashed passwords on it, I need to increment its size from 25 to 60 or 100 BYTE.
I do not want to do this manually, I hope I can find a script or anything else using KnexJS (Something like migrations or seeds)
Thank you.
The correct term for what you want to do is "increase", not "increment". It looks like Knex.js supports changing the default DDL for columns (which is to create) to alter via the alter method. http://knexjs.org/#Schema-alter
In theory, it should work something like this:
knex.schema.alterTable('user', function(t) {
t.string('password', 100).alter();
});
I must admit, the following verbage in this method has me a little concerned:
Alter is not done incrementally over older column type so if you like to add notNull and keep the old default value, the alter statement must contain both .notNull().defaultTo(1).alter().
I'm not sure what that means at the end of the day. Just be sure to test this in development before trying it in production!
Clarification requested on KUDU.
In the KUDU guides the following is stated:
Row delete and update operations must also specify the full primary key of the row to be changed. Kudu does not natively support range deletes or updates.
The first part makes sense. However, using IMPALA via Hue I can easily issue commands like these that relate to the highlighted part of the prose:
delete from metrics_001 where (value >= 400 and value <= 600);
update metrics_001 set value = value + 1000 where (value >= 600 and value <= 800);
which execute as expected.
Does the statement mean that IMPALA allows this to be so? Could not find it from the documentation. I must be missing something elementary.
Impala first scans Kudu for the records that meet the filter criteria, and then it sends back to Kudu the individual delete/update operations for each key that was found.
I recently had to convert challenge questions and passwords for an OpenAM implementation.
The plan was to convert these values as part of the user entry in a LDIF file and load it. The attribute to complete is iplanet-am-user-password-reset-question-answer. This is a multi valued attribute to support multiple question/answer pairs.
The challenge question key, answer and question key and question status flag had to be combined in a single line delimited by tabs.
[question-key]\t[answer]\t[1|0]
The value needs to be encrypted. This was the class used to encrypt but it did not work.
AMPasswordUtil().encrypt(question.get(challenge) + "\t" + response + "\t1")
What to do to make this work?
Finally gave up and dropped ForgeRock support a question. They were very helpful and supplied the solution and it worked immediately. Here it is...
It turns out the AMPasswordUtil class should not be used. Instead this should be used
encrypted_str = AccessController.doPrivileged(new EncodeAction( clear_text_str ))
The encryption key needs to be set as a system property
System.setProperty("am.encryption.pwd", key );
The encryption key can be retrieved from OpenAM.
I recently started playing around with SubSonic 2.2 (only 2.2 because I didn't find any Oracle t4 templates at the time). That aside, I have been noticing that I can run a query on table a and field b will have a value of 1. If I went into Sql Tools or Oracle Developer and changed field b to a value of 2, SubSonic's LoadByKey functions still returns an object with field b having a value of 1.
In case that is hard to read.
var id = "primary key";
x.LoadByKey(id);
Console.Write(x.b); -> yields 1
I can go change this value in another program and rerun the code and it is always 1 regardless.
Any ideas?
The only thing I can think is that it's an app issue, or a driver-level issue. We don't implement any kind of caching.