db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@oracle.com>
Subject Re: adding a record to a table
Date Mon, 17 Feb 2014 13:53:34 GMT
On 2/17/14 2:03 AM, John English wrote:
> On 17/02/2014 11:29, Bob M wrote:
>> Hi John
>>
>> I am having difficulty following your latest message.........sorry :(
>>
>> I don't understand where to give constraints names?
>> Is it when I set up the table?
>
> Yes, replace PRIMARY KEY(x) with CONSTRAINT c PRIMARY KEY(x) in the 
> table definition. See 
> http://db.apache.org/derby/docs/10.1/ref/rrefsqlj42154.html
>
>> derby.properties - I have no idea where / what that is?
>
> Create a file in the startup directory (where derby.log should also 
> be) containing this line:
>
>   derby.language.logStatementText=true
>
> See http://db.apache.org/derby/docs/10.1/tuning/ctunsetprop13074.html
>
> HTH,
If you haven't named a constraint, then its system-generated name should 
be the same as the name of the system-generated index which backs the 
constraint. You should be able to use DatabaseMetaData.getIndexInfo() to 
retrieve enough information to figure out which one is being violated. 
The following script shows how to do this:

connect 'jdbc:derby:memory:db;create=true';

create table t1( z int primary key );
create table t2( x int not null unique, y int primary key, z int 
references t1( z ) );

call syscs_util.syscs_register_tool( 'databaseMetaData', true );

select substr( index_name, 1, 36 ), substr( column_name, 1, 36 ), 
ordinal_position
from table( getIndexInfo( null, 'APP', 'T2', false, false ) ) s
order by index_name, ordinal_position;

call syscs_util.syscs_register_tool( 'databaseMetaData', false );

Hope this helps,
-Rick

Mime
View raw message