You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by go...@osmosis.gr on 2004/03/30 18:31:27 UTC

How can I get ID number after insert a new record?

i'm executing an Insert SQL statement using a custom xsp action

is it possible to get the new id number (auto increment) inside the action 
or inside the my pipeline's match?


any idea ?

--stavros


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How can I get ID number after insert a new record?

Posted by Yves Vindevogel <yv...@implements.be>.
Ach, short code ...
short answer then

select * from table1 where table1.Id in (select max(id) from table1)

Gives you the record with the highest ID
Including all the columns and even the ID you just inserted

On 30 Mar 2004, at 19:59, gounis@osmosis.gr wrote:

>
> i dont know but this code make cocoon give to answer
>     <esql:connection>
>         <esql:pool>hotpoints</esql:pool>
>         <esql:execute-query>
>             <esql:query>select max(id_Elements) from tblElements  
> </esql:query>
>             <esql:results>
>                 <elements>
>                     <esql:row-results>
>                         <element>
>                             <esql:get-columns/>
>                         </element>
>                     </esql:row-results>
>                 </elements>
>             </esql:results>
>         </esql:execute-query>
>     </esql:connection>
>
> On Tue, 30 Mar 2004, Yves Vindevogel wrote:
>
>> Why are you unable to make a  select max(myfield) from mytable query ?
>> I don't understand the problem.  Please explain.
>>
>> On 30 Mar 2004, at 19:26, gounis@osmosis.gr wrote:
>>
>>>
>>> yves
>>> thnx for your answer
>>>
>>>
>>> i'm using eslq to make queries and it was unable to run a select
>>> max(id)
>>> .. querie...
>>>
>>>
>>> is it possible to write java code to make my queries. if yes how can  
>>> i
>>> get
>>> access to connection pool configured in xconf?
>>>
>>>
>>> thnx
>>>
>>>
>>> --stavros
>>> On Tue, 30 Mar 2004, Yves Vindevogel wrote:
>>>
>>>> Not possible in one shot .... IMHO
>>>> You'll need to do the Insert and in the same page, run a second  
>>>> query
>>>> to get the Max(id).
>>>> If you're afraid of getting the wrong one (because somebody is doing
>>>> the same thing on the same table), use a where clause (like adding  
>>>> the
>>>> name of the company you just inserted)
>>>>
>>>> On 30 Mar 2004, at 19:08, gounis@osmosis.gr wrote:
>>>>
>>>>>
>>>>>
>>>>> oh sorry
>>>>>
>>>>> i use msAccess throgh ODBC
>>>>>
>>>>> -- stavro
>>>>>
>>>>> On Tue, 30 Mar 2004, Yves Vindevogel wrote:
>>>>>
>>>>>> What database ?
>>>>>>
>>>>>> I generally do this by using a function in postgresql.
>>>>>> You execute the function and in the function you get the new id.
>>>>>> That ID is returned as value (and 0 for failure)
>>>>>>
>>>>>> Same for MS Sql.  You can use a stored procedure there.
>>>>>> That's kind of the same as a postgresql function
>>>>>>
>>>>>>
>>>>>> On 30 Mar 2004, at 18:31, gounis@osmosis.gr wrote:
>>>>>>
>>>>>>> i'm executing an Insert SQL statement using a custom xsp action
>>>>>>>
>>>>>>> is it possible to get the new id number (auto increment) inside  
>>>>>>> the
>>>>>>> action
>>>>>>> or inside the my pipeline's match?
>>>>>>>
>>>>>>>
>>>>>>> any idea ?
>>>>>>>
>>>>>>> --stavros
>>>>>>>
>>>>>>>
>>>>>>> ----------------------------------------------------------------- 
>>>>>>> --
>>>>>>> --
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>>>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Met vriendelijke groeten,
>>>>>> Bien ~{&.!c~} vous,
>>>>>> Kind regards,
>>>>>>
>>>>>> Yves Vindevogel
>>>>>> Implements
>>>>>>
>>>>>> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
>>>>>>
>>>>>> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
>>>>>> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
>>>>>>
>>>>>> Web: http://www.implements.be
>>>>>>
>>>>>> First they ignore you.  Then they laugh at you.  Then they fight
>>>>>> you.
>>>>>> Then you win.
>>>>>> Mahatma Ghandi.
>>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------- 
>>>>> --
>>>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>>>
>>>>>
>>>>>
>>>> Met vriendelijke groeten,
>>>> Bien ~{&#~}  vous,
>>>> Kind regards,
>>>>
>>>> Yves Vindevogel
>>>> Implements
>>>>
>>>> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
>>>>
>>>> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
>>>> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
>>>>
>>>> Web: http://www.implements.be
>>>>
>>>> First they ignore you.  Then they laugh at you.  Then they fight  
>>>> you.
>>>> Then you win.
>>>> Mahatma Ghandi.
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>>
>> Met vriendelijke groeten,
>> Bien ~{($~} vous,
>> Kind regards,
>>
>> Yves Vindevogel
>> Implements
>>
>> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
>>
>> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
>> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
>>
>> Web: http://www.implements.be
>>
>> First they ignore you.  Then they laugh at you.  Then they fight you.
>> Then you win.
>> Mahatma Ghandi.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Met vriendelijke groeten,
Bien à vous,
Kind regards,

Yves Vindevogel
Implements

Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91

Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76

Web: http://www.implements.be

First they ignore you.  Then they laugh at you.  Then they fight you.   
Then you win.
Mahatma Ghandi.

Re: How can I get ID number after insert a new record?

Posted by go...@osmosis.gr.
i dont know but this code make cocoon give to answer
    <esql:connection>
        <esql:pool>hotpoints</esql:pool>
        <esql:execute-query>
            <esql:query>select max(id_Elements) from tblElements </esql:query>
            <esql:results>
                <elements>
                    <esql:row-results>
                        <element>
                            <esql:get-columns/>
                        </element>
                    </esql:row-results>
                </elements>
            </esql:results>
        </esql:execute-query>
    </esql:connection>

On Tue, 30 Mar 2004, Yves Vindevogel wrote:

> Why are you unable to make a  select max(myfield) from mytable query ?
> I don't understand the problem.  Please explain.
> 
> On 30 Mar 2004, at 19:26, gounis@osmosis.gr wrote:
> 
> >
> > yves
> > thnx for your answer
> >
> >
> > i'm using eslq to make queries and it was unable to run a select  
> > max(id)
> > .. querie...
> >
> >
> > is it possible to write java code to make my queries. if yes how can i  
> > get
> > access to connection pool configured in xconf?
> >
> >
> > thnx
> >
> >
> > --stavros
> > On Tue, 30 Mar 2004, Yves Vindevogel wrote:
> >
> >> Not possible in one shot .... IMHO
> >> You'll need to do the Insert and in the same page, run a second query
> >> to get the Max(id).
> >> If you're afraid of getting the wrong one (because somebody is doing
> >> the same thing on the same table), use a where clause (like adding the
> >> name of the company you just inserted)
> >>
> >> On 30 Mar 2004, at 19:08, gounis@osmosis.gr wrote:
> >>
> >>>
> >>>
> >>> oh sorry
> >>>
> >>> i use msAccess throgh ODBC
> >>>
> >>> -- stavro
> >>>
> >>> On Tue, 30 Mar 2004, Yves Vindevogel wrote:
> >>>
> >>>> What database ?
> >>>>
> >>>> I generally do this by using a function in postgresql.
> >>>> You execute the function and in the function you get the new id.
> >>>> That ID is returned as value (and 0 for failure)
> >>>>
> >>>> Same for MS Sql.  You can use a stored procedure there.
> >>>> That's kind of the same as a postgresql function
> >>>>
> >>>>
> >>>> On 30 Mar 2004, at 18:31, gounis@osmosis.gr wrote:
> >>>>
> >>>>> i'm executing an Insert SQL statement using a custom xsp action
> >>>>>
> >>>>> is it possible to get the new id number (auto increment) inside the
> >>>>> action
> >>>>> or inside the my pipeline's match?
> >>>>>
> >>>>>
> >>>>> any idea ?
> >>>>>
> >>>>> --stavros
> >>>>>
> >>>>>
> >>>>> ------------------------------------------------------------------- 
> >>>>> --
> >>>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >>>>> For additional commands, e-mail: users-help@cocoon.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>> Met vriendelijke groeten,
> >>>> Bien ~{&.!c~} vous,
> >>>> Kind regards,
> >>>>
> >>>> Yves Vindevogel
> >>>> Implements
> >>>>
> >>>> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
> >>>>
> >>>> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
> >>>> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
> >>>>
> >>>> Web: http://www.implements.be
> >>>>
> >>>> First they ignore you.  Then they laugh at you.  Then they fight  
> >>>> you.
> >>>> Then you win.
> >>>> Mahatma Ghandi.
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >>> For additional commands, e-mail: users-help@cocoon.apache.org
> >>>
> >>>
> >>>
> >> Met vriendelijke groeten,
> >> Bien ~{&#~}  vous,
> >> Kind regards,
> >>
> >> Yves Vindevogel
> >> Implements
> >>
> >> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
> >>
> >> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
> >> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
> >>
> >> Web: http://www.implements.be
> >>
> >> First they ignore you.  Then they laugh at you.  Then they fight you.
> >> Then you win.
> >> Mahatma Ghandi.
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> >
> Met vriendelijke groeten,
> Bien ~{($~} vous,
> Kind regards,
> 
> Yves Vindevogel
> Implements
> 
> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
> 
> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
> 
> Web: http://www.implements.be
> 
> First they ignore you.  Then they laugh at you.  Then they fight you.   
> Then you win.
> Mahatma Ghandi.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How can I get ID number after insert a new record?

Posted by Yves Vindevogel <yv...@implements.be>.
Why are you unable to make a  select max(myfield) from mytable query ?
I don't understand the problem.  Please explain.

On 30 Mar 2004, at 19:26, gounis@osmosis.gr wrote:

>
> yves
> thnx for your answer
>
>
> i'm using eslq to make queries and it was unable to run a select  
> max(id)
> .. querie...
>
>
> is it possible to write java code to make my queries. if yes how can i  
> get
> access to connection pool configured in xconf?
>
>
> thnx
>
>
> --stavros
> On Tue, 30 Mar 2004, Yves Vindevogel wrote:
>
>> Not possible in one shot .... IMHO
>> You'll need to do the Insert and in the same page, run a second query
>> to get the Max(id).
>> If you're afraid of getting the wrong one (because somebody is doing
>> the same thing on the same table), use a where clause (like adding the
>> name of the company you just inserted)
>>
>> On 30 Mar 2004, at 19:08, gounis@osmosis.gr wrote:
>>
>>>
>>>
>>> oh sorry
>>>
>>> i use msAccess throgh ODBC
>>>
>>> -- stavro
>>>
>>> On Tue, 30 Mar 2004, Yves Vindevogel wrote:
>>>
>>>> What database ?
>>>>
>>>> I generally do this by using a function in postgresql.
>>>> You execute the function and in the function you get the new id.
>>>> That ID is returned as value (and 0 for failure)
>>>>
>>>> Same for MS Sql.  You can use a stored procedure there.
>>>> That's kind of the same as a postgresql function
>>>>
>>>>
>>>> On 30 Mar 2004, at 18:31, gounis@osmosis.gr wrote:
>>>>
>>>>> i'm executing an Insert SQL statement using a custom xsp action
>>>>>
>>>>> is it possible to get the new id number (auto increment) inside the
>>>>> action
>>>>> or inside the my pipeline's match?
>>>>>
>>>>>
>>>>> any idea ?
>>>>>
>>>>> --stavros
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------- 
>>>>> --
>>>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>>>
>>>>>
>>>>>
>>>> Met vriendelijke groeten,
>>>> Bien Ξ° vous,
>>>> Kind regards,
>>>>
>>>> Yves Vindevogel
>>>> Implements
>>>>
>>>> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
>>>>
>>>> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
>>>> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
>>>>
>>>> Web: http://www.implements.be
>>>>
>>>> First they ignore you.  Then they laugh at you.  Then they fight  
>>>> you.
>>>> Then you win.
>>>> Mahatma Ghandi.
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>>
>> Met vriendelijke groeten,
>> Bien Γ  vous,
>> Kind regards,
>>
>> Yves Vindevogel
>> Implements
>>
>> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
>>
>> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
>> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
>>
>> Web: http://www.implements.be
>>
>> First they ignore you.  Then they laugh at you.  Then they fight you.
>> Then you win.
>> Mahatma Ghandi.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Met vriendelijke groeten,
Bien à vous,
Kind regards,

Yves Vindevogel
Implements

Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91

Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76

Web: http://www.implements.be

First they ignore you.  Then they laugh at you.  Then they fight you.   
Then you win.
Mahatma Ghandi.

Re: How can I get ID number after insert a new record?

Posted by go...@osmosis.gr.
yves 
thnx for your answer


i'm using eslq to make queries and it was unable to run a select max(id) 
.. querie...


is it possible to write java code to make my queries. if yes how can i get 
access to connection pool configured in xconf?


thnx


--stavros
On Tue, 30 Mar 2004, Yves Vindevogel wrote:

> Not possible in one shot .... IMHO
> You'll need to do the Insert and in the same page, run a second query 
> to get the Max(id).
> If you're afraid of getting the wrong one (because somebody is doing 
> the same thing on the same table), use a where clause (like adding the 
> name of the company you just inserted)
> 
> On 30 Mar 2004, at 19:08, gounis@osmosis.gr wrote:
> 
> >
> >
> > oh sorry
> >
> > i use msAccess throgh ODBC
> >
> > -- stavro
> >
> > On Tue, 30 Mar 2004, Yves Vindevogel wrote:
> >
> >> What database ?
> >>
> >> I generally do this by using a function in postgresql.
> >> You execute the function and in the function you get the new id.
> >> That ID is returned as value (and 0 for failure)
> >>
> >> Same for MS Sql.  You can use a stored procedure there.
> >> That's kind of the same as a postgresql function
> >>
> >>
> >> On 30 Mar 2004, at 18:31, gounis@osmosis.gr wrote:
> >>
> >>> i'm executing an Insert SQL statement using a custom xsp action
> >>>
> >>> is it possible to get the new id number (auto increment) inside the
> >>> action
> >>> or inside the my pipeline's match?
> >>>
> >>>
> >>> any idea ?
> >>>
> >>> --stavros
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >>> For additional commands, e-mail: users-help@cocoon.apache.org
> >>>
> >>>
> >>>
> >> Met vriendelijke groeten,
> >> Bien Ξ° vous,
> >> Kind regards,
> >>
> >> Yves Vindevogel
> >> Implements
> >>
> >> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
> >>
> >> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
> >> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
> >>
> >> Web: http://www.implements.be
> >>
> >> First they ignore you.  Then they laugh at you.  Then they fight you.
> >> Then you win.
> >> Mahatma Ghandi.
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> >
> Met vriendelijke groeten,
> Bien Γ  vous,
> Kind regards,
> 
> Yves Vindevogel
> Implements
> 
> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
> 
> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
> 
> Web: http://www.implements.be
> 
> First they ignore you.  Then they laugh at you.  Then they fight you.  
> Then you win.
> Mahatma Ghandi.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How can I get ID number after insert a new record?

Posted by Yves Vindevogel <yv...@implements.be>.
Not possible in one shot .... IMHO
You'll need to do the Insert and in the same page, run a second query 
to get the Max(id).
If you're afraid of getting the wrong one (because somebody is doing 
the same thing on the same table), use a where clause (like adding the 
name of the company you just inserted)

