update & delete query !

can u tell me update & delete query that i can use to connect jdatastore...

i use this query statements...but i got error

for delete:

appendPStmt = conn.prepareStatement("DELETE FROM \"info\" WHERE \"info\".\"name=\""+name);

appendPStmt.executeUpdate();

for update:

appendPStmt = conn.prepareStatement( "UPDATE \"info\" SET \"info\".\"password=\""+npwd+" WHERE \"info\".\"name=\""+name);

appendPStmt.executeUpdate();

[469 byte] By [Ivya] at [2007-11-27 2:35:41]
# 1
Please don't doublepost and proceed here http://forum.java.sun.com/thread.jspa?threadID=5166138
BalusCa at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
sorry for my double post!coz my connection is not too good..when i post once...i see only white page...so i think it is not send...so....i post again.......sorry!thz for ur help !
Ivya at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

appendPStmt = conn.prepareStatement("DELETE FROM info WHERE info.name="+name);

appendPStmt = conn.prepareStatement( "UPDATE info SET info.password="+npwd+" WHERE info.name="+name);

plz, post the error message you got because we can't guess it !

java_2006a at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
Check the other thread ..
BalusCa at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

Try:

int result = 0;

String deleteSQL = "DELETE FROM info WHERE info.name= ?";

appendPStmt = conn.prepareStatement(deleteSQL);

appendPStmt.setString( 1, name );

result = appendPStmt.executeUpdate();

for update:

String updateSQL = "UPDATE info SET info.password= ? WHERE info.name= ?);

appendPStmt = conn.prepareStatement(updateSQL);

appendPStmt.setString( 1, npwd );

appendPStmt.setString( 2, name );

result = appendPStmt.executeUpdate();

abillconsla at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
In terms of the replies suggested above....please be aware that SQL (meaning most databases) support quoted identifiers. Thus the following is in fact valid SQL.select * from "mytable"Whether that is applicable or not in this thread depends on the database.
jschella at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
The one I am working on does not ... Oracle 9i
abillconsla at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8
> The one I am working on does not ... Oracle 9iDoes not what? Support quoted identifiers? Yes it does.
jschella at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9

If I run:

select count(*) from 'xtable'

Or if I substitute the double quotes for the single, I get table name does not exist.

Are you saying that the DB admin has control over the config of that - something I never see?

~Bill

correction ... it's "invalid tablename"

abillconsla at 2007-7-12 2:54:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

> If I run:

>

> select count(*) from 'xtable'

>

> Or if I substitute the double quotes for the single,

> I get table name does not exist.

>

The actual form is double quotes.

If you have a table name xtable in your database (presuming no quotes) then the following should actually return something.

select count(*) from "XTABLE"

> Are you saying that the DB admin has control

> over the config of that - something I never see?

Not sure what you mean, however I think SQL Server database setup can disallow the use of quoted identifiers. The default is to allow it. I don't believe Oracle allows for that. It could though.

Note again that this is part of ANSI SQL.

jschella at 2007-7-12 2:54:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 11
By the way, my position on the use of quoted identifiers is that they shouldn't be allowed in the first place. And if they are in use then they should be removed.I certainly never met an Oracle DBA that recommended nor would even tolerate their usage.
jschella at 2007-7-12 2:54:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 12

> > If I run:

> >

> > select count(*) from 'xtable'

> >

> > Or if I substitute the double quotes for the

> single,

> > I get table name does not exist.

> >

>

> The actual form is double quotes.

>

> If you have a table name xtable in your database

> (presuming no quotes) then the following should

> actually return something.

>

> select count(*) from "XTABLE"

NoGo ... I tried that and it does not matter (I can't retry anything now because I am no longer at work BTW) ... However, I tried wrapping it in single quotes (as I displayed), double quotes (as I said and as you displayed) and even three single quotes on each end. The result is always the same - 'Invalid tablename":

>

> > Are you saying that the DB admin has control

> > over the config of that - something I never see?

>

> Not sure what you mean, however I think SQL Server

> database setup can disallow the use of quoted

> identifiers. The default is to allow it. I don't

> believe Oracle allows for that. It could though.

>

What I meant is that, since I can't get the results from it that you mentioned above, I figured that perhaps there is some config the DBA can make to allow or disallow the use of what we're talking about - that's all

> Note again that this is part of ANSI SQL.

abillconsla at 2007-7-12 2:54:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 13
At any rate - OP - did you try what I posted in post #5?
abillconsla at 2007-7-12 2:54:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 14

> > The actual form is double quotes.

> >

> > If you have a table name xtable in your database

> > (presuming no quotes) then the following should

> > actually return something.

> >

> > select count(*) from "XTABLE"

>

> NoGo

Maybe there is a way to turn it off then.

Here is the documentation, search for the following for examples "Nonquoted identifiers are not case sensitive. "

http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/sql_elements9a.htm

jschella at 2007-7-12 2:54:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 15

> > > The actual form is double quotes.

> > >

> > > If you have a table name xtable in your database

> > > (presuming no quotes) then the following should

> > > actually return something.

> > >

> > > select count(*) from "XTABLE"

> >

> > NoGo

>

> Maybe there is a way to turn it off then.

>

> Here is the documentation, search for the following

> for examples "Nonquoted identifiers are not case

> sensitive. "

>

> http://download-west.oracle.com/docs/cd/B10501_01/serv

> er.920/a96540/sql_elements9a.htm

Thank you sir! I did not need to use the link - just those two magic words (case sensitive) in your last post was all it took to straighten me out.

I had not even thought to try that before, but as soon as I keyed in the DB table name in upper-case and then placed the double quotes around it, it recognized it. I admit that I should have considered that in light of the quotes, but it did not click until then.

Good thing to know - thank you.

~Bill

abillconsla at 2007-7-21 20:28:53 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 16

>

> I had not even thought to try that before, but as

> soon as I keyed in the DB table name in upper-case

> and then placed the double quotes around it, it

> recognized it. I admit that I should have considered

> that in light of the quotes, but it did not click

> until then.

>

It gave you that weird error message just because the case was different?

jschella at 2007-7-21 20:28:53 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 17
select count(*) from "tableX"Oracle O00942 - Table or view does not existselect count(*) from "TABLEX"Good to go!
abillconsla at 2007-7-21 20:28:53 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 18
> select count(*) from "tableX"> Oracle O00942 - Table or view does not existGood - I thought it should look like that.
jschella at 2007-7-21 20:28:53 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...