Showing posts with label tables. Show all posts
Showing posts with label tables. Show all posts

Saturday, March 31, 2012

triggers

I have two tables (STOCK_ITEM and SEASONAL):

STOCK_ITEM
Barcode
Description
Price
Quantity_on_Order
Quantity_in_Stock

SEASONAL
Barcode
Season
Start_Date
End_Date

I want to use a trigger to delete one row out of SEASONAL when one row out
of STOCK_ITEM is deleted. The primary keys of the two rows that are to be
deleted must be the same.

Can you please tell me what is the code for the trigger?

Thanks,

Wally.>> I have two tables (STOCK_ITEM and SEASONAL):...<<

How about using a Cascading Delete...

-- Code
CREATE TABLE StockItems
(
Barcode varchar(20) PRIMARY KEY,
Description varchar(20) NOT NULL,
Price smallmoney NOT NULL,
Quantity_on_Order smallint NULL,
Quantity_in_Stock smallint NOT NULL
);

INSERT StockItems VALUES ('123456789','cool product',11.95,1,10);

CREATE TABLE Seasons
(
SeasonID smallint PRIMARY KEY,
Barcode varchar(20) FOREIGN KEY REFERENCES StockItems(Barcode) ON DELETE
CASCADE,
Season varchar(10) NOT NULL,
Start_Date smalldatetime NOT NULL,
End_Date smalldatetime NOT NULL,
);

INSERT Seasons VALUES (1,'123456789','summer','06/23/06','09/22/06');

DELETE StockItems WHERE Barcode = '123456789';

SELECT COUNT(*) FROM Seasons;

-- results --

0
-- End of Code

Garth
www.SQLBook.com

triggers

I have two tables (STOCK_ITEM and SEASONAL):
STOCK_ITEM
Barcode
Description
Price
Quantity_on_Order
Quantity_in_Stock
SEASONAL
Barcode
Season
Start_Date
End_Date
I want to use a trigger to delete one row out of SEASONAL when one row out
of STOCK_ITEM is deleted. The primary keys of the two rows that are to be
deleted must be the same.
Can you please tell me what is the code for the trigger?
Thanks,
Wally.>> I have two tables (STOCK_ITEM and SEASONAL):...<<
How about using a Cascading Delete...
-- Code
CREATE TABLE StockItems
(
Barcode varchar(20) PRIMARY KEY,
Description varchar(20) NOT NULL,
Price smallmoney NOT NULL,
Quantity_on_Order smallint NULL,
Quantity_in_Stock smallint NOT NULL
);
INSERT StockItems VALUES ('123456789',' product',11.95,1,10);
CREATE TABLE Seasons
(
SeasonID smallint PRIMARY KEY,
Barcode varchar(20) FOREIGN KEY REFERENCES StockItems(Barcode) ON DELETE
CASCADE,
Season varchar(10) NOT NULL,
Start_Date smalldatetime NOT NULL,
End_Date smalldatetime NOT NULL,
);
INSERT Seasons VALUES (1,'123456789','summer','06/23/06','09/22/06');
DELETE StockItems WHERE Barcode = '123456789';
SELECT COUNT(*) FROM Seasons;
-- results --
0
-- End of Code
Garth
www.SQLBook.com

Monday, March 26, 2012

Trouble getting row count from DataReader

I am using the DataReader to populate an ASP table dynamically. I would
like to set the tables "visible" property based on the the data from my
query. For example, if I have at least one row of data, I will set visible
to true, otherwise, false.

How get I find out if I have at least one row of data? The code below is
from the CodeBehind of my asp form.

*****************************
OracleConnection conn = new OracleConnection(ConnectionString);
OracleCommand cmd = new OracleCommand("select * from customer where name =
'BOB', conn);
try
{
conn.Open();
IDataReader reader = cmd.ExecuteReader();
_grid.DataSource = reader;
_grid.DataBind();
}
finally
{
conn.Dispose();
}
*****************************

Thanks,
KevinI think your only option on a DataReader is to use the .Read property. It
returns false if it can't produce a record.

Otherwise, a dataset is necessary to get the actual record count.

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz

"Kevin" <kevin@.spammers_die.com> wrote in message
news:OFV8NLZxDHA.2304@.TK2MSFTNGP12.phx.gbl...
> I am using the DataReader to populate an ASP table dynamically. I would
> like to set the tables "visible" property based on the the data from my
> query. For example, if I have at least one row of data, I will set
visible
> to true, otherwise, false.
> How get I find out if I have at least one row of data? The code below is
> from the CodeBehind of my asp form.
> *****************************
> OracleConnection conn = new OracleConnection(ConnectionString);
> OracleCommand cmd = new OracleCommand("select * from customer where name =
> 'BOB', conn);
> try
> {
> conn.Open();
> IDataReader reader = cmd.ExecuteReader();
> _grid.DataSource = reader;
> _grid.DataBind();
> }
> finally
> {
> conn.Dispose();
> }
> *****************************
> Thanks,
> Kevin
Thanks Jerry, that was exactly what I needed.

Kevin

"Jerry Boone" <jerry@.antech.biz.killspam> wrote in message
news:mkmEb.1432$C21.627@.newssvr22.news.prodigy.com ...
> I think your only option on a DataReader is to use the .Read property. It
> returns false if it can't produce a record.
> Otherwise, a dataset is necessary to get the actual record count.
> --
> Jerry Boone
> Analytical Technologies, Inc.
> http://www.antech.biz
>
> "Kevin" <kevin@.spammers_die.com> wrote in message
> news:OFV8NLZxDHA.2304@.TK2MSFTNGP12.phx.gbl...
> > I am using the DataReader to populate an ASP table dynamically. I would
> > like to set the tables "visible" property based on the the data from my
> > query. For example, if I have at least one row of data, I will set
> visible
> > to true, otherwise, false.
> > How get I find out if I have at least one row of data? The code below
is
> > from the CodeBehind of my asp form.
> > *****************************
> > OracleConnection conn = new OracleConnection(ConnectionString);
> > OracleCommand cmd = new OracleCommand("select * from customer where name
=
> > 'BOB', conn);
> > try
> > {
> > conn.Open();
> > IDataReader reader = cmd.ExecuteReader();
> > _grid.DataSource = reader;
> > _grid.DataBind();
> > }
> > finally
> > {
> > conn.Dispose();
> > }
> > *****************************
> > Thanks,
> > Kevin

