在我的PostgreSQL数据库中,我有以下表格(简化):
CREATE TABLE quotations ( receipt_id bigint NOT NULL PRIMARY KEY ); CREATE TABLE order_confirmations ( receipt_id bigint NOT NULL PRIMARY KEY fk_quotation_receipt_id bigint REFERENCES quotations (receipt_id) );
我现在的问题如下:
我有与先前报价相关的订单(这很好'因为我可以将这样的订单附加到使用FK字段引用的报价单),但我也有从头开始的订单而没有匹配的报价.如果数据库允许我,FK字段将为NULL.不幸的是,由于违反了外键约束,我在INSERT语句中尝试将fk_quotation_receipt_id设置为NULL时出错.
在设计这些表时,我仍然使用PgSQL 8.2,它允许NULL值.现在我有9.1.6,但不允许这样做.
我希望是一个可选(或可为空)外键约束order_confirmations(fk_quotation_receipt_id)→引用(receipt_id).我在官方的PgSQL文档中找不到任何提示,其他用户发布的类似问题已经很老了.
感谢您提供任何有用的提示.
我的键盘上有一个Compose键,但是将NumLock键用于其他目的,而将数字键盘仅用于输入数字。因此,我确实不需要NumLock指示灯,但想使用此LED来指示Compose键处于活动状态。在现成的xkb模板中,我找不到能做到这一点的模板。这是我的xkb / compat / lednum文件:
// Use the Num Lock LED to show either
// Num Lock, Group, or Shift Lock state.
default partial xkb_compatibility "num_lock" {
indicator "Num Lock" {
!allowExplicit;
whichModState= Locked;
modifiers= NumLock;
};
};
partial xkb_compatibility "group_lock" {
indicator "Num Lock" {
modifiers= None;
groups=All-group1;
};
};
partial xkb_compatibility "shift_lock" {
indicator "Num Lock" {
whichModState= Locked;
modifiers= Shift;
};
};
Run Code Online (Sandbox Code Playgroud)
在openSuSE 13.2(x86_64)平台上,我的X.org版本是7.6。
有人可以给我一个提示吗?谢谢。
我将在我用 C++ 编写的项目中使用用 C 实现的驱动程序库。库的头文件包含许多声明为extern我必须实现的函数存根:
extern uint8_t ADS1x1x_i2c_start_write (uint8_t i2c_address);
Run Code Online (Sandbox Code Playgroud)
我的 C++ 代码现在包含一个名为 的类vfd,该类将包含实现各自函数存根的静态方法,就像这样:
uint8_t vfd::ADS1x1x_i2c_start_write (uint8_t i2c_address) {
uint8_t ret = 0x00;
// do something
return ret;
}
Run Code Online (Sandbox Code Playgroud)
在类的头文件中vfd,相应的行将如下所示:
class vfd {
public:
uint8_t ADS1x1x_i2c_start_write (uint8_t i2c_address);
}
Run Code Online (Sandbox Code Playgroud)
我应该如何声明我的方法,以便编译器将它们识别为extern我的库头文件中相应函数的实现?