dbTalk Databases Forums  

how to get agent id

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss how to get agent id in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
crazy_jutt
 
Posts: n/a

Default how to get agent id - 07-18-2006 , 10:54 AM






hello,

How can i retreive agent id in return when i connect to database and
run some sql?

can i do something like

db2 connect to database1
agent_id = db2 "select * from abc"


Reply With Quote
  #2  
Old   
Knut Stolze
 
Posts: n/a

Default Re: how to get agent id - 07-18-2006 , 11:03 AM






crazy_jutt wrote:

Quote:
hello,

How can i retreive agent id in return when i connect to database and
run some sql?

can i do something like

db2 connect to database1
agent_id = db2 "select * from abc"
You could write a not fenced UDF that invokes the C function "getpid" and
return its result. Depending on your platform, you may need the thread-id
as well.

But the real question is: what do you want to do with this number?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


Reply With Quote
  #3  
Old   
db2admin
 
Posts: n/a

Default Re: how to get agent id - 07-18-2006 , 11:30 AM



I am doing load pipe using unix pipes
sometime load fails and export still keep on pushing data into pipe
i want to kill that export when load fails and vise versa

Knut Stolze wrote:
Quote:
crazy_jutt wrote:

hello,

How can i retreive agent id in return when i connect to database and
run some sql?

can i do something like

db2 connect to database1
agent_id = db2 "select * from abc"

You could write a not fenced UDF that invokes the C function "getpid" and
return its result. Depending on your platform, you may need the thread-id
as well.

But the real question is: what do you want to do with this number?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


Reply With Quote
  #4  
Old   
jefftyzzer
 
Posts: n/a

Default Re: how to get agent id - 07-18-2006 , 02:57 PM



How about something like:

SELECT
APPL.AGENT_ID
FROM
TABLE (SNAPSHOT_APPL_INFO('<YOUR DB NAME>',-1)) AS APPL
WHERE
APPL.APPL_ID = (VALUES APPLICATION_ID());

and by extension

BEGIN ATOMIC
DECLARE AGNT BIGINT;--
SET AGNT =
(SELECT
APPL.AGENT_ID
FROM
TABLE (SNAPSHOT_APPL_INFO('CSE1DV00',-1)) AS APPL
WHERE
APPL.APPL_ID = (VALUES APPLICATION_ID()));--
END;

HTH,

--Jeff

crazy_jutt wrote:
Quote:
hello,

How can i retreive agent id in return when i connect to database and
run some sql?

can i do something like

db2 connect to database1
agent_id = db2 "select * from abc"


Reply With Quote
  #5  
Old   
crazy_jutt
 
Posts: n/a

Default Re: how to get agent id - 07-18-2006 , 04:10 PM



how can i use this in dynamic SQL ?

jefftyzzer wrote:
Quote:
How about something like:

SELECT
APPL.AGENT_ID
FROM
TABLE (SNAPSHOT_APPL_INFO('<YOUR DB NAME>',-1)) AS APPL
WHERE
APPL.APPL_ID = (VALUES APPLICATION_ID());

and by extension

BEGIN ATOMIC
DECLARE AGNT BIGINT;--
SET AGNT =
(SELECT
APPL.AGENT_ID
FROM
TABLE (SNAPSHOT_APPL_INFO('CSE1DV00',-1)) AS APPL
WHERE
APPL.APPL_ID = (VALUES APPLICATION_ID()));--
END;

HTH,

--Jeff

crazy_jutt wrote:
hello,

How can i retreive agent id in return when i connect to database and
run some sql?

can i do something like

db2 connect to database1
agent_id = db2 "select * from abc"


Reply With Quote
  #6  
Old   
Serge Rielau
 
Posts: n/a

Default Re: how to get agent id - 07-18-2006 , 08:13 PM



jefftyzzer wrote:
Quote:
APPL.APPL_ID = (VALUES APPLICATION_ID()));--
What speaks against
APPL.APPL_ID = APPLICATION_ID() ??

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/


Reply With Quote
  #7  
Old   
jefftyzzer
 
Posts: n/a

Default Re: how to get agent id - 07-18-2006 , 08:53 PM



Doh! Nothing speaks against it--I just like to waste keystrokes :-).
Good catch.

-- Jeff

Serge Rielau wrote:
Quote:
jefftyzzer wrote:
APPL.APPL_ID = (VALUES APPLICATION_ID()));--
What speaks against
APPL.APPL_ID = APPLICATION_ID() ??

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/


Reply With Quote
  #8  
Old   
crazy_jutt
 
Posts: n/a

Default Re: how to get agent id - 07-19-2006 , 09:56 AM



thanks guys
i got it

here it what i did

db2 -x "SELECT APPL.AGENT_ID FROM TABLE(SNAPSHOT_APPL_INFO('PROD1',-2))
AS APPL WHERE APPL.APPL_ID = (VALUES APPLICATION_ID())" | read agent_id
echo ${agent_id}




jefftyzzer wrote:
Quote:
Doh! Nothing speaks against it--I just like to waste keystrokes :-).
Good catch.

-- Jeff

Serge Rielau wrote:
jefftyzzer wrote:
APPL.APPL_ID = (VALUES APPLICATION_ID()));--
What speaks against
APPL.APPL_ID = APPLICATION_ID() ??

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/


Reply With Quote
  #9  
Old   
crazy_jutt
 
Posts: n/a

Default Re: how to get agent id - 07-19-2006 , 10:09 AM



are there more functions like this
i know there must not be function like AGENT_ID() otherwise you guys
must have mentioned but i am curious if there are more functions like
this which could be useful





crazy_jutt wrote:
Quote:
thanks guys
i got it

here it what i did

db2 -x "SELECT APPL.AGENT_ID FROM TABLE(SNAPSHOT_APPL_INFO('PROD1',-2))
AS APPL WHERE APPL.APPL_ID = (VALUES APPLICATION_ID())" | read agent_id
echo ${agent_id}




jefftyzzer wrote:
Doh! Nothing speaks against it--I just like to waste keystrokes :-).
Good catch.

-- Jeff

Serge Rielau wrote:
jefftyzzer wrote:
APPL.APPL_ID = (VALUES APPLICATION_ID()));--
What speaks against
APPL.APPL_ID = APPLICATION_ID() ??

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/


Reply With Quote
  #10  
Old   
jefftyzzer
 
Posts: n/a

Default Re: how to get agent id - 07-19-2006 , 01:35 PM



First thing: as Serge pointed out, you don't need "= VALUES(...", just
call the function directly as he illustrated--my mistake. As to your
question, I wouldn't say there are many functions like that, but there
is a lot of information available in snapshot table functions like
SNAPSHOT_APPL and SNAPSHOT_APPL_INFO.

--Jeff

crazy_jutt wrote:
Quote:
are there more functions like this
i know there must not be function like AGENT_ID() otherwise you guys
must have mentioned but i am curious if there are more functions like
this which could be useful





crazy_jutt wrote:
thanks guys
i got it

here it what i did

db2 -x "SELECT APPL.AGENT_ID FROM TABLE(SNAPSHOT_APPL_INFO('PROD1',-2))
AS APPL WHERE APPL.APPL_ID = (VALUES APPLICATION_ID())" | read agent_id
echo ${agent_id}




jefftyzzer wrote:
Doh! Nothing speaks against it--I just like to waste keystrokes :-).
Good catch.

-- Jeff

Serge Rielau wrote:
jefftyzzer wrote:
APPL.APPL_ID = (VALUES APPLICATION_ID()));--
What speaks against
APPL.APPL_ID = APPLICATION_ID() ??

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.