Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread INSERT INTO..SELECT FROM Using parameters.
Tue, Oct 8 2013 6:17 PMPermanent Link

RichardWu

Hi everyone, do you known how to use parameters in the INSERT INTO ..SELECT FROM ?
Like:
INSERT INTO tablename (Columnname...)
SELECT parameter1,  CASE WHEN xDayOfWeek BETWEEN parameter2 AND parameter3
                                          THEN 1 ELSE 0 END AS OccupiedDay
FROM tablename
WHERE xGUID=paramerter4

I have set values to these parameters before INSERT, but still there is errors, any good ideas about this?
Wed, Oct 9 2013 3:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

RichardWu

>Hi everyone, do you known how to use parameters in the INSERT INTO ..SELECT FROM ?
>Like:
>INSERT INTO tablename (Columnname...)
>SELECT parameter1, CASE WHEN xDayOfWeek BETWEEN parameter2 AND parameter3
> THEN 1 ELSE 0 END AS OccupiedDay
>FROM tablename
>WHERE xGUID=paramerter4
>
>I have set values to these parameters before INSERT, but still there is errors, any good ideas about this?

ElevateDB does not permit the substitution of parameters for system objects (eg column names). If this is a script you will have to build the string manually and then use that either via EXECUTE IMMEDIATE or using a cursor.

Roy Lambert [Team Elevate]
Wed, Oct 9 2013 12:11 PMPermanent Link

RichardWu

So is there anyway to insert just the parameter values to a table(or temporary table) like:
INSERT INTO tablename (Columnname,Columname)
VALUES(parameter,parameter)

This is not the substitution of system objects, does it work in some way?





Roy Lambert wrote:

RichardWu

>Hi everyone, do you known how to use parameters in the INSERT INTO ..SELECT FROM ?
>Like:
>INSERT INTO tablename (Columnname...)
>SELECT parameter1, CASE WHEN xDayOfWeek BETWEEN parameter2 AND parameter3
> THEN 1 ELSE 0 END AS OccupiedDay
>FROM tablename
>WHERE xGUID=paramerter4
>
>I have set values to these parameters before INSERT, but still there is errors, any good ideas about this?

ElevateDB does not permit the substitution of parameters for system objects (eg column names). If this is a script you will have to build the string manually and then use that either via EXECUTE IMMEDIATE or using a cursor.

Roy Lambert [Team Elevate]
Wed, Oct 9 2013 12:25 PMPermanent Link

Uli Becker

RichardWu,

> So is there anyway to insert just the parameter values to a table(or temporary table) like:
> INSERT INTO tablename (Columnname,Columname)
> VALUES(parameter,parameter)

This will work in a script e.g.:

Execute Immediate 'INSERT INTO MyTable (Col1,Col2) values (?,?)' using
Param1, Param2;

Uli
Thu, Oct 10 2013 3:24 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< Hi everyone, do you known how to use parameters in the INSERT INTO
...SELECT FROM ? >.

ElevateDB does not allow for the use of parameters in the SELECT columns
list.  I'm hoping to relax this a bit for things like CASE that don't affect
the type/size of the SELECT expression at some point, but for now this is
the rule.

Tim Young
Elevate Software
www.elevatesoft.com


Wed, Oct 23 2013 12:55 AMPermanent Link

Ben Sprei

CustomEDP

Since you are setting a parameter value in code why dont you build the SQL
line in code using a format statement.  That will put the parameter value in
the SQL statement.

Ben

"Uli Becker" <johnmuller54@googlemail.com> wrote in message
news:EBCCC6CD-A088-4AC7-A05D-2177B6189B01@news.elevatesoft.com...
> RichardWu,
>
>> So is there anyway to insert just the parameter values to a table(or
>> temporary table) like:
>> INSERT INTO tablename (Columnname,Columname)
>> VALUES(parameter,parameter)
>
> This will work in a script e.g.:
>
> Execute Immediate 'INSERT INTO MyTable (Col1,Col2) values (?,?)' using
> Param1, Param2;
>
> Uli
>

Image