[ic] Accessing $Db or $Sql in Jobs?

Jeff Fearn jefffearn at gmail.com
Thu Jan 6 00:24:10 EST 2005


On Thu, 6 Jan 2005 15:23:16 +1000, Jeff Fearn <jefffearn at gmail.com> wrote:
> On Wed, 05 Jan 2005 18:22:32 -0800, John Young <john_young at sonic.net> wrote:
> > Ethan Rowe wrote:
> > > Jeff Fearn wrote:
> > >
> > >> Hi, how do you make $Db or $Sql accessable to usertags run using the
> > >> jobs functionality?
> > >>
> > >> I have a job which uses a new usertag, however $Db and $Sql are empty.
> > >>
> > >> I have used $Db and $Sql in another usertag; which is used in the
> > >> order routing; without a problem. I am assuming this is something to
> > >> do with this tag being used via the job queue ... this may be a very
> > >> bad assumption :}
> > >>
> > >> I have tried setting "AllowGlobal foundation" in interchange.cfg,
> > >> which I really don't want to do, with no effect.
> > >>
> > >> The job just contains:
> > >>
> > >> [x12_945]
> > >>
> > >> The tag code is:
> > >> UserTag x12_945 Routine <<EOR
> > >> sub
> > >> {
> > >>        # Make sure we have the EDI module installed
> > >>        eval
> > >>        {
> > >>                use X12::Base;
> > >>        };
> > >>
> > >>        if($@)
> > >>        {
> > >>                ::logError("Could not load X12::Base Module. X12-945
> > >> processing failed!\n");
> > >>                return(1);
> > >>        }
> > >>
> > >>        # Both of these always die
> > >>        my $dbh = $Sql{orderline} or die("No SQL orderline database!\n");
> > >>        my $ref = $Db{orderline} or die("No orderline database!\n");
> > >>
> > >>        .....
> > >> }
> > >>
> > >> TIA, Jeff.
> > >> __
> > >>
> > > Having not yet used IC jobs myself, I may be totally useless.  That said:
> > > Is the usertag defined for a single catalog, or as an Interchange global
> > > tag?
> > >
> > > The $Db and $Sql objects aren't available at the global level.  You can
> > > effectively access the $Db object for a particular table at the global
> > > level, however, via:
> > > my $dbh = database_exists_ref( $tablename );
> > > $dbh = $dbh->ref();
> > >
> > >  From there, $dbh gives you access to functions like query().
> > >
> > > I hope this is of some use.
> > >    - Ethan
> >
> >
> > The following link might help, as well, if you are not already familiar
> > with its content:
> >
> > http://www.icdevgroup.org/pipermail/interchange-users/2004-December/041551.html
> >
> >
> > -John Young
> 
> I had not seen that, thanks :)
> 
> I had thought from reading that link that all I had to do was add:
> 
> $Tag->perl({tables => 'orderline'});
> 
> above my existing code. However both attempts to get refs to orderline
> still die.
> 
> I have played around with what Ethan sent and I get " Can't call
> method "ref" on unblessed reference" errors :{

Method was actually "prepare" ... need more caffine.

> These jobs are making me thirsty :}
> 
> Jeff.
>


More information about the interchange-users mailing list