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

Jeff Fearn jefffearn at gmail.com
Wed Jan 5 22:15:57 EST 2005


On Wed, 05 Jan 2005 21:02:38 -0500, Ethan Rowe <ethan at endpoint.com> 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 tag is defined for a single catalog, appended to the require
UserTag line of catalog.cfg.

The tag file is in the  /usr/lib/interchange/code/UserTag/ directory.

> 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().

Cool, I will give this a try :)
 
> I hope this is of some use.
>     - Ethan

I'm sure it will be, thanks for the prompt reply :)

Jeff.


More information about the interchange-users mailing list