On 30 Mar 2004, at 19:08, gounis@osmosis.gr wrote:

>
>
> oh sorry
>
> i use msAccess throgh ODBC
>
> -- stavro
>
> On Tue, 30 Mar 2004, Yves Vindevogel wrote:
>
>> What database ?
>>
>> I generally do this by using a function in postgresql.
>> You execute the function and in the function you get the new id.
>> That ID is returned as value (and 0 for failure)
>>
>> Same for MS Sql.  You can use a stored procedure there.
>> That's kind of the same as a postgresql function
>>
>>
>> On 30 Mar 2004, at 18:31, gounis@osmosis.gr wrote:
>>
>>> i'm executing an Insert SQL statement using a custom xsp action
>>>
>>> is it possible to get the new id number (auto increment) inside the
>>> action
>>> or inside the my pipeline's match?
>>>
>>>
>>> any idea ?
>>>
>>> --stavros
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>>
>> Met vriendelijke groeten,
>> Bien ΰ vous,
>> Kind regards,
>>
>> Yves Vindevogel
>> Implements
>>
>> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
>>
>> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
>> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
>>
>> Web: http://www.implements.be
>>
>> First they ignore you.  Then they laugh at you.  Then they fight you.
>> Then you win.
>> Mahatma Ghandi.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Met vriendelijke groeten,
Bien à vous,
Kind regards,

