我确信这是常见的地方,但谷歌没有帮助.我试图在PostgreSQL 9.1中编写一个简单的存储过程,它将从父cpt表中删除重复的条目.父表cpt由子表引用,lab定义为:
CREATE TABLE lab (
recid serial NOT NULL,
cpt_recid integer,
........
CONSTRAINT cs_cpt FOREIGN KEY (cpt_recid)
REFERENCES cpt (recid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE RESTRICT,
...
);
Run Code Online (Sandbox Code Playgroud)
我遇到的最大问题是如何获取失败的记录,以便我可以在EXCEPTION子句中使用它将子行移动lab到一个可接受的键,然后循环返回并从cpt表中删除不必要的记录.
这是(非常错误的)代码:
CREATE OR REPLACE FUNCTION h_RemoveDuplicateCPT()
RETURNS void AS
$BODY$
BEGIN
LOOP
BEGIN
DELETE FROM cpt
WHERE recid IN (
SELECT recid
FROM (
SELECT recid,
row_number() over (partition BY cdesc ORDER BY recid) AS …Run Code Online (Sandbox Code Playgroud) 在PostgreSQL(9.3)中,是否有一种简单的方法来获取使用特定表的存储过程的列表?
我要更改几个表,需要修复使用它们的存储过程。
我正在尝试使用Npgsql PostgreSQL客户端来完成两件事:
我看不出怎么办:(
PostrgeSQL版本9.1
在下面的代码中,dx.chronic是bool类型的?表dx的cdesc可能包含单引号,如"Tom's dog".显然,当Npgsql/PostgreSQL命中单引号时,写入的UpdateCmd将失败.
string sChronic = (dx.chronic == null) ? "null" : dx.chronic.ToString();
string UpdateCmd = "update dx "+
"set chronic = " + sChronic +
" where (trim(lower(cdesc)), trim(cicd9)) = "+
" ('"+dx.description.Trim().ToLower()+"','"+dx.icd9.Trim() +"');";
using (NpgsqlCommand command = new NpgsqlCommand(UpdateCmd, conn))
{
command.Parameters.Add(new NpgsqlParameter("value1", NpgsqlDbType.Text));
command.Parameters[0].Value = "Big Tom's Dog";
....... ? ? ? ? ? ? ? ? ? ? ? ? ? ...................
Run Code Online (Sandbox Code Playgroud)
这是怎么做到的?任何帮助都非常感谢.
TIA
我正在尝试从附加属性更改ListViewItem的背景。在将ListViewItem滚动出显示的ListView之前,以下代码将一直起作用。错误是计时器在已断开连接的ListViewItem上触发。
{System.Windows.Controls.ListViewItem:{DisconnectedItem}} System.Windows.Controls.ListViewItem
如何在Visual Studio 2010中测试断开连接的项目?
TIA
namespace Stargate_V
{
// Using singleton pattern to create one time to be shared among all ListViewItem instances.
public static class ListTimer
{
// Reasons for using a DispatcherTimer opposed to a System.Timers.Timer are that the DispatcherTimer runs on the same thread as the
// Dispatcher and a DispatcherPriority can be set on the DispatcherTimer. Timer runs in its own thread.
private static readonly Timer listTimer;
static ListTimer()
{
listTimer = new Timer …Run Code Online (Sandbox Code Playgroud) 在postgresql(9.2)中,我有一个表:
tservice timestamp without time zone NOT NULL,
patient_recid integer NOT NULL
Run Code Online (Sandbox Code Playgroud)
我希望在tservice 的日期创建一个独特的约束,如:
constraint service_unique UNIQUE (patient_recid, tservice::date)
Run Code Online (Sandbox Code Playgroud)
这会在日期转换时产生语法错误.
如何在PostgreSQL中做得最好?
TIA
我有一个操作定义为:
Action CurrentDxList;
Run Code Online (Sandbox Code Playgroud)
最初,我将其用作:
private void test()
{
CurrentDxList = MakeAllDxList;
CurrentDxList();
}
Run Code Online (Sandbox Code Playgroud)
在哪里
private void MakeAllDxList()
{
var dx = MedicalClient.GetAllDx((int)Patient.Patient_Recid, Patient.tservice);
_dxlist = dx.OrderBy(o => o.Cdesc);
DxList = new ObservableCollection<DiagnosisDetail>(iDxDetail);
ListCount = DxList.Count();
}
Run Code Online (Sandbox Code Playgroud)
然而,MakeAllDxList() 最好用异步定义为:
private async Task MakeAllDxList()
{
var dx = await MedicalClient.GetAllDxAsync((int)Patient.Patient_Recid, Patient.tservice);
_dxlist = dx.OrderBy(o => o.Cdesc);
DxList = new ObservableCollection<DiagnosisDetail>(iDxDetail);
ListCount = DxList.Count();
}
Run Code Online (Sandbox Code Playgroud)
现在会导致以下错误:
任务 MakeAllDxList() 的返回类型错误。
那么是否可以为一个动作分配一个可等待的值呢?这是怎么做到的?任何想法都是非常受欢迎的。
当然,我可以将 MakeAllDxList() 的签名更改为
private async void MakeAllDxList()
Run Code Online (Sandbox Code Playgroud)
但这样我就会失去异步任务的所有优点。
我在主窗口中有一个复杂的 WPF Tab 控件,全部使用 C#,使用 .NET Framework。主窗口提供一致的主菜单和包含选项卡控件的内容控件。
选项卡控件的每个选项卡使用特定于每个用户控件的视图模型呈现不同的用户控件。
在深入研究之前,我需要知道 Elmish.WPF 是否可以为这种情况提供适当的 F# 支持。
在研究这些示例时,到 Elmish.WPF 的关键切换似乎发生在:
Program.mkSimpleWpf App.init App.update bindings
Run Code Online (Sandbox Code Playgroud)
一旦出现主窗口和第一个选项卡,init、update 和 bindings 是否可以区分并允许用户在选项卡之间切换?如果是这样,新的选项卡状态是否可以“输入”到 Elmish.WPF 中?
任何帮助或建议将不胜感激。
TIA
(更复杂的是,其中一个选项卡显示了一个带有自定义装饰器的数据网格,用于列表操作)。
鉴于 F# 中的以下记录:
type Model =
{ Text: string option }
Run Code Online (Sandbox Code Playgroud)
什么是 C# 的 F# 等价物,
string.IsNullOrEmpty(Model.Text)
Run Code Online (Sandbox Code Playgroud)
TIA
在 C# 中,我这样做:
public const double PAPER_SIZE_WIDTH = 8.5 * 96;
Run Code Online (Sandbox Code Playgroud)
在 F# 中定义此全局常量的最佳方法是什么?
这失败了:
[<Literal>]
let PaperSizeWidth = 8.5*96.0
Run Code Online (Sandbox Code Playgroud)
错误:这不是有效的常量表达式
TIA
在 C# 中,我有以下接口定义:
using System.Collections;
public interface ISuggestionProvider
{
#region Public Methods
IEnumerable GetSuggestions(string filter);
#endregion Public Methods
}
Run Code Online (Sandbox Code Playgroud)
在 F# 中,我试过这样做:
type ISuggestionProvider =
abstract member GetSuggestions: string -> seq<'T>
type DiagnosisProvider () =
interface ISuggestionProvider with
member this.GetSuggestions s =[ "one"; "two"; "three"] |> Seq.cast
Run Code Online (Sandbox Code Playgroud)
但是当这被读回 C# 时,我得到:
public IEnumerable<T> GetSuggestions<T>(string value)
{
throw new NotImplementedException();
}
Run Code Online (Sandbox Code Playgroud)
我需要的是将其读回为:
public System.Collections.IEnumerable GetSuggestions(string filter)
{
return _method(filter);
}
Run Code Online (Sandbox Code Playgroud)
简而言之,我如何返回一个无类型的 IEnumerable 而不是 IEnumerable<'T> ???
在此先感谢您的帮助。
database ×4
f# ×4
postgresql ×4
c# ×2
plpgsql ×2
asynchronous ×1
elmish-wpf ×1
foreign-keys ×1
function ×1
npgsql ×1
sequence ×1
wpf ×1
xaml ×1