pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
jdbc question
7+ messages / 6 participants
[nested] [flat]

* jdbc question
@ 2000-01-05 15:39 Phillip Rhodes <rhodespc@bellatlantic.net>
  0 siblings, 0 replies; 7+ messages in thread

From: Phillip Rhodes @ 2000-01-05 15:39 UTC (permalink / raw)
  To: pgsql-interfaces

All,
I have a table with a column type of serial.
If I do an insert into this table, is there a way to find out this column's value?

Thanks!
PHillip



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: [INTERFACES] jdbc question
@ 2000-02-07 09:25 Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Peter Mount @ 2000-02-07 09:25 UTC (permalink / raw)
  To: 'Phillip Rhodes' <rhodespc@bellatlantic.net>; pgsql-interfaces

When you do a SERIAL, it actually creates a Sequence which you can then
get the current value using: select currval('sequence name');

Peter

-- 
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.



-----Original Message-----
From: Phillip Rhodes [mailto:rhodespc@bellatlantic.net]
Sent: Wednesday, January 05, 2000 3:40 PM
To: 'pgsql-interfaces@postgreSQL.org'
Subject: [INTERFACES] jdbc question


All,
I have a table with a column type of serial.
If I do an insert into this table, is there a way to find out this
column's value?

Thanks!
PHillip

************



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* jdbc question
@ 2000-02-09 15:50 Phillip Rhodes <rhodespc@bellatlantic.net>
  2000-02-09 21:34 ` Re: [INTERFACES] jdbc question Lars <lars@sscsinc.com>
  2000-02-09 23:17 ` Re: [INTERFACES] jdbc question Ken J. Wright <ken@ori-ind.com>
  2000-02-10 18:52 ` Re: [INTERFACES] jdbc question Joe Shevland <shevlandj@kpi.com.au>
  0 siblings, 3 replies; 7+ messages in thread

From: Phillip Rhodes @ 2000-02-09 15:50 UTC (permalink / raw)
  To: pgsql-interfaces

If I submit a query joining two tables with identical column names, how can 
I differentiate the different columns and get the correct values?

table test1
(col1 INTEGER,
col2 INTEGER)

table test2
(col1 INTEGER,
col2 INTEGER)


select * from test1, test2
where test1.col1 = test2.col1

The call
rs.getInt("col1") returns successfully with a value, but there are 2 col1 
columns in the resultset.

Thanks,
Phillip




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [INTERFACES] jdbc question
  2000-02-09 15:50 jdbc question Phillip Rhodes <rhodespc@bellatlantic.net>
@ 2000-02-09 21:34 ` Lars <lars@sscsinc.com>
  2 siblings, 0 replies; 7+ messages in thread

From: Lars @ 2000-02-09 21:34 UTC (permalink / raw)
  To: Phillip Rhodes <rhodespc@bellatlantic.net>; +Cc: pgsql-interfaces

Phillip,
I believe that you can just refer to the as column number, or cast them to
another name, ie;
SELECT (test1.column1 AS columnA, test2.column1)
FROM test1, test2;

-Lars

On Wed, 9 Feb 2000, Phillip Rhodes wrote:

> If I submit a query joining two tables with identical column names, how can 
> I differentiate the different columns and get the correct values?
> 
> table test1
> (col1 INTEGER,
> col2 INTEGER)
> 
> table test2
> (col1 INTEGER,
> col2 INTEGER)
> 
> 
> select * from test1, test2
> where test1.col1 = test2.col1
> 
> The call
> rs.getInt("col1") returns successfully with a value, but there are 2 col1 
> columns in the resultset.
> 
> Thanks,
> Phillip
> 
> 
> ************
> 
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [INTERFACES] jdbc question
  2000-02-09 15:50 jdbc question Phillip Rhodes <rhodespc@bellatlantic.net>