Yves Vindevogel
Implements

Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91

Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76

Web: http://www.implements.be

First they ignore you.  Then they laugh at you.  Then they fight you.  
Then you win.
Mahatma Ghandi.

Re: How can I get ID number after insert a new record?

Posted by go...@osmosis.gr.

oh sorry

i use msAccess throgh ODBC

-- stavro

On Tue, 30 Mar 2004, Yves Vindevogel wrote:

> What database ?
> 
> I generally do this by using a function in postgresql.
> You execute the function and in the function you get the new id.
> That ID is returned as value (and 0 for failure)
> 
> Same for MS Sql.  You can use a stored procedure there.
> That's kind of the same as a postgresql function
> 
> 
> On 30 Mar 2004, at 18:31, gounis@osmosis.gr wrote:
> 
> > i'm executing an Insert SQL statement using a custom xsp action
> >
> > is it possible to get the new id number (auto increment) inside the 
> > action
> > or inside the my pipeline's match?
> >
> >
> > any idea ?
> >
> > --stavros
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> >
> Met vriendelijke groeten,
> Bien ΰ vous,
> Kind regards,
> 
> Yves Vindevogel
> Implements
> 
> Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91
> 
> Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
> Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76
> 
> Web: http://www.implements.be
> 
> First they ignore you.  Then they laugh at you.  Then they fight you.  
> Then you win.
> Mahatma Ghandi.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How can I get ID number after insert a new record?

