[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

how can i execute batch sql in one times?

hi,experts,
   i want do it:

  String sql="delete from TParameterMedicareChild where parid=6;";
  sql=sql+"delete from TParameterMedicare where parId=6;";
  execute(sql);

but this code is error,how can i do it?

i use mysql5.0.
0
hgbdelphi
Asked:
hgbdelphi
  • 2
1 Solution
 
hgbdelphiAuthor Commented:
i want this can be execute in one times!

Strin s="start TransAction;delete from TParameterMedicareChild where parid=?;delete from TParameterMedicare where parid=?;commit;"

mysql.execute(s)

but this will error!

how can i do it!

thanks!
0
 
virmaiorCommented:
http://dev.mysql.com/doc/mysql/en/delete.html

you can delete across multiple tables in one query.

delete TParameterMedicareChild, TParameterMedicare FROM TParameterMedicareChild, TParameterMedicare WHERE TParameterMedicare.parId = 6 AND TParameterMedicare.parId = TParameterMedicareChild.parId
0
 
ellandrdCommented:
i take it your using php or some scripting language??

try this if using php...

<?php

$host = "xxx.xxx.xxx.xx";
$user = "x";
$password = "x";
$database = "x";

mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

mysql_query("DELETE FROM TParameterMedicareChild WHERE parid = 6;")
mysql_query("DELETE FROM TParameterMedicare WHERE parid = 6;")

?>

Ellandrd ;-)
0
 
hgbdelphiAuthor Commented:
thank,now i use java batch code.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now