|
:->
can u also please elaborate the functionality of
DECLARE @salary int;<br />
SELECT @salary = salary FROM inserted;
what is 'FROM inserted'?
|
|
|
|
|
First to DECLARE a variable by the name of @salary and define it as an integer.
Then to SELECT the value from the salary column in the inserted table (a virtual table provided inside the trigger that contains all the inserted data)
|
|
|
|
|
Actually, you are probably better with some sort of constraint.
Set up the rule:
CREATE RULE validSalary AS @salary <1000000;
Bind the rule to the column:
EXEC sp_bindrule 'validSalary', 'Employee.Salary'
|
|
|
|
|
re Rules substitutes for triggers??
what i mean is that Triggers can be applied for three different operations i.e. for INSERT, DELETE and UPDATE
can rule be used likewise??
|
|
|
|
|
Saira Tanwir wrote: re Rules substitutes for triggers??
It isn't a substitute. But it seem to me that what you want in this instance is a rule. Not a trigger.
A trigger says "here are some additional actions to perform when something happens" a rule says "in order to allow this to happen, you must satisfy my condition"
A rule is applied on a column. It will be checked when data is inserted or updated. A rule cannot have an effect on a delete.
|
|
|
|
|
okay
then the validation rules that are applied on a column in MS Access(if u've worked in it) are at the backend Triggers or Rules? cause trying to do something similr to that an it would be a help if u would clear my concepts too.
|
|
|
|
|
No idea - I thought we were talking about SQL Server. I don't use Access.
|
|
|
|
|
Don't worry, we still are using Sql Server i just asked perchance
thanks a lot for the great help
until next time
Regards
Saira
|
|
|
|
|
When should I go for query & when should I prefer SP? For example, we can wrap a simple select query inside an SP . Is it a better way? Any technical advanatages by using a particular method? I'm asking just for optimizing my app.
*
|
|
|
|
|
General rule: Go for a query when you are doing something quick and dirty. Go for a stored procedure in all other circumstances.
|
|
|
|
|
SPs are the best for your db an sql: 1) less traffic on your network 2) best performance on your db 3) encapsulation and security are easier to manage.
|
|
|
|
|
Am retrieving data from my databese engine to read the data, but encountering an error at dr.Read(), con.close()
string connection=@" ";
SqlConnection con = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand("select * from employee",con);
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
con.Close();
"Invalid token '(' in class, struct, or interface member declaration", what could be the reason for this?
-- modified at 18:57 Friday 9th February, 2007
|
|
|
|
|
sreecahitu wrote: Invalid token '(' in class, struct, or interface member declaration
I don't know why that error occurs. There is not enough information given.
However, I can point out other problems with the code.
1. The connection string is empty (although I'm guessing you removed it for security)
2. You never open the connection.
3. You read from the database but you never check if anything exists, and if it does exist you never actually get the data.
|
|
|
|
|
Hello everyone
I wanted to ask if we can update the column values automatically?
my requirement is a particular column value of a table should get changed when the system time is changed
can this be done in T-sql?
Please reply its very urgent thank you
|
|
|
|
|
Ravi Ahuja wrote: my requirement is a particular column value of a table should get changed when the system time is changed
can this be done in T-sql?
Given that the system time is changing continuously, no.
What exactly is your objective? There might be a better way of thinking about the problem.
|
|
|
|
|
my objective say when the system date changes say today is 02/11/2007 so when the date will change to 02/12/2007
the column value should change.
see basically i am working on a ticket reservation project
so when a ticket is issued to a customer his status is set to confirmed or waiting depending upon the situation
and when the train departs than his status must change as departed
|
|
|
|
|
Ravi Ahuja wrote: so when a ticket is issued to a customer his status is set to confirmed or waiting depending upon the situation
and when the train departs than his status must change as departed
And you are saying that a train has departed based on the time, rather than whether the train actually departed or not.... Interesting system...
I suggest you need to find a way to be told that a train actually departed rather than when you expected the train to depart (if at all)
|
|
|
|
|
I have to make questions like this:
CString abfrage;
abfrage = "SELECT kstnr, kststamm.Bezeichnung, karnr, KarBezeichnung, buchungen.ktrnr, KtrBezeichnung, betrag, datum, datenart, belsymbol,\
belnr, text FROM buchungen LEFT OUTER JOIN karstamm ON buchungen.karnr = karstamm.Nummer ";
abfrage = abfrage + "LEFT OUTER JOIN kststamm ON buchungen.kstnr = kststamm.Nummer ";
abfrage = abfrage + " LEFT OUTER JOIN ktrstamm ON buchungen.ktrnr = ktrstamm.KtrNr WHERE datum >= ";
abfrage = abfrage + "'" + kstvon.c_str() + "' AND datum <= '" + kstbis.c_str() + "'";
if (kstnr != "") abfrage = abfrage + " AND kstnr = '" + kstnr.c_str() + "'";
if (koarnr != "") abfrage = abfrage + " AND karnr = '" + koarnr.c_str() + "'";
if (datenart != "") abfrage = abfrage + " AND datenart = '" + datenart.c_str() + "'";
rs->Close();
rs->Open(CRecordset::snapshot, abfrage);
Is there an easier way to make a Select in VC++??
I made this question in the Longe, unforounatly - and my question was even deleted (what's right, wrong click;))
But can anyone help here???
Thanks, Gerhard
|
|
|
|
|
Your question is not 100% on this forum again;)
anyway I forgot sql server but I think its possible can you create a view on your database and use of it on the VC++?and also you can use of CString::Insert instead abfrage = abfrage + ...;)
|
|
|
|
|
Tahnks,
Seems to be a good idea.
Can you tell me, what would be the right forum for a question like this. Lounge was a fault, of course - sorry.
Gerhard
|
|
|
|
|
Your're welcome
Well Lounge was 100% fault.No programming questions please (on the Lounge);)
Why you cant find MFC forum (Visual C++ / MFC) Visual C++ / MFC[^]
|
|
|
|
|
Becouse I opened the menue-point 'Message Boards' and searched there. And there it's called Visual C++ only.
But I already found, thanks
|
|
|
|
|
Not problem maybe you are new here(codeproject),but I am ready to help people
|
|
|
|
|
Try the CString::Format member.
Here is what with ADO and MFC:
CString tempStr;
try {
tempStr.Format("SELECT * "
"FROM CAD_Info "
"WHERE ( ([SessionNumber] = %d) "
"AND ([SiteID] = %d) "
"AND ([SeqNumber] = %d) )",
nSession,nSiteID,nSeqNum);
CMainDataBase::TESTHR(pRst.CreateInstance(__uuidof(Recordset)));
CADORecordSetEx rst(m_pDB,pRst);
rst.Open(tempStr,m_cursorType,m_lockType, adCmdText);
}
catch(CException* e)
{
}
catch (...)
{
}
I know you are using CRecordSet and DAO but the syntax should be similar.
John
|
|
|
|
|
Thanks for the answer,
Unfortunatly I have no experience with ADO, but I have some books to learn it. Maybe I have to do so now;)
BTW, the statemant above ment, this is not the rigth forum too. What would be the right one. In the Lounge ( sorry again), you said, I should try in the MFC-forum, but I can't find.
Thanks, Gerhard
|
|
|
|