Posted by Yves Vindevogel <yv...@implements.be>.
What database ?

I generally do this by using a function in postgresql.
You execute the function and in the function you get the new id.
That ID is returned as value (and 0 for failure)

Same for MS Sql.  You can use a stored procedure there.
That's kind of the same as a postgresql function


On 30 Mar 2004, at 18:31, gounis@osmosis.gr wrote:

> i'm executing an Insert SQL statement using a custom xsp action
>
> is it possible to get the new id number (auto increment) inside the 
> action
> or inside the my pipeline's match?
>
>
> any idea ?
>
> --stavros
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Met vriendelijke groeten,
Bien à vous,
Kind regards,

Yves Vindevogel
Implements

Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91

Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76

Web: http://www.implements.be

First they ignore you.  Then they laugh at you.  Then they fight you.  
Then you win.
Mahatma Ghandi.

Re: How can I get ID number after insert a new record?

Posted by Yves Vindevogel <yv...@implements.be>.
I agree with Brian, but it M$ Access.  No decent thing there like a 
sequence.
You have to use autonumbers


On 30 Mar 2004, at 22:29, Brian McCallister wrote:

> Don't use auto-increment in an insert where you care about having the 
> identity of the inserted value. A better solution, most of the time, 
> is to use a named sequence and select values off of it, then populate 
> the id field yourself:
>
> In postgresql:
>
> select nextval('MySequence'), nextval('MySequence'), 
> nextval('MySequence'), nextval('MySequence'), nextval('MySequence');
>
> Will give you the next five values from MySequence. Use these for your 
> next five inserts. Most of the time when you set a field to 
> autoincrement, or set a default value, or whatever the database you 
> are using calls it, if you populate that value it doesn't use the 
> default. This allows you to use the default value for batch inserts 
> where you don't care about the ids, and lets you specify the id where 
> you do.
>
> -Brian
>
> On Mar 30, 2004, at 11:31 AM, gounis@osmosis.gr wrote:
>
>> i'm executing an Insert SQL statement using a custom xsp action
>>
>> is it possible to get the new id number (auto increment) inside the 
>> action
>> or inside the my pipeline's match?
>>
>>
>> any idea ?
>>
>> --stavros
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Met vriendelijke groeten,
Bien à vous,
Kind regards,

