[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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

--
Ethan Rowe
End Point Corporation
suppressed

_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.