At the point of posting a record to a database table I get the following error:
Could not parse sql timestamp string.
At the click of a button my code does the following:
qry1.Open;
qry1.Insert;
qry1.FieldByName('files_uploaded').asdatetime := qry2.FieldByName('files_uploaded').asdatetime;
qry1.Post;
qry1.Close;
The datatype for the field in the database table is timestamp.
Example of the data in the field : 2014-04-23T14:48:40.816+01:00.
I'm not entirely sure what I'm doing wrong or unless its something to do with the field data.
Any help would be appreciated.
Please try this code:
qry1.Open;
qry1.Insert;
qry1.FieldByName('files_uploaded').AsSQLTimeStamp :=qry2.FieldByName('files_uploaded').AsSQLTimeStamp;
qry1.Post;
qry1.Close;
Try setting ".Value" instead of defining the Data Type. When you use .Value the dataset will convert everything that is necessary.
qry1.Open;
qry1.Insert;
qry1.FieldByName('files_uploaded').Value :=qry2.FieldByName('files_uploaded').Value;
qry1.Post;
qry1.Close;
Related
I want to create an object in a triple with a datatype Double. I have the following code:
if(!spine.equals(null)){
register_res.addProperty(spineWidth, model.createTypedLiteral(new XSDDouble(spine)));
}
I am reading spine from a csv file and saving it in a String.
I am getting the following error:
java.lang.NullPointerException
at org.apache.jena.datatypes.xsd.XSDDatatype.<init>(XSDDatatype.java:231)
at org.apache.jena.datatypes.xsd.impl.XSDDouble.<init>(XSDDouble.java:38)
at VolumesUpload.main(VolumesUpload.java:140)
Any idea what is wrong please?
XSDDouble is the class of the datatype, not the value.
You want:
model.createTypedLiteral("4.5", XSDDatatype.XSDdouble);
if spine is the lexical form of the value or
model.createTypedLiteral(Double.valueOf("4.5"));
to create from a value.
I'm looking for help with a stored procedure in teradata. I want to update a whole table and for this I'm trying to use a for loop cursor. the problem is that my update is defined via column names passing through parameters to the SP.
I've seen it can be possible to use dynamic sql to do that but I haven't found any information on the subject concerning for loop cursor and dynamic sql. Is it possible with FOR LOOP CURSOR ?
I've tried to do only the select and calculs with dynamic sql, it works fine but then the problem is to update the table from the cursor on the select. In this case how to update a table from my cursor?
I let you show my code.
loop cursor :
REPLACE PROCEDURE [database].calDELAI
(
IN dateDebut VARCHAR(30),
IN dateFin VARCHAR(30),
IN delay VARCHAR(30)
)
BEGIN
DECLARE DATE_DEBUT_COLONNE VARCHAR(64);
DECLARE DATE_FIN_COLONNE VARCHAR(64);
SET DATE_DEBUT_COLONNE=dateDebut;
SET DATE_FIN_COLONNE=dateFin;
FOR for_loop_update AS cur_select_set CURSOR FOR
SELECT
TMP.DATE_FIN_COLONNE-TMP.DATE_DEBUT_COLONNE
FROM [database].ORD_T_DETL_ORDR_DELAI AS TMP
/* the select is more complicated but here is the spirit of it.*/
DO
IF (delay='DELAI1') THEN SET DELAI1=NB_JR_OUVRABLE;
END IF;
END FOR ;
END ;
The errors given by teradata are :
SPL1027:E, Missing/Invalid SQL statement'E(3810):Column/Parameter '[database].TMP.DATE_FIN_COLONNE' does not exist.'.
SPL2001:E, Undefined symbol 'DELAI1'.
SPL2001:E, Undefined symbol 'NB_JR_OUVRABLE'.
Thanks in advance for your replies and your help.
The call statement should contain all the input Paramenters , make sure you are specifying all the input parameters correctly. Could you please provide your call statement.
I had a multi tier project in which i would collect data from a microsoft sql 2005 through a FDStoredProc with a function and the function would return a dataset to the client. When the server assigns the dataset to the result of the function and the function tries to send it to the client i get this error. Project etctec.exe raised exception class TDBXError with message 'TDBXTypes.BLOB value type cannot be accessed as TDBXTypes.Bytes value type'.
In another project i used the StoredProc of a different database with TFDStoredProc in exactly the same way and it works fine. Any ideas what would raise this error?
This is what i do in the server.
function TServerMethods1.getCategories(): TDataSet;
begin
FDStoredProc1.ParamByName('#val1').AsInteger:= 1;
FDStoredProc1.ParamByName('#val2').AsInteger:= 0;
FDStoredProc1.ParamByName('#val3').AsInteger:= 1;
FDStoredProc1.ParamByName('#val4').AsInteger:= 1;
FDStoredProc1.Open();
result:= FDStoredProc1;
end;
and the client calls it like this...
dataset:=ClientModule1.ServerMethods1Client.getCategories();
Problem comes from some fields that are of type NVARCHAR(max), anyone knows a workaround to this error without changing the field type?
I tried changing the dataset's field type to a string or something with no success. The only thing i can temporarily do is get these fields separately, put them in a stringlist or something like that and pass it to the client.
I think you should use some of similar methods below:
http://docwiki.embarcadero.com/Libraries/XE4/en/Data.DB.TDataSet.CreateBlobStream
http://docwiki.embarcadero.com/Libraries/XE4/en/Data.DB.TDataSet.GetBlobFieldData
You should define you field as a blob field and then put data in/out with the functions described in the links.
Here is also example how to copy data:
http://docwiki.embarcadero.com/Libraries/XE4/en/Data.DB.TDataSet.CreateBlobStream
Why is it that my query does not work ?
Form1.ABSQuery1.Close;
Form1.ABSQuery1.SQL.Clear;
Form1.ABSQuery1.SQL.Text:='DELETE FROM LOG WHERE status = ''YES'' and DATE BETWEEN :d1 and :d2';
Form1.ABSQuery1.Params.ParamByName('d1').Value :=cxDateEdit1.Date;
Form1.ABSQuery1.Params.ParamByName('d2').Value :=cxDateEdit2.Date;
Form1.ABSQuery1.ExecSQL;
Form1.ABSTable1.Refresh;
I get this error :
You should be using AsDateTime in your Params setting code.
Form1.ABSQuery1.SQL.Text:='DELETE FROM LOG WHERE status = ''YES'' and DATE BETWEEN :d1 and :d2';
Form1.ABSQuery1.Params.ParamByName('d1').AsDateTime :=cxDateEdit1.Date;
Form1.ABSQuery1.Params.ParamByName('d2').AsDateTime :=cxDateEdit2.Date;
Form1.ABSQuery1.ExecSQL;
Using Value converts the cxDateEdit1.Date to a generic string format for assignment, and that doesn't properly convert it to the YYYY-MM-DD format that most databases (including ABS) expect. Properly using AsDateTime allows the database driver/component to convert to the specific date format the DBMS uses.
Also, is your database field really named DATE? Date is usually a reserved word or function name in most DBMS, and if it is it usually needs to be quoted.
Form1.ABSQuery1.Params.ParamByName('d1').DataType := ftDateTime;
Form1.ABSQuery1.Params.ParamByName('d1').Value :=cxDateEdit1.Date;
You must explicitly specify the data type of the parameter to it had no such problem, and then convert to a string does not need to
This is a simple rails form using CKeditor.
I'm saving the content, it appears in the Update.
pp params[:email]["body"]
"<br />\r\nheyyy<br />\r\nbut now i am going to save this past 9 lines.<br />\r\ncuz that's what this is all about<br />\r\n<br />\r\nI am crazy like that<br />\r\nc<br />\r\ncrazy<br />\r\ncrazy c<br />\r\ncrazy<br />\r\n<br />\r\nhere is another line..<br />\r\noh#!!&<br />\r\nfa<br />\r\nsdf<br />\r\nas<br />\r\ndf<br />\r\nasd<br />\r\nfa<br />\r\nsdfasdf<br />\r\n"
Then my controller goes like this :
#emails = Email.find(params[:id])
Then! After this is called, I type #emails.body in ruby-debug, and it outputs 1/2 of that! :
#emails.body
"<br />\r\nheyyy<br />\r\nbut now i am going to save this past 9 lines.<br />\r\ncuz that's what this is all about<br />\r\n<br />\r\nI am crazy like that<br />\r\nc<br />\r\ncrazy<br />\r\ncrazy c<br />\r\ncrazy<br />\r\n<br />\r\nhere is another line..<br />\r\noh#!!&"
Why would that occur?
The attribute is saved as a string in my database.
You're likely storing it in the database as a varchar instead of text. Depending on the length of the varchar, it will simply truncate the data instead of return an error. You can easily change the column type in a migration:
change_column :my_table, :my_column, :text
What sort of column is body? Could it be that it's a MySQL varchar(255) or something similar that's just being overloaded?
Are you sure you called:
#emails.save
in the controller ??
If so, try calling:
#emails.save!
It should raise an error if something goes wrong.