Yves Vindevogel
Implements

Mail: yves.vindevogel@implements.be  - Mobile: +32 (478) 80 82 91

Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
Markt 18c  -  9700 Oudenaarde  -  Tel: +32 (55) 30 55 76

Web: http://www.implements.be

First they ignore you.  Then they laugh at you.  Then they fight you.  
Then you win.
Mahatma Ghandi.

Re: How can I get ID number after insert a new record?

Posted by Brian McCallister <br...@apache.org>.
Don't use auto-increment in an insert where you care about having the 
identity of the inserted value. A better solution, most of the time, is 
to use a named sequence and select values off of it, then populate the 
id field yourself:

In postgresql:

select nextval('MySequence'), nextval('MySequence'), 
nextval('MySequence'), nextval('MySequence'), nextval('MySequence');

Will give you the next five values from MySequence. Use these for your 
next five inserts. Most of the time when you set a field to 
autoincrement, or set a default value, or whatever the database you are 
using calls it, if you populate that value it doesn't use the default. 
This allows you to use the default value for batch inserts where you 
don't care about the ids, and lets you specify the id where you do.

-Brian

On Mar 30, 2004, at 11:31 AM, gounis@osmosis.gr wrote:

> i'm executing an Insert SQL statement using a custom xsp action
>
> is it possible to get the new id number (auto increment) inside the 
> action
> or inside the my pipeline's match?
>
>
> any idea ?
>
> --stavros
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org