RE: Problem in using trigger

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: John Bell (JohnBell_at_discussions.microsoft.com)
Date: 09/14/04


Date: Tue, 14 Sep 2004 00:27:14 -0700

Hi

You don't give the code for the trigger therefore it is not possible to see
what would be happening. If you posted DDL (Create table, Create Trigger
etc...) statements it would be alot cleared along with example data (as
insert statements) See http://www.aspfaq.com/etiquette.asp?id=5006 for
information regarding doing this.

You may want to consider using a stored procedure to provide this
functionality and encapsulate the logic so the work is performed on the
server.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmscadocodeexamplesinvbscript.asp?frame=true

The requery method will refresh a record set. Your AutoRs recordset does not
have any parameters therefore you are not being product specific. Also SELECT
* is not deemed as good coding for a production environment.

HTH

John
"Sridhar K" wrote:

> Dear All,
>
> I am facing problem in using the "TRIGGER"
>
> There are 2 tables.
>
> Ex
> Table 1
> Table 2 - (Insert Trigger written in this table)
>
> I am getting some value from previous page(asp)
>
> Following is my code structure
> ========================
> <%
> Set ProductRs = Myconn.execute("Select VFld1 from Table1")
> If Not ProductRs.Eof Then
> Fld1 = ProductRs("VFld1") + Request.Form("User_Value")
> Set AutoRs = Myconn.execute("Select * from Table2")
> If Not AutoRs.eof then
> Response.Write "Info not matching. Try again"
> End If
> If AutoRs.eof then
> MyConn.Execute("Update Table1 Set Fld1 = " & VFld1 & ", Fld2 =
> '"&VFld2&"' where Prd_Sl_no=" &VFld3&"")
> Myconn.execute("insert into Table2(sFld1,sfld2,sfld3)
> values("&VsFld1&",'"&VsFld2&"','"&VsFld3&"')")
> End If
> End If
> %>
>
> Step 1
> ====
> I am creating a record set called "ProductRs" with "Table 1"
> Here The ProductRs("VFld1") = 3000
> Step 2
> ====
> Here the the Request.Form("User_Value") = 2000
> Adding user value to the VFld1 of the record set "ProductRs"
> Let say The Total is 5000
>
> Step 3
> ====
> Here i am creating another record set which is "AutoRs"
> Which is currently EOF
>
> Now my problem is.
>
> Since the AutoRs is eof
>
> The update and the insert statments are executed.
>
> But after this process the "If Not AutoRs.eof Then " statment also
> executed. and more then that now the ProductRs("VFld1") = 5000.
>
> But i am not executed the "ProductRs" agin.
>
> Earlier the ProductRs("VFld1") = 3000
> Now the ProductRs("VFld1") = 5000
>
> Like that
>
> Earlier AutoRs is eof
>
> Now it is Not AutoRs eof
>
> I Mean to say both(all) the statments are executed.
>
> Give me a solution.
>
> Regards
> Sridhar K
> Chennai - India
>
>
>
>



Relevant Pages

  • Problem in using trigger
    ... I am creating a record set called "ProductRs" with "Table 1" ... Here i am creating another record set which is "AutoRs" ... Which is currently EOF ...
    (microsoft.public.sqlserver.programming)
  • Re: scanf (yes/no) - doesnt work + deprecation errors scanf, fopen etc.
    ... C standard allows, but in C89 at least does not require, EOF to be ... Control-D might be the character that you enter to ... trigger and end-of-file condition, which will then cause getcharto ... The way an end-of-file condition is triggered ...
    (comp.lang.c)
  • Re: EOF question
    ... > The program should read input characters until it hits an EOF ... How that EOF condition is triggered is system-specific. ... > should be able to trigger and EOF by entering control-Z on a line by ...
    (comp.lang.c)
  • Re: EOF question
    ... The program should read input characters until it hits an EOF ... How that EOF condition is triggered is system-specific. ... should be able to trigger and EOF by entering control-Z on a line by ...
    (comp.lang.c)