@ 2000-02-09 23:17 ` Ken J. Wright <ken@ori-ind.com>
  2 siblings, 0 replies; 7+ messages in thread

From: Ken J. Wright @ 2000-02-09 23:17 UTC (permalink / raw)
  To: Phillip Rhodes <rhodespc@bellatlantic.net>; pgsql-interfaces

At 15:50 02/09/2000 -0000, Phillip Rhodes wrote:
>If I submit a query joining two tables with identical column names, how can 
>I differentiate the different columns and get the correct values?
>
>table test1
>(col1 INTEGER,
>col2 INTEGER)
>
>table test2
>(col1 INTEGER,
>col2 INTEGER)
>
>
>select * from test1, test2
>where test1.col1 = test2.col1

select a.*, b.col1 as col3, b.col2 as col4 from test1 a, test2 b
where a.col1 = b.col1

>The call
>rs.getInt("col1") returns successfully with a value, but there are 2 col1 
>columns in the resultset.
>
>Thanks,
>Phillip
>
>
>************
>



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [INTERFACES] jdbc question
  2000-02-09 15:50 jdbc question Phillip Rhodes <rhodespc@bellatlantic.net>
@ 2000-02-10 18:52 ` Joe Shevland <shevlandj@kpi.com.au>
  2 siblings, 0 replies; 7+ messages in thread

From: Joe Shevland @ 2000-02-10 18:52 UTC (permalink / raw)
  To: Phillip Rhodes <rhodespc@bellatlantic.net>; pgsql-interfaces

You could try:

---
SELECT test1.col1 AS t1c1, test2.col1 AS t2c1 FROM test1, test2 WHERE test1.col1 = test2.col1
---

The 'AS' being the important bit there as it will alias the parameters. I am
not sure whether rs.getInt("test1.col1") would work and I cannot test this
quickly where I am... anyone else?


Cheers,
Joe

----- Original Message ----- 
From: "Phillip Rhodes" <rhodespc@bellatlantic.net>
To: <pgsql-interfaces@postgreSQL.org>
Sent: Wednesday, February 09, 2000 7:50 AM
Subject: [INTERFACES] jdbc question


> If I submit a query joining two tables with identical column names, how can 
> I differentiate the different columns and get the correct values?
> 
> table test1
> (col1 INTEGER,
> col2 INTEGER)
> 
> table test2
> (col1 INTEGER,
> col2 INTEGER)
> 
> 
> select * from test1, test2
> where test1.col1 = test2.col1
> 
> The call
> rs.getInt("col1") returns successfully with a value, but there are 2 col1 
> columns in the resultset.
> 
> Thanks,
> Phillip
> 
> 
> ************
> 
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: [INTERFACES] jdbc question
@ 2000-02-09 18:38 Phillip Rhodes <phillip@rhoderunner.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Phillip Rhodes @ 2000-02-09 18:38 UTC (permalink / raw)
  To: pgsql-interfaces

Is there a way to resolve this without aliases?  I would like to use some 
objects that would handle the resultset of a particular table,  and if some 
queries refer to cola as colx, there would be no way to re-use the code.

For example

select * from test1, test2

//call method to get test1
test1ResultsetHandler(resultset)

//call method to get test1
test2ResultsetHandler(resultset)



----------
From: 	Ken J. Wright[SMTP:ken@ori-ind.com]
Sent: 	Wednesday, February 09, 2000 6:17 PM
To: 	Phillip Rhodes; 'pgsql-interfaces@postgreSQL.org'
Subject: 	Re: [INTERFACES] jdbc question

At 15:50 02/09/2000 -0000, Phillip Rhodes wrote:
>If I submit a query joining two tables with identical column names, how 
can
>I differentiate the different columns and get the correct values?
>
>table test1
>(col1 INTEGER,
>col2 INTEGER)
>
>table test2
>(col1 INTEGER,
>col2 INTEGER)
>
>
>select * from test1, test2
>where test1.col1 = test2.col1

select a.*, b.col1 as col3, b.col2 as col4 from test1 a, test2 b
where a.col1 = b.col1

>The call
>rs.getInt("col1") returns successfully with a value, but there are 2 col1
>columns in the resultset.
>
>Thanks,
>Phillip
>
>
>************
>





^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2000-02-10 18:52 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-01-05 15:39 jdbc question Phillip Rhodes <rhodespc@bellatlantic.net>
2000-02-07 09:25 RE: [INTERFACES] jdbc question Peter Mount <petermount@it.maidstone.gov.uk>
2000-02-09 15:50 jdbc question Phillip Rhodes <rhodespc@bellatlantic.net>
2000-02-09 21:34 ` Lars <lars@sscsinc.com>
2000-02-09 23:17 ` Ken J. Wright <ken@ori-ind.com>
2000-02-10 18:52 ` Joe Shevland <shevlandj@kpi.com.au>
2000-02-09 18:38 RE: [INTERFACES] jdbc question Phillip Rhodes <phillip@rhoderunner.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox