Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Feature request
Mon, Feb 6 2012 7:21 AMPermanent Link

Lucian

Hi Tim,

Many times I need a handfull of stored procs in many databases if not all of them. And so I have to add the very same function or proc to every database and if there's a bug I have to fix it tons of times.

Not sure how to define this but visually, in ElevateDB Manager, I could see another node under a session, between "Databases" and "Stores", called "Library" having two child nodes: "Procedures" and "Functions" .... where I one can drop some stuff which would be available in all databases.
I hope this makes sense

Regards,
Lucian
Mon, Feb 6 2012 7:28 AMPermanent Link

Lucian

CREATE FUNCTION "AddToken" (
IN "InputStr" VARCHAR COLLATE "UNI_CI",
IN "DelimStr" VARCHAR COLLATE "UNI_CI",
IN "TokenStr" VARCHAR COLLATE "UNI_CI")
RETURNS VARCHAR COLLATE "UNI_CI"
BEGIN
 DECLARE Result VARCHAR DEFAULT '';

 IF InputStr = '' THEN
   SET Result = TokenStr;
 ELSE
   IF TokenStr = '' THEN
     SET Result = InputStr;
   ELSE
     IF DelimStr = '' THEN
       SET Result = InputStr + TokenStr;
     ELSE
       SET Result = InputStr + DelimStr + TokenStr;
     END IF;
   END IF;
 END IF;

 RETURN Result;
END

Sample of usage:

AddToken('ABC', ', ', 'DEF') = 'ABC, DEF'
AddToken('', ', ', 'DEF') = 'DEF'
AddToken('ABC', ', ', '') = 'ABC'
AddToken('', ', ', '') = ''
Mon, Feb 6 2012 7:33 AMPermanent Link

Lucian

The above reply had a meaningfull subject line which does not show up when I use Internet Explorer. This post also has a meaningfull subject line that will not show up in Internet Explorer.

This why I still use XanaNews to read newsgroups Smile

regards
Lucian
Mon, Feb 6 2012 9:14 AMPermanent Link

Lucian

BTW, sorry I asked  for this feature here ... I missed there was a ng only for this.

regards
Lucian
Mon, Feb 6 2012 9:42 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Lucian

I asked ages ago for session level functions but, given the architecture of ElevateDB, its difficult to see how Tim could make it work securely. The only place I can see he could put such things is in the configuration file and since you could (not at the same time) have the same database being accessed via different configuration files it could get messy.

I wanted to share stuff between an in-memory and a disk database. My personal solution was a small procedure to copy the various functions / procedures across.


Roy Lambert [Team Elevate]
Mon, Feb 6 2012 10:04 AMPermanent Link

Lucian

>...have the same database being accessed via different configuration files it could get messy.

Ok, I can see that.

Than perhaps that's where the "shared code" idea can help. For many years people asked Borland/Inprise to add new funcs/procs to their SysUtils unit and, in the end, many requests got there. Since these session level functions and procs would not have references to any tables or columns they ought to be inside EDB core code, string functions, numeric functions, etc.

Stuff like: IsLeapYear, IsCurWeek, IsCurMonth, IsCurYear, IsLastWeek, IsLastMonth, IsLastYear, IsQ1/2/3/4/, IsFirstHalfOfYear. (I'll upload these shortly)

CURRENT_DATE it's nice, but it's even nicer to see YESTERDAY's sales.

regards
Lucian
Mon, Feb 6 2012 10:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Lucian

>Stuff like: IsLeapYear, IsCurWeek, IsCurMonth, IsCurYear, IsLastWeek, IsLastMonth, IsLastYear, IsQ1/2/3/4/, IsFirstHalfOfYear. (I'll upload these shortly)

That will have to wait on Tim's decision. Some things I could support being in the core (especially things I want) but I also don't want to end up with something like Word or Excel where its big, bloated and I can't believe many people use a lot of its features.

These days with three primary components (ElevateDB, WPTools, FastReport) and a project starts at 5Mb. I really don't want that start point much higher.

Another thought has just occured. Have you looked at the external functions capability of ElevateDB yet? That could give you the single code base to maintain and all that's needed for each database is the links to the dll and the functions.

Roy Lambert [Team Elevate]
Mon, Feb 6 2012 11:21 AMPermanent Link

Lucian

>and a project starts at 5Mb. I really don't want that start point much higher.

hehehe ... my limit is a bit higher, about 10-12MB Smile

>Another thought has just occured. Have you looked at the external functions capability of ElevateDB yet?

No, not yet. I'll give it a shot one of these days

Lucian
Mon, Feb 6 2012 1:26 PMPermanent Link

Adam Brett

Orixa Systems

>Another thought has just occured. Have you looked at the external functions capability of ElevateDB yet?

External libraries are a very good place to "wrap" often used external processes. You can end up with a single DLL which contains a good number of functions in 1 place.

Then you only have to

CREATE EXTERNAL MODULE XXX in your new database and all the functions are immediately available.

It means a bit of programming in Delphi to generate the DLL ... but once that is done its easy to transfer around.
Mon, Feb 6 2012 1:45 PMPermanent Link

George

> Many times I need a handfull of stored procs in many databases if not all
> of them. And so I have to add the very same function or proc to every
> database and if there's a bug I have to fix it tons of times.
>

Here's a workaround that I use:

1) Have the current database set to where the function is defined.
2)  Call the function and if the parameters involve data from another
database, prefix the tablename with the database name.


Example:
Table1 residing in Database1
AddToken Function defined in Database2

SQL Statements:

Set Current database to Database2 and the following works
select  *, AddToken(SomeFieldInTable1) from Database1.Table1

However Setting the Current database to Database1 and
the following DOES NOT WORK
select  *, Database2.AddToken(SomeFieldInTable1) from Table1

Page 1 of 2Next Page »
Jump to Page:  1 2
Image