Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Building a Statement
Sat, Nov 22 2008 7:02 AMPermanent Link

Leslie
This question is probably very easy to answer (does not require Tim), hopefully soemone
will be around to answer it on the weekend.

I am trying to create a tigger to make some changes before the insert takes place. Got
confused with the syntax. How to build a statement to include some new field values? These
are what I have tried, but was not accepted by the engine:


BEGIN
EXECUTE IMMEDIATE   'Update State
                  Set Sort_ID= Sort_ID + 1
                  where Parent_ID = ' + NewRow.Parent_ID  +
                  ' and Sort_ID >= '+ NewRow.Sort_ID;

END     

BEGIN
EXECUTE IMMEDIATE   'Update State
                  Set Sort_ID= Sort_ID + 1
                  where Parent_ID = ' + cast(NewRow.Parent_ID as char(12))  +
                  ' and Sort_ID >= '+ cast(NewRow.Sort_ID as char(12));

END   

Regards,
Leslie
Sat, Nov 22 2008 7:10 AMPermanent Link

Leslie
Solved it: Smile

BEGIN
Declare Parent_ID_as_String VARCHAR DEFAULT '';
Declare Sort_ID_as_String VARCHAR DEFAULT '';
                     
set Parent_ID_as_String = cast(NewRow.Parent_ID as VARCHAR);
set Sort_ID_as_String    = cast(NewRow.Sort_ID as VARCHAR);

Execute immediate
                 'Update State
                  Set Sort_ID= Sort_ID + 1
                  where Parent_ID = ' + Parent_ID_as_String +
                  ' and Sort_ID >= '+ Sort_ID_as_String;

END
Sat, Nov 22 2008 7:32 AMPermanent Link

Leslie
Also it better be an After Insert trigger. Smile
Tue, Nov 25 2008 3:23 PMPermanent Link

Leslie
Very simple sytnax question again:

How to make a string quoted  with   '   in a script?
Tue, Nov 25 2008 4:10 PMPermanent Link

"Malcolm"
Leslie wrote:

> Very simple sytnax question again:
>
> How to make a string quoted  with   '   in a script?

Try:

   'Leslie''s string'

--
Tue, Nov 25 2008 4:40 PMPermanent Link

Leslie
Malcolm

I probably  wasn't precise enough. Smile

What I want to do is assigning a value to a variable, and the value should be a quoted
string.

Declare aStringVar VarChar;

-- instead of
set aStringVar = 'somestring'

-- I need
set aStringVar = ' 'somestring' '

Any idea about this?



Leslie

 
Tue, Nov 25 2008 6:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Leslie,

<< What I want to do is assigning a value to a variable, and the value
should be a quoted string. >>

A QUOTEDSTR() function will be in the either the next build or 2.03.  (most
likely the next build along with an INTRANSACTION() function since both are
really needed right now)

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Nov 26 2008 5:30 AMPermanent Link

Tiago Ameller
Tim,

<< (most
likely the next build along with an INTRANSACTION() function since both are
really needed right now) >>

Any chance to see next build / release before Thanksgiving day? Smiley
Mon, Dec 1 2008 9:40 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tiago,

<< Any chance to see next build / release before Thanksgiving day? Smiley>>

No. (says he on December 1st) Smiley

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Dec 1 2008 10:36 AMPermanent Link

Tiago Ameller
Tim,

<<No. (says he on December 1st) Smiley>

Oh, sorry! I forgot to say 2009's Thanksgiving day <very great Smiley!
Image