Showing posts with label certain. Show all posts
Showing posts with label certain. Show all posts

Monday, March 19, 2012

Composite key cannot allow bit column

Made an interesting discovery today - a column of data type Bit is not allowed to participate in composite key. Rather surprised.

I have a certain unique code that exhibits 2 unique states, which rendered the use of the boolean column, so the uniqueness goes <code>-1 and <code>-0. Is there any 'hack' so to speak to avoid using a Tinyint for the boolean column instead?Perhaps instead you could use a unique constraint composed of the 2 columns.

Terri|||I'm sure its not a good idea to use a field with so few values as a part of key. I think the tree tranversal will be impacted and your performance will suffer.|||Well, SQL Server won't allow me to use it as a key, so no "worries" on that. I will try Terri's unique constraint suggestion later.|||Unique constraints don't allow bit columns to participate either. Sigh.|||Actually, I'm sorry, what I meant was a unique index! I had tried that out before posting and it did not give me an error.

Terri

Wednesday, March 7, 2012

Complex SELECT Statement Help

Hi All,

My sql is a little rusty, i ve been trying to do few things but still no luck. I m trying to query some data in one column based on certain . Here is my puzzle:

I have 7 tables: categories, characteristics, configs, rm_cat, rm_chars, rm_conf and rooms.

And here are the details on these tables:

- categories: {cat_id, cat_name}

- characteristics: {char_id, char}

- configs: {conf_id, conf}

- rm_cat: {room_id, cat_id}

- rm_chars: { room_id, char_id}

- rm_conf: {room_id, conf_id}

- room: {room_id. room_name}

I m trying to select a "room_name" based on a certain cat_id, char_id and conf_id and i don't know how to do this.

Sincerely,

Try this:

select room_name

from room

join rm_conf

on room.[room_id]= rm_conf.[room_id]

join configs

on rm_conf.[conf_id]= configs.[conf_id]

join rm_cat

on room.[room_id]= rm_cat.[room_id]

join rm_chars

on room.[room_id]= rm_chars.[room_id]

join categories

on categories.[cat_id]= rm_cat.[cat_id]

join characteristics

on rm_chars.[char_id]= charateristics.[char_id]

where categories.[cat_id]= @.Cat_ID

and characteristics.[char_id]= @.Char_ID

and configs.[conf_id]= @.Conf_ID

|||

Thanks mpateson ...

Could you please tell me why am i getting this error : "ORA - 01722: invalid number" when i try to apply this select statement in my gridview

<asp:GridViewID="GridView1"runat="server"AllowPaging="True"AllowSorting="True"

DataSourceID="search_result">

</asp:GridView>

<asp:SqlDataSourceID="search_result"runat="server"ConnectionString="<%$ ConnectionStrings:ConnectionStringR25 %>"

ProviderName="<%$ ConnectionStrings:ConnectionStringR25.ProviderName %>"SelectCommand="SELECT R25.ROOMS.ROOM_SHORT FROM R25.ROOMS INNER JOIN R25.RM_CONF ON R25.ROOMS.ROOM_ID = R25.RM_CONF.ROOM_ID INNER JOIN R25.CONFIGS ON R25.RM_CONF.CONF_ID = R25.CONFIGS.CONF_ID INNER JOIN R25.RM_CAT ON R25.ROOMS.ROOM_ID = R25.RM_CAT.ROOM_ID INNER JOIN R25.RM_CHARS ON R25.ROOMS.ROOM_ID = R25.RM_CHARS.ROOM_ID INNER JOIN R25.CATEGORIES ON R25.CATEGORIES.CAT_ID = R25.RM_CAT.CAT_ID INNER JOIN R25.CHARACTERISTICS ON R25.RM_CHARS.CHAR_ID = R25.CHARACTERISTICS.CHAR_ID WHERE (R25.CATEGORIES.CAT_ID = :CAT_ID) AND (R25.CHARACTERISTICS.CHAR_ID = :CHAR_ID) AND (R25.CONFIGS.CONF_ID = :CONF_ID)">

<SelectParameters>

<asp:ControlParameterControlID="RadioButtonList1"DefaultValue="NULL"Name="CAT_ID"

PropertyName="SelectedValue"/>

<asp:ControlParameterControlID="CheckBoxList1"DefaultValue="NULL"Name="CHAR_ID"

PropertyName="SelectedValue"/>

<asp:ControlParameterControlID="DropDownList1"DefaultValue="NULL"Name="CONF_ID"

PropertyName="SelectedValue"/>

</SelectParameters>

</asp:SqlDataSource>

|||

I found this on google.

ORA-01722:invalid numberCause:The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal. Only numeric fields or character fields containing numeric data may be used in arithmetic functions or expressions. Only numeric fields may be added to or subtracted from dates.Action:Check the character strings in the function or expression. Check that they contain only numbers, a sign, a decimal point, and the character "E" or "e" and retry the operation.

Saturday, February 25, 2012

Complex Math functions

Hi there friends,

Can any of you please advice me as to how I am going to accomplish certain mathematical functions on numbers such as working out the n-th root of a number since the mathematical functions built in don't go past the square root (2nd root)?

Regards
<!--[if !msEquation]--> <!--[if !vml]--> <![endif]--><!--[if !vml]--><!--[endif]--><!--[endif]-->hi,
you can use the POWER function since the equivalent exponential function of an [n'th root of x] is [x power of 1/n]..
e.g.
if you want to get the 5th root of 100, use POWER(100, 1.0/5.0)

- clintz|||Thank you very much clintz.
|||you can also create user defined function (UDF) for other mathematical functions that you need.. like factorial, permutations, etc.|||It seems i have rejoiced to early:

if i do a simple query like select power(27,1/3),
the resulting value is 1 not 3. why is that?

Regards

|||

bcs 1/3 = 0 (INTEGER DIVISION)

So anything power 0 = 1

To overcome this use the following expression

Select Power(27.0,1.0/3.0)

|||lol of course, thanks so much once again
Regards

Tuesday, February 14, 2012

Compatibility of SQL Server 7.0 with Windows 2K

Is SQL Server 7.0 compatible with the Windows 200 operating system? Are
there certain patches or service packs that need to be applied to SQL to
make this compatibility work? Thanks.

Larry"lmclaus" <lmclaus@.sandia.gov> wrote in message
news:bka37u$j4c$1@.sass2141.sandia.gov...
> Is SQL Server 7.0 compatible with the Windows 200 operating system? Are
> there certain patches or service packs that need to be applied to SQL to
> make this compatibility work? Thanks.
> Larry

http://www.microsoft.com/sql/evalua...datasheet.asp#E

Simon|||"lmclaus" <lmclaus@.sandia.gov> wrote in message
news:bka37u$j4c$1@.sass2141.sandia.gov...
> Is SQL Server 7.0 compatible with the Windows 200 operating system? Are
> there certain patches or service packs that need to be applied to SQL to
> make this compatibility work? Thanks.

Seems to be working fine here.

Ron.
--
Performance Intelligence, Inc.
Spy 4 DB2 - http://www.pireporting.com/spy4db2.html