From: Sathish on
Hello All,

I am trying to pass variablename and value in the following command

orabind statement-handle ?:varname value ...?

I tried following methods

Method 1:
set part_values_bind {:WORDS ${value_WORDS} :OWNING_ORGANIZATION $
{value_OWNING_ORGANIZATION} :ICAP ${value_ICAP} :EXPORT_JOB_ID $
{exp_job_id}}
orabind $ora_insrt_stmnt [puts $part_values_bind]

Method 2:
orabind $ora_insrt_stmnt $part_values_bind

Method 3
set part_values_bind ":WORDS $value_WORDS :OWNING_ORGANIZATION
$value_OWNING_ORGANIZATION :ICAP $value_ICAP :EXPORT_JOB_ID
$exp_job_id"
orabind $ora_insrt_stmnt [puts $part_values_bind]

Method 4:
orabind $ora_insrt_stmnt $part_values_bind

For everything, binding gets executed but the oraexec fails.

I tried to give the variable name and value statically as following,
and this works fine

orabind $ora_insrt_stmnt :WORDS $value_WORDS :OWNING_ORGANIZATION
$value_OWNING_ORGANIZATION :ICAP $value_ICAP :EXPORT_JOB_ID
$exp_job_id

Please let me know if you have a solution for this.

Thanks,
Sathish
From: Gerald W. Lester on
Sathish wrote:
> Hello All,
>
> I am trying to pass variablename and value in the following command
>
> orabind statement-handle ?:varname value ...?
>
> I tried following methods
>
> Method 1:
> set part_values_bind {:WORDS ${value_WORDS} :OWNING_ORGANIZATION $
> {value_OWNING_ORGANIZATION} :ICAP ${value_ICAP} :EXPORT_JOB_ID $
> {exp_job_id}}
> orabind $ora_insrt_stmnt [puts $part_values_bind]
>
> Method 2:
> orabind $ora_insrt_stmnt $part_values_bind
>
> Method 3
> set part_values_bind ":WORDS $value_WORDS :OWNING_ORGANIZATION
> $value_OWNING_ORGANIZATION :ICAP $value_ICAP :EXPORT_JOB_ID
> $exp_job_id"
> orabind $ora_insrt_stmnt [puts $part_values_bind]
>
> Method 4:
> orabind $ora_insrt_stmnt $part_values_bind
>
> For everything, binding gets executed but the oraexec fails.
>
> I tried to give the variable name and value statically as following,
> and this works fine
>
> orabind $ora_insrt_stmnt :WORDS $value_WORDS :OWNING_ORGANIZATION
> $value_OWNING_ORGANIZATION :ICAP $value_ICAP :EXPORT_JOB_ID
> $exp_job_id
>
> Please let me know if you have a solution for this.
>
> Thanks,
> Sathish

You need to (re-)read the Dodekalogue (http://wiki.tcl.tk/10259).

Short answer to your question:

First off you should do:
set part_values_bind [list \
:WORDS $value_WORDS \
:OWNING_ORGANIZATION $value_OWNING_ORGANIZATION \
:ICAP $value_ICAP \
:EXPORT_JOB_ID $exp_job_id \
]


In Tcl 8.5+:
orabind $ora_insrt_stmnt {*}$part_values_bind

In earlier versions do:
eval orabind $ora_insrt_stmnt $part_values_bind


--
+------------------------------------------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
From: Andreas Leitgeb on
Gerald W. Lester <Gerald.Lester(a)cox.net> wrote:
>> orabind $ora_insrt_stmnt :WORDS $value_WORDS :OWNING_ORGANIZATION
>> $value_OWNING_ORGANIZATION :ICAP $value_ICAP :EXPORT_JOB_ID
>> $exp_job_id
>> Please let me know if you have a solution for this.
> You need to (re-)read the Dodekalogue (http://wiki.tcl.tk/10259).
>
> Short answer to your question:
>
> First off you should do:
> set part_values_bind [list \
> :WORDS $value_WORDS \
> :OWNING_ORGANIZATION $value_OWNING_ORGANIZATION \
> :ICAP $value_ICAP \
> :EXPORT_JOB_ID $exp_job_id \
> ]
>
> In Tcl 8.5+:
> orabind $ora_insrt_stmnt {*}$part_values_bind
>
> In earlier versions do:
> eval orabind $ora_insrt_stmnt $part_values_bind

Good advice, except for the last line (for pre-8.5), which had
better read;

eval orabind [list $ora_insrt_stmnt] $part_values_bind

Mind the extra [list ...] for the pre-8.5 way.
The variant for 8.5+ does not need the extra list, so if you don't
need 8.4 or earlier, then by all means use the modern idiom.

From: Sathish on
Hi,

eval did the magic. Thanks for the link also.

I am working on moving bulk data between applications, try to use sql
binding to gain performance. Thanks for the help.

Sathish