LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error in stamptime from sql using data base

Hello,

I am trying to read one sql file (.db). But from the data table I got wrong number in time stamp, the data is unix data time but Labview give me the same number in all the rows.

What is the problem?.

Regards.

0 Kudos
Message 1 of 12
(4,138 Views)

That's the maximum size of an I32 variable. You need to read it as a longer datatype - the LabVIEW Timestamp is 128 bits.

A more detailed description of the Timestamp format is available here.


GCentral
0 Kudos
Message 2 of 12
(4,131 Views)

Thanks for reply!.

 

But, How I get the two integers I64 from 'Database Variant to Data'?.

I didnt get it.

Regards.

 

0 Kudos
Message 3 of 12
(4,087 Views)

There's a snippet shown below with an array of clusters passed as the datatype to the DB Variant to Data. You can use this by appropriately filling the cluster constant (with datatypes for your result row), then right clicking and choosing Change to Array (to get an array, one element per row).

 

Here I used a Time Stamp Constant and a Double, which won't exactly work for you but gives you the idea. You probably want a cluster of Time Stamp Constant (or pair of I64, or just one I64 depending on the storage), 3 integers (I don't know the size, but you could try I32) and two floating point variables (probably double, but consider single if it doesn't work well for you).

 

You should make this cluster a typedef once you know the types you want.

Example_VI.png


GCentral
0 Kudos
Message 4 of 12
(4,075 Views)

Hello,

Yes, I tried to create constant cluster and put inside the stamp time constant and the 3 I32 and 3 Doubles.

Then this cluster of 7, put inside of array constant. But I got 0 readings. How I can do one pair of I64 for fist value in cluster?.

You can see with cluster of 7 elements inside 1D array I didnt get any data.

IF I remove the time stamp I got the numbers but I need more bits.

What is the wrong part?.

Thanks, Fred.

Download All
0 Kudos
Message 5 of 12
(4,066 Views)

Try replacing the timestamp with a DBL value. It looks like your values line up with 64 bits for the time entry, but it's hard for me to guess further because I don't know how you created the table. At least in SQLite (perhaps not directly relevant here, but anyway...) I believe numeric fields take a width only as needed.

 

The LabVIEW Database Connectivity toolkit manual in chapter 4 discusses data types, but it doesn't seem very encouraging for forcing specific widths. It is worth noting that SQL supports a date/time format - but I guess you're not writing that 🙂

 

Copied from the manual:

All LabVIEW data types are supported but not necessarily in their native form. For example, bytes (U8 and I8) and words (U16 and I16) can be treated as longs (I32). The binary data type encompasses any piece of LabVIEW data, such as waveform, cluster, or array data, that cannot be represented natively in the database. Table 4-2 lists LabVIEW data types and the data types in the Database Connectivity Toolkit to which they correspond.

 

There's an accompanying table (4-2) which gives the conversion types. SGL and DBL probably match, most integer classes are probably I32. As I understand it, values in the upper half of U32 and (all) I/U64 are all stored as strings. 

 

The manual continues with the following note:

You also can use the DB Tools Format Datetime Str VI to insert date/time strings into a database. The DB Tools Format Datetime Str VI formats a string into the correct format for SQL. This VI places a header at the beginning of the string that is later decoded in other VIs to determine that the string is a date/time string. Refer to the Formatting Date and Time section of Chapter 6, Using the Database Connectivity Toolkit Utility VIs, for more information about using the DB Tools Format Datetime Str VI to format date and time in a database.


GCentral
0 Kudos
Message 6 of 12
(4,044 Views)

Thanks for your time and help!.

I tried everything but I dont know what happens.

I attached the vi, with the data entry.

 

If you can look at this...

Regards.

0 Kudos
Message 7 of 12
(4,039 Views)

They're saved in the cluster constant as type VT_I4, which is a 32 bit signed integer (I32). The database presumably is storing them as something longer (or at least, differently) to be able to get larger values.


GCentral
0 Kudos
Message 8 of 12
(4,030 Views)

Yes, I checked it. But like you looked in capture, the SQLite Expert software read it perfectly.

So the problem is Database Toolkit from Labview. I dont know if It need to fix the entries or use any query to get the data stamp correctly.

 

Regards and Thanks.

0 Kudos
Message 9 of 12
(4,021 Views)

Ah - what I meant is I can't try and troubleshoot the VI you attached, because the time data is already truncated in the default data you helpfully provided.


GCentral
0 Kudos
Message 10 of 12
(4,015 Views)