1

I have a table which contains say X rows and 10 columns. User has an option to edit any of the rows and columns and also he can add new rows and add details to it. He has a single button 'Save' and check box upon every row. He can select the rows which he has edited and inserted using the check box and save it using the Save button.

Now my question is, consider the user has edited X-1 rows and inserted some 3 rows. and has selected only the edited and inserted rows. How can i insert and update at the same time when he clicks the 'Save' button.

P.S: I am using Java Script and SQLj.

Sadique
  • 11
  • 1
  • 3
  • If this question has anything to do with Java, can you say what it is. Otherwise you can remove the `java` tag. ;) – Peter Lawrey Aug 30 '11 at 08:52
  • 1
    I am using a session to pass all these multiple values to my SQLJ file and run the query through that. – Sadique Aug 30 '11 at 08:56
  • He means that java has nothing to do with javascript or SQLJ. Actually, java and javascript is very different. This question has a tag "java" which can cause a lot confusion. – Tim S. Sep 27 '11 at 12:57
  • How can you use SQLj from JavaScript? SQLj is to do a Java precompilation for DB2 or Oracle databases. How did you you that with Java Script? – AngocA Sep 02 '13 at 14:15

1 Answers1

0

A SQL query can have multiple queries usually divided by a semicolon (;).

INSERT INTO table_name VALUES (value1, valu2, value3); UPDATE table_name SET column1=value, column2=value2 WHERE some_column=some_value

This is in fact the answer to your question, assuming that you know how to get all edited fields from your table, and make a bunch of queries from that.

Tim S.
  • 13,597
  • 7
  • 46
  • 72