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

Jeff Fearn jefffearn at gmail.com
Fri Jan 7 21:19:58 EST 2005

w00t! It works!

On Fri, 07 Jan 2005 08:23:28 -0500, Ethan Rowe <ethan at endpoint.com> wrote:
> Jeff Fearn wrote:
> >Ok, after _much_ confusion on my part, I have finally figured out how
> >to get a ref to the DB ... or maybe just the table, either way I can
> >run select statements via $db->query.
> Your table is configured as read-only ($s->[$CONFIG]{Read_only}).  This
> is the thing to sort out next.
> I'm not sure how best to proceed... I think you need to use [tag] to set
> the particular table in write-mode.  Do it before any other access to
> that table occurs.  Within the usertag, you could probably do:
> $Tag->tag('flag', 'write' { table => 'orderline' });

The correct syntax is:
$Tag->flag( { type => 'write', table => 'orderline' });

> I haven't used the read/write flags much so don't be surprised if this
> doesn't solve the problem immediately... or if it's not even related.

It was spot on :)
> I believe this call to $Tag->perl is not necessary.  Have you tried
> taking it out?  I don't anticipate a fix to your problem, but it will
> increase the efficiency of your code.  Calling $Tag->perl adds a bunch
> of overhead, even if you aren't giving it any code to eval.

You were correct, I removed it with no side effects.

> A nice way to do it is, for a particular catalog:
>     - put catalog-specific usertags in <CATALOGROOT>/usertag with a
> '.tag' extension
>     - in <CATALOGROOT>/catalog.cfg, add the line: include usertag/*.tag

This is good, I will make this my standard way of doing local
usertags. Although I will leave this one as global.
> >Where are database_exists_ref and the like documented? I have searched
> >the website and RTFM site and have only found references in the change
> >logs.
> >
> I've never seen docs for these kinds of global utility functions; that
> doesn't mean they don't exist, but I'm skeptical.
> Basically, when you're writing global code, not wrapped in the confines
> of the Safe module, I find the best way to learn how to do stuff is just
> look at the Interchange core modules and see how it does stuff.  If you
> want to figure out how to access database objects, find an Interchange
> core tag that works with database objects (i.e. the data tag or export
> tag), find the routine it executes, and see how it's done there.

I have tried to do that, but I keep getting myself confused between
tag and perl syntax and the overlapping behaviour. It's a pretty steep
learning curve if you want to play with the guts of IC.

> That's probably not the most encouraging answer.  Anyway, that's what I
> do, for what it's worth.

The worst part is that the code is not comment either. Not even a
single line above a function to describe what it does :( If there was
such comments a few well placed pod commands would allow some basic
documentation to be generated [hint] [hint] ;)

/me notices he didn't comment his code either ;)

> >Thanks for you help and patience :)
> >
> >
> Good luck!

Thanks for the help guys, I'd never had got this working without you :)


P.S. I will see if I am allowed to distribute these EDI tags as they
may make a useful example for others to follow. Especially if I
comment them ;)

More information about the interchange-users mailing list