datatypes

Can RoR deal with char(1) fields as "boolean" fields?

I am looking at using Ruby on Rails for a storefront that has to make use of existing data, but I can create my own database schema if I need to. A lot of the fields in the existing data are char(1) emulating a boolean field (i.e. Y/N) for, I believe, cross-platform portability. Since the data is prone to change, I don't want to have t...

Why am I able to read char[2] but not char[1]?

I am able to read char into char[2] in OCI C++ code, but I am not able to read to char[1]? Does anyone have any idea why? (oracle data type is char(1)) ...

SQL - Informix - Changing the datatype of a column from numeric to character.

I have a temp table that has numeric integer values in one column. I want to either replace the integer values with character values based on some criteria or I want to add another column of character type that automatically inserts values into itself based on some criteria. If x <= 1, change to "SP" or make new column and store "SP" i...

Using integers and requiring multiplication vs. using decimals as a data type - what are your thoughts?

What are your thoughts on this? I'm working on integrating some new data that's in a tab-delimited text format, and all of the decimal columns are kept as single integers; in order to determine the decimal amount you need to multiply the number by .01. It does this for things like percentages, weight and pricing information. For examp...

How do you deal with char(1) in place of a boolean and tri-state fields?

Somewhat related to my question about integers instead of decimals; my vendor provides a lot of "boolean" fields in the char(1) format (i.e. Y/N). Some of these fields legitimately cannot be a boolean because they can have several values, but the majority can be treated as a boolean. In my previous question the advice was to do what's ...

How to get IntPtr from byte[] in C#

Hi All, I want to pass a byte[] to a method takes a IntPtr Parameter in c#, is that possible and how. Thanks All ...

Float in Database to ? in .NET

If you have a float in MSSQLServer, to what do you map this in .NET? Can you convert it to Double or will you loose numbers? thx, Lieven Cardoen ...

To cast or to function call?

In PHP is it better to convert a value to an integer using the syntax (int)$value or intval($value) the question is also be relevant to string, bool, float ...

Conversion of a unicode character from byte

In our API, we use byte[] to send over data across the network. Everything worked fine, until the day our "foreign" clients decided to pass/receive Unicode characters. As far as I know, Unicode characters occupy 2 bytes, however, we only allocate 1 byte in the byte array for them. Here is how we read the character from the byte[] ...

typedef equivalent for overloading in c#

I have a bunch of code that has lots integers with different meanings (I'd rather a general solution but for a specific example: day-of-the-month vs. month-of-the-year vs. year etc.). I want to be able to overload a class constructor based on these meanings. For example int a; // takes role A int b; // takes role B var A = new Foo(a)...

Compiler Error C2632: Type 1 followed by Type 2 is illegal

I'm trying to learn an SDK that requires a header file be included. There are two statements in the header file that says typedef long long SomeIdentifier_SInt64; and typedef unsigned long SomeIdentifier_UInt64; The compiler (MSVC++ 6) is complaining that this is illegal. If so, does this mean the SDK is broken? I seriously doubt ...

Best data type to store list of strings?

In .NET which data type do you use to store list of strings ? Currently I'm using List(Of String) because it's easier than Array to manage and add/remove stuff. I'm trying to understand what are the other options, when they become handy and when I should avoid List(Of String) usage. Do you use another type? Why and When? ...

Change type of a column with numbers from varchar to int

We have two columns in a database which is currently of type varchar(16). Thing is, it contains numbers and always will contain numbers. We therefore want to change its type to integer. But the problem is that it of course already contains data. Is there any way we can change the type of that column from varchar to int, and not lose al...

Get bools out of byte and the other way

Simple question: How do i tell which bits in the byte are set to 0 and which are set to 1 for example: //That code would obviously wont work, but how do i make something similar that would work? byte myByte = 0X32; foreach(bool bit in myByte) { Console.WriteLine(bit); } //Part 2 revert bool[] bits = new bool[8]; bits[0] = 0 bits[...

Should you choose the MONEY or DECIMAL(x,y) datatypes in SQL Server?

I'm curious as to whether or not there is a real difference between the money datatype and something like decimal(19,4) (which is what money uses internally, I believe). I'm aware that money is specific to SQL Server. What I want to know is if there is a compelling reason to choose one over the other; most SQL Server samples (e.g. the ...

Convert object to integer in PHP

The value of $total_results = 10 $total_results in an object, according to gettype() I cannot use mathematical operators on $total_results because it's not numeric Tried $total_results = intval($total_results) to convert to an integer, but no luck The notice I get is: Object of class Zend_Gdata_Extension_OpenSearchTotalResults could not...

using part of a byte array

If I have an array of bytes created byte[] binBuffer = new byte[256] and I fill up 100 bytes of the array, if I want to pass only those 100 bytes to some other method, is it possible to do that without creating a new byte array of 100 bytes, copying from the old array to the new, then passing off the new array? Is there somehow I can ju...

Why aren't op-assign operators type safe in java?

I'm not sure the question is clearly worded, but an example will be clearer. I found out that will not work in Java: int a = ...; a = 5.0; but this will: int a = ...; a += 5.0; I.e., it seems that the = operator is type safe but += isn't. Is there any deep reason for this or is it just another arbitrary decision language designer...

SQL When to use Which Data Type

Hi I was wondering when I should use the different data types. As in in my table, how can I decide which to use: nvarchar, nchar, varchar, varbinary, etc. Examples: What would I use for a ... column: Phone number, Address, First Name, Last Name, Email, ID number, etc. Thanks for any help! ...

Best practises for dealing with monetary amounts in C#

I have read a couple of articles about the perils of certain data types being used to store monetary amounts. Unfortunately, some of the concepts are not in my comfort zone. Having read these articles, what are the best practises and recommendations for working with money in C#? Should I use a certain data type for a small amount and a ...