简体   繁体   English

栏位长度>最大

[英]Field length is > maximum

I'm working on some middleware in C# using the System.Data.Odbc library to interact with a v10 PSQL database. 我正在使用System.Data.Odbc库与C10 vSQL数据库交互的C#中的一些中间件。 I have a set of working select and insert queries I run in sequence where occasionally the full sequence will execute without issue but most of the time for each INSERT query in the sequence my error handling catches the exception: 我有一组按顺序运行的工作选择查询和插入查询,偶尔会执行完整序列而不会出现问题,但是大多数情况下,对于我序列中的每个INSERT查询,我的错误处理都会捕获异常:

ERROR [HY000][Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface][Date Record Manager]Field length is > maximum 错误[HY000] [普及] [ODBC客户端接口] [LNA] [普及] [ODBC引擎接口] [日期记录管理器]字段长度>最大

I'm trying to understand what this means and how to resolve it. 我试图了解这意味着什么以及如何解决它。

This is on a Windows 2008 R2 server. 这是在Windows 2008 R2服务器上。 I'm using C# in Visual Studios Community 2015 to take information from a web system (no issues here) and add sales orders to the other system sitting on the server which uses a Pervasive SQL v10 database. 我在Visual Studios Community 2015中使用C#来从Web系统中获取信息(此处没有问题),并将销售订单添加到位于使用Pervasive SQL v10数据库的服务器上的另一个系统上。

The PSQL tables are massive with 80-160 columns, so for the 3 tables I need to write to I run a select query first to fetch the excess values, then bind them as parameters for the insert query. PSQL表庞大,有80-160列,因此对于我要写入的3个表,我首先运行一个选择查询以获取多余的值,然后将它们绑定为插入查询的参数。 There are 4 SELECT/INSERT routines run in sequence, with the last one running n times in a foreach loop. 依次有4个SELECT / INSERT例程运行,最后一个在foreach循环中运行n次。

I've been able to run this ODBC SELECT/INSERT sequence on this system in the past using MS Access and PHP. 过去,我已经可以使用MS Access和PHP在此系统上运行此ODBC SELECT / INSERT序列。 I've tried cleaning the solution, rebooting the server and rebuilding, as well as adding additional Dispose() calls on the commands, but I still get these errors. 我尝试清理解决方案,重新启动服务器并重建,以及在命令上添加其他Dispose()调用,但仍然遇到这些错误。

class PSQLOrderConnector
{
    private OdbcConnection Odbc { get; }

    public PSQLOrderConnector()
    {
        Odbc = new OdbcConnection(Constants.ODBCSTRING);
        Odbc.Open();
    }

    /*
    ...
    */

    public void CreateOrderAddressBillTo(string CustomerCode, string OrderNumber, string AddDate, int AddTime)
    {
        OdbcCommand cmdSelectAddressB = new OdbcCommand();
        OdbcCommand cmdInsertAddressB = new OdbcCommand();

        cmdSelectAddressB = this.Odbc.CreateCommand();

        cmdSelectAddressB.CommandText = OrderQueries.PQSL_SELECT_ADDRESS_BY_CUSTOMER;
        cmdSelectAddressB.Parameters.Add("@CEV_NO", OdbcType.Text).Value = CustomerCode;

        OdbcDataReader reader = cmdSelectAddressB.ExecuteReader();

        reader.Read();

        var NAME = reader.GetString(0);
        /* ...repeat for the next 80 columns */

        cmdSelectAddressB.Dispose();

        cmdInsertAddressB = this.Odbc.CreateCommand();

        cmdInsertAddressB.CommandText = OrderQueries.PSQL_INSERT_ORDER_ADDRESS;
        cmdInsertAddressB.Parameters.Add("NAME", OdbcType.Text).Value = NAME;
        /* ...repeat for the next 80 variables */

        try
        {
            int result = cmdInsertAddressB.ExecuteNonQuery();
        }
        catch (OdbcException odbce)
        {
            //Exception error gets thrown here
        }

        cmdInsertAddressB.Dispose();
    }

    /*
    ...
    */
}       

class Order
{
    private PSQLOrderConnector PSQLOrder { get; }   

    public Order()
    {
        PSQLOrder = new PSQLOrderConnector();
    }       
    /*
    ...
    */

    public void AddOrders(List<businessEvent> Events )
    {
        /*
        ...
        */

        /* These 4 calls either pass in sequence or fail in sequence on the Try/Catch in the above class*/
        PSQLOrder.CreateOrderHeader(OrderNumber, CustomerCode, PONumber, SubTotal, CurrentCost, AverageCost, AddDate, AddTime);

        /* This is the method detailed above */
        PSQLOrder.CreateOrderAddressBillTo(CustomerCode, OrderNumber, AddDate, AddTime);

        PSQLOrder.CreateOrderAddressShipTo(CustomerCode, ShipToCode, OrderNumber, AddDate, AddTime);

        int recNo = 1;
        foreach (ItemLine line in itemLines)
        {
            PSQLOrder.CreateOrderDetail( OrderNumber, recNo, line.ItemCode, line.Quantity, line.Price, AddDate, AddTime);
            recNo++;
        }       
    }
}

(I edited the code for cleaner posting here, hopefully there's no typo's) (我在此处编辑了代码,以方便张贴,希望没有错字)

With the last lines running the function calls either the error triggers for each insert in sequence, or the entire sequence completes successfully. 在最后一行运行时,该函数将为序列中的每个插入调用错误触发器,或者整个序列成功完成。 Using the same or different inputs this occurs randomly with roughly a 80/20 failure/success rate. 使用相同或不同的输入,这种随机发生的故障/成功率大约为80/20。

I've resolved my issue, the error message was exactly right and was pointing to my timestamp. 我已经解决了我的问题,错误消息是正确的,并且指向我的时间戳。 Because I set it once with a variable AddTime then sent that to each of the 4 function calls is why it would fail in sequence but sometimes work, probably in the first 9 seconds of the system minute. 因为我使用变量AddTime对其进行了一次设置,然后将其发送到4个函数调用中的每一个,这就是为什么它顺序失败但有时可以工作的原因,可能是在系统分钟的前9秒钟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM