I'm getting a very vague error. I have the following code:
var skey = ev.EntityKey;
var id = skey.EntityKeyValues[0];
int eventid = (int)id.Value;
The second line var id=skey.EntityKeyValues[0] throws the following exception:
[SqlException (0x80131904): String or binary data would be truncated.
The statement has been terminated.]
Trouble is, EntityKeyValues[0] is code to get the primary key value of the newly inserted record and pass it to a method.
It is a string but I don't see why it should be particuarly large.
Related
I have the following code in Google Cloud Function. The cloud function is written in.NET 6 C#
var testsku = 1414;
var parameters = new BigQueryParameter[]
{
new BigQueryParameter("skuId", BigQueryDbType.Int64, testsku),
};
BigQueryClient client = BigQueryClient.Create(projectID);
string query = #"CALL 'xxxxxxx.xxxxxx.fraudskus'()";
BigQueryJob job = client.CreateQueryJob(
sql: query,
parameters: parameters,
options: new QueryOptions { UseQueryCache = false });
// Wait for the job to complete.
job.PollUntilCompleted();
// Display the results
int numOrders = 0;
foreach (BigQueryRow row in client.GetQueryResults(job.Reference))
{
numOrders++;
}
message = "Num of rows = " + numOrders;
The stored procedure runs fine in BIGQUERY and outputs the right results, but I am getting errors on the call to the stored procedure as follows.
"The service bigquery has thrown an exception.
No HttpStatusCode was specified.
Google.Apis.Requests.RequestError
Job unique-moon-366800/US/job_24e29215_e011_4d66_a2c4_bbf5640d5cc6 contained 2 error(s). First error message: Syntax error: Unexpected string literal 'unique-moon-366800.ecommerce_fraud_ds.fraudskus' at [1:6] [0]
Errors [
Message[Syntax error: Unexpected string literal 'xxxx.xxxxx.fraudskus' at [1:6]] Location[query - ] Reason[invalidQuery] Domain[]
Message[Syntax error: Unexpected string literal 'xxxx.xxxxx.fraudskus' at [1:6]] Location[query - ] Reason[invalidQuery] Domain[]
]
Google.GoogleApiException: The service bigquery has thrown an exception. No HttpStatusCode was specified. Job xxxxxxx/US/job_24e29215_e011_4d66_a2c4_bbf5640d5cc6 contained 2 error(s). First error message: Syntax error: Unexpected string literal 'unique-moon-366800.ecommerce_fraud_ds.fraudskus' at [1:6]
at Google.Cloud.BigQuery.V2.BigQueryJob.ThrowOnFatalError()
at Google.Cloud.BigQuery.V2.BigQueryJob.GetQueryDestinationTable()
at Google.Cloud.BigQuery.V2.BigQueryJob.GetQueryResults(GetQueryResultsOptions options)
at Google.Cloud.BigQuery.V2.BigQueryClientImpl.GetQueryResults(JobReference jobReference, GetQueryResultsOptions options)
at SimpleHttpFunction.Function.HandleAsync(HttpContext context) in /workspace/Function.cs:line 196
at Google.Cloud.Functions.Hosting.HostingInternals.Execute(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)"
I can get the results I expect if I use sql SELECT, but not if I try to call the stored procedure.
Quick summary of issue - when I set the RawString to text, the email with attachment is sent and properly named. When I set the attachment to a RawString message, I get the error "The part 'PartAttachment' of message 'msg_Email' contained a null value at the end of the construct block."
I have created my own RawString class which I have used before. The orchestration receives a CSV file via a pass-thru pipline. Following some documentation I found, I receive a XmlDocument, and in the next shape, I construct the RawString as follows:
msg_Raw_String.MessagePart_1 = msg_Ledger6002_File_XmlDoc;
However if I set the to dummy text in RawString, the email with attachment is sent (the attachment is just a text file with the value below:
msg_Email.PartAttachment = new XXXLedger6002.Component.RawString("Test Text");
Full code in message assignment:
msg_Email.BodyPart = new XXXLedger6002.Component.RawString("See attached email. Method 2 Dynamic");
// Force some value to make sure it is not null
//msg_Email.PartAttachment = new Ledger6002.Component.RawString("Test Text");
// Tried both of these, same error:
//msg_Email.PartAttachment = msg_Ledger6002_File_XmlDoc;
msg_Email.PartAttachment = msg_Raw_String.MessagePart_1;
// syntax doesn't allow this:
// msg_Email.PartAttachment = msg_Raw_String;
// Set the filename as it should display on the attachment in the email
// (drop the path, just the filename/extension)
attachmentName = System.IO.Path.GetFileName(
msg_Ledger6002_File_XmlDoc(FILE.ReceivedFileName));
msg_Email.PartAttachment(MIME.FileName) = attachmentName;
//msg_Email.BodyPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";//
//msg_Email.AttachmentPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
msg_Email(SMTP.Subject) = "Ledger6002 File";
msg_Email(SMTP.SMTPTo) = msg_Config_Email.smtpToEmail;
msg_Email(SMTP.From) = msg_Config_Email.smtpFromEmail;
msg_Email(SMTP.SMTPAuthenticate) = 0; // do not authenticate to SMTP server
msg_Email(SMTP.SMTPHost) = msg_Config_Email.smptHostName;
// msg_Email(SMTP.EmailBodyText) = "UTF-8";
msg_Email(SMTP.EmailBodyTextCharset) = "UTF-8";
msg_Email(SMTP.MessagePartsAttachments) = 2;
// No email generated with comment out line, trying same without mailto:
SMTP_Dyn_Email(Microsoft.XLANGs.BaseTypes.Address) = "mailto:" + msg_Config_Email.smtpToEmail;
SMTP_Dyn_Email(Microsoft.XLANGs.BaseTypes.TransportType) = "SMTP";
Error:
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Ledger6002.Logic.Ledger6002_Process_File(9eb6993c-87d0-7bf0-b0bf-e1f684000af2)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: ecaa7ed2-04c1-46b9-b845-cf3211b83387
Shape name: Send_Dyn_Email
ShapeId: 4ada59c3-367e-40b4-babc-d0d9999feb77
Exception thrown from: segment 1, progress 60
Inner exception: The part 'PartAttachment' of message 'msg_Email' contained a null value at the end of the construct block.
Exception type: NullPartException
Source: Microsoft.XLANGs.Engine
Target Site: System.IO.Stream Persist(System.String ByRef, Boolean)
The following is a stack trace that identifies the location where the exception occured
at Microsoft.XLANGs.Core.CustomFormattedPart.Persist(String& encoding, Boolean wantEncoding)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.StagePartData(Part part)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.PrepareMessage(XLANGMessage msg, IList promoteProps, IList toPromote)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.WriteMessageState(IBTPEPInfoLookup pepLookup, Guid portId, XLANGMessage msg, Segment seg, String opname, String url, IList promoteProps, Boolean track, IList toPromote)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXLogicalPortBinding.SendMessage(XLANGMessage msg, XlangStore store, Segment seg, OperationInfo op, IList additionalProps, IList toPromote, Boolean ignoreRoutingFailure)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.SendMessage(Int32 iOperation, XLANGMessage msg, Correlation[] initCorrelations, Correlation[] followCorrelations, Context cxt, Segment seg, ActivityFlags flags)
at Ledger6002.Logic.Ledger6002_Process_File.segment1(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
The following is a get-around that seems to work.
msg_Email.PartAttachment = new SBA.Ledger6002.Component.RawString(
msg_Raw_String.MessagePart_1.ToString());
If anybody can explain why I just can't set it to msg_Raw_String.MessagePart_1, I would love to know.
I have code below. Creating array of BYTEs, filling it with some sytes, and then trying to read it. When reading, i got an error:
int imageSize = 1024;
BYTE* input = new BYTE[imageSize];
// input is filling by some bytes..
DataWriter ^writer = ref new DataWriter();
writer->WriteBytes(ArrayReference<BYTE>(input, imageSize));
IBuffer ^buffer = writer->DetachBuffer();
DataReader ^ reader = DataReader::FromBuffer(buffer);
auto res = reader->ReadString(buffer->Length); // THIS STRING THROW Platform::COMException ^
Strings cannot contain random data - they must contain well-formed Unicode code-points. I assume the error (which you don't include) says this:
HRESULT:0x80070459 No mapping for the Unicode character exists in the target multi-byte code page.
From the name of your variable (imageSize) it sounds like you're trying to load bitmap data, which is not a valid String.
CREATE OR REPLACE FUNCTION public.writecalculations(id integer, times integer, j json)
RETURNS text
LANGUAGE plv8
AS
$body$
var overallStart = new Date();
var result = 0;
var insertStmt = "Insert into \"CalculationResult\" Values($1,$2,$3::json)"
result += plv8.execute(insertStmt,[id, times, j]);
var loopEnd = new Date();
return JSON.stringify({"AffectedRows": result, "OverallRuntime": loopEnd-overallStart}) ;
$body$
IMMUTABLE STRICT
COST 100;
COMMIT;
This gives an error when executed using
WbCall calculationResult(4,4,'{\"a\":1}');
Error :
An error occurred when executing the SQL command:
ERROR: function calculationresult(integer, integer, unknown) does not exist
Hint: No function matches the given name and argument types. You might need >to add explicit type casts.
Position: 15 [SQL State=42883]
What am I doing wrong?
I tried various options of passing text with "" and '' and also as passing json
try:
WbCall calculationResult(4,4,'{"a":1}'::json);
calculationresult(integer, integer, unknown) - PostgreSQL didn't detect type of '{"a":1}', so it ask you to add explicit type casts.
Is it possible to insert the current time in table using the code datestr(now);?
I am getting this error:
Error using database/fastinsert (line 86) Input data must be a cell array, matrix, or structure
Error in licenseplate>pushbutton23_Callback (line 615) fastinsert(conn,tableName,colnames2,txt);
in the command window.
Here's the code:
conn = database('vlmsystem','admin','admin');
dbpath = 'C:\Users\Sony Vaio\Documents\Task\0.1 Systems\System 1 - edited\Appendix\vlogdbase.mdb';
tableName = 'vehicleLog';
colnames = {'plate_number','date_time','login_logout'};
colnames1 = {'plate_number'};
colnames2 = {'date_time'};
colnames3 = {'login_logout'};
txt = datestr(now);
fastinsert(conn,tableName,colnames2,txt);
close(conn);
EDIT using txt = {datestr(now)} :
I'm getting this error and it's not recording the date in the table.
licenseplate
txt =
'25-Oct-2013 02:03:59'
Error using database/datainsert (line 129)
Unable to insert element in row 1 column 1, 25-Oct-2013 02:03:59.
Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
Error in licenseplate>pushbutton23_Callback (line 615)
datainsert(conn,tableName,colnames2,txt);
Format the datestr according to your database.
How to format datestrings is described in the datestr docs.
You can almost copy&paste that from the last error message:
txt = {datestr(now, 'yyyy-mm-dd HH:MM:SS')}
should be fine.