Passing Hash variable in to sql query in perl

Hi Everyone,

Can anyone help me how do i call hash variable in to sql query in perl. Please see the script below

i have defined two Hash %lc and %tab as below

$lc{'REFF'}='V_RES_CLASS';
$lc{'CALE'}='V_CAP_CLASS';
$lc{'XRPD'}='V_XFMR_CLASS';
$tab{'V_RES_CLASS'}='V_MFR_SERS';
$tab{'V_CAP_CLASS'}='V_MFR_SERS';
$tab{'V_XFMR_CLASS'}='V_TFM_MFR_SERIES';

in the query i should use these two hash table varible
my table name is V_CAP_CLASS and attribute is v_MFR_SERIES.

$tbl=$lc{'CALE'};
$att=$tab{$lc{'CALE'}};

query is as below

$sth=$dbh->prepare("select prt.v_prt_nbr, cgy.$att from _prt_class prt,  $tbl cgy where prt.obj_id=cgy.obj_id");

this query is not executing throwing below error

DBD::Oracle::db prepare failed: ORA-01747: invalid user.table.column, table.column

Can anyone pls help me.... Appreciate your help.

Thanks

Try,

$sth=$dbh->prepare("select prt.v_prt_nbr, ? from _prt_class prt,  ? cgy where prt.obj_id=cgy.obj_id");
$sth->execute("cgy.$att", $tbl);

sorry agn,

still throwing below error

BD::Oracle::db prepare failed: ORA-00903: invalid table name (DBD ERROR: OCIStmtExecute/Describe)

Are you sure this query is correct ?

$sth=$dbh->prepare("select prt.v_prt_nbr, cgy.$att from _prt_class prt,  $tbl cgy where prt.obj_id=cgy.obj_id");

Hi,

Yes. Query is very much correct.

could anyone pls provide the resolution at the earliest........

can any expert help me on this.

Try,

$qry="select prt.v_prt_nbr, cgy.$att from _prt_class prt,  $tbl cgy where prt.obj_id=cgy.obj_id";
$sth=$dbh->prepare($qry);