Tuesday, March 13, 2012

Trouble with Table borders

Hello
I seem to have a re-occuring problem with tables.
Every tiime i create a new table in my code (Table x = new Table();) it
creates in the final code the browser gets the attribute 'border="0"'.(i
prefer putting my styles in a seprate css file)
Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
nothing seems to work.even changing the Table.BorderWidth property creates a
'style="border-width:x"' and stucks me with the 'border="0"'.
It happens even when i create classes derived from Table.
Please help me,it's really annoying.
Thank you.It's hard-coded in the table creation - unfortunetly. But I don't see why
it'd be causing problems with your css decleration? if you do
<table border="0" class="Blah"> and the Blah class defines a border, it
ought to apply it reguarless of what the border says..
Karl
--
http://www.openmymind.net/
"ThePinkPanther" <ThePinkPanther@.discussions.microsoft.com> wrote in message
news:E9E18BBB-B846-40B3-AAD4-A16272C96D68@.microsoft.com...
> Hello
> I seem to have a re-occuring problem with tables.
> Every tiime i create a new table in my code (Table x = new Table();) it
> creates in the final code the browser gets the attribute 'border="0"'.(i
> prefer putting my styles in a seprate css file)
> Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
> nothing seems to work.even changing the Table.BorderWidth property creates
> a
> 'style="border-width:x"' and stucks me with the 'border="0"'.
> It happens even when i create classes derived from Table.
> Please help me,it's really annoying.
> Thank you.
> It's hard-coded in the table creation - unfortunetly. But I don't see why
> it'd be causing problems with your css decleration? if you do

> <table border="0" class="Blah"> and the Blah class defines a border, it
> ought to apply it reguarless of what the border says..
Not true, CSS properties are overriden by inline styles. Not very
helpful, I know.
Well, I'm willing to admit that i'm wrong...but...
I agree that external css properties are overriden by inline styles, but
border="0" isn't an inline style, it's an attribute decleration which ARE
overriden by any styles (inline or external).
so if you do:
<table border="0">
<tr><td>asdsa</td></tr>
</table>
and you create a style in a css:
table
{
border:1px solid #000;
}
you WILL see the border
Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Flinky Wisty Pomm" <Pathogenix@.gmail.com> wrote in message
news:1139834577.520780.250200@.g47g2000cwa.googlegroups.com...
>
> Not true, CSS properties are overriden by inline styles. Not very
> helpful, I know.
>
Object withdrawn :)
Always happy to be proven wrong.

Trouble with Table borders

Hello
I seem to have a re-occuring problem with tables.
Every tiime i create a new table in my code (Table x = new Table();) it
creates in the final code the browser gets the attribute 'border="0"'.(i
prefer putting my styles in a seprate css file)
Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
nothing seems to work.even changing the Table.BorderWidth property creates a
'style="border-width:x"' and stucks me with the 'border="0"'.
It happens even when i create classes derived from Table.

Please help me,it's really annoying.
Thank you.It's hard-coded in the table creation - unfortunetly. But I don't see why
it'd be causing problems with your css decleration? if you do

<table border="0" class="Blah"> and the Blah class defines a border, it
ought to apply it reguarless of what the border says..

Karl
--
http://www.openmymind.net/

"ThePinkPanther" <ThePinkPanther@.discussions.microsoft.com> wrote in message
news:E9E18BBB-B846-40B3-AAD4-A16272C96D68@.microsoft.com...
> Hello
> I seem to have a re-occuring problem with tables.
> Every tiime i create a new table in my code (Table x = new Table();) it
> creates in the final code the browser gets the attribute 'border="0"'.(i
> prefer putting my styles in a seprate css file)
> Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
> nothing seems to work.even changing the Table.BorderWidth property creates
> a
> 'style="border-width:x"' and stucks me with the 'border="0"'.
> It happens even when i create classes derived from Table.
> Please help me,it's really annoying.
> Thank you.
> It's hard-coded in the table creation - unfortunetly. But I don't see why
> it'd be causing problems with your css decleration? if you do

> <table border="0" class="Blah"> and the Blah class defines a border, it
> ought to apply it reguarless of what the border says..

Not true, CSS properties are overriden by inline styles. Not very
helpful, I know.
Well, I'm willing to admit that i'm wrong...but...

I agree that external css properties are overriden by inline styles, but
border="0" isn't an inline style, it's an attribute decleration which ARE
overriden by any styles (inline or external).

so if you do:
<table border="0">
<tr><td>asdsa</td></tr>
</table
and you create a style in a css:

table
{
border:1px solid #000;
}

you WILL see the border

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/

"Flinky Wisty Pomm" <Pathogenix@.gmail.com> wrote in message
news:1139834577.520780.250200@.g47g2000cwa.googlegr oups.com...
>> It's hard-coded in the table creation - unfortunetly. But I don't see why
>> it'd be causing problems with your css decleration? if you do
>> <table border="0" class="Blah"> and the Blah class defines a border, it
>> ought to apply it reguarless of what the border says..
> Not true, CSS properties are overriden by inline styles. Not very
> helpful, I know.
Object withdrawn :)

Always happy to be proven wrong.