Mysql Trigger
am 10.07.2011 10:32:21 von vishesh kumar
--bcaec547c08dce78e404a7b2e788
Content-Type: text/plain; charset=ISO-8859-1
Hi Members
Whats wrong i am doing in following create trigger statement
Create trigger test before insert on user
for each row
begin
set New.host=upper(new.host)
end
Above statement giving error check sql syntax , please guide me. I want to
put host field value in uppercase in user table
--
http://linuxmantra.com
--bcaec547c08dce78e404a7b2e788--
Re: Mysql Trigger
am 10.07.2011 11:12:50 von Reindl Harald
--------------enig722FF9439A70AC9C6B6E3D0D
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Am 10.07.2011 10:32, schrieb vishesh kumar:
> Hi Members
>=20
> Whats wrong i am doing in following create trigger statement
>=20
> Create trigger test before insert on user
> for each row
> begin
> set New.host=3Dupper(new.host)
> end
>=20
> Above statement giving error check sql syntax , please guide me. I wan=
t to
> put host field value in uppercase in user table
a) why "before insert"
b) why "for each row" when a single update can do this
c) update table_name set fieldname=3Dupper(fieldname)
--------------enig722FF9439A70AC9C6B6E3D0D
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk4ZbRIACgkQhmBjz394Anm08ACfWB0vu2ZpS9SrjS5qkgHg IZRs
2nsAnjt099RAsfEklVQ6Bjx2SAdqsbti
=/WZ+
-----END PGP SIGNATURE-----
--------------enig722FF9439A70AC9C6B6E3D0D--
Re: Mysql Trigger
am 10.07.2011 11:53:56 von vishesh kumar
--20cf307abe6f87483704a7b40b9f
Content-Type: text/plain; charset=ISO-8859-1
Thanks for reply , but i want to do only for certain record that i will put
using IF
On Sun, Jul 10, 2011 at 2:42 PM, Reindl Harald wrote:
>
>
> Am 10.07.2011 10:32, schrieb vishesh kumar:
> > Hi Members
> >
> > Whats wrong i am doing in following create trigger statement
> >
> > Create trigger test before insert on user
> > for each row
> > begin
> > set New.host=upper(new.host)
> > end
> >
> > Above statement giving error check sql syntax , please guide me. I want
> to
> > put host field value in uppercase in user table
>
> a) why "before insert"
> b) why "for each row" when a single update can do this
> c) update table_name set fieldname=upper(fieldname)
>
>
--
http://linuxmantra.com
--20cf307abe6f87483704a7b40b9f--
Re: Mysql Trigger
am 10.07.2011 13:21:19 von Peter Brawley
On 7/10/2011 3:32 AM, vishesh kumar wrote:Hi Members
> Whats wrong i am doing in following create trigger statement
>
> Create trigger test before insert on user
> for each row
> begin
> set New.host=upper(new.host)
> end
>
> Above statement giving error check sql syntax , please guide me. I want to
> put host field value in uppercase in user table
One-liners don't need DELIMITERs, so you can write:
create trigger test before insert on user for each row set new.host=upper(new.host);
Multi-line Triggers need BEGIN...END so they need DELIMITERs too:
drop trigger if exists test;
delimiter go
create trigger test before insert on user for each row
begin
set new.c=upper(new.c);
set ...&c ...
end;
go
delimiter ;
A note on names: once you have too many tables & Triggers to remember,
you wish you'd adopted a naming convention that helps you remember
object names. A good convention for Trigger names is
TablenameWhenAction, so yours would be TestBeforeIns.
PB
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org