Question

I am using Oracle 10 G database

    Drop Table yassin; 
Create Table yassin as Select  
              sad_gen.key_dec,
              sad_gen.key_year,
              sad_gen.sad_typ_proc,
              sad_gen.sad_asmt_nber,
              sad_gen.key_cuo,
              sad_gen.sad_reg_nber,
              sad_gen.sad_reg_date,
              sad_gen.sad_asmt_date,
              sad_gen.sad_dec_date,
              sad_gen.sad_exporter,
              sad_gen.sad_stat_val,
              sad_gen.key_nber,
              sad_gen.sad_itm_total,
              sad_gen.sad_pack_total,
              sad_gen.sad_consignee,
              sad_gen.sad_cty_1dlp,
              sad_gen.sad_tra_cty,
              sad_gen.sad_cty_expcod,
              sad_gen.sad_cty_destcod,
              sad_gen.sad_tod_cod,
              sad_gen.sad_cur_cod,
              sad_gen.sad_tot_invoiced,
              sad_gen.sad_tra_cod1,
              sad_gen.sad_mot_bord,
              sad_gen.sad_cuo_bord,
              sad_gen.sad_total_taxes,
              sad_gen.sad_reg_year,
              sad_gen.sad_asmt_year,
              sad_gen.sad_rcpt_nber,
              sad_gen.sad_rcpt_date,
              sad_gen.sad_loc_goods,
              sad_gen.sad_lop_cod,
              sad_gen.sad_whs_time
              FROM   sad_gen
              WHERE  
                    sad_gen.sad_num=:X
                    AND   sad_gen.lst_ope='U';

                    SELECT  *  from yassin;

When I use it and SET parameter X VALUE IN .NET with OleDbDataAdabtor

The error I get is ORA-01036: illegal variable name/number

this is my function. Query is upper is query Para is sturct that keep parameter values public DataTable GetTable(String Query,AsycudaParameter[] Para) {

    OleDbConnection c = new OleDbConnection(ConnectionString);
    c.Open();

    OleDbDataAdapter da = new OleDbDataAdapter(Query, c);

    for (int b = 0; b < Para.Length; b++)
    {
        if (Query.Contains(Para[b].name))
        {
            if (Para[b].Type == TypeCode.String)
            {
                da.SelectCommand.Parameters.Add(new OleDbParameter(Para[b].name, OleDbType.VarWChar));
                da.SelectCommand.Parameters[da.SelectCommand.Parameters.Count - 1].Value = Para[b].value.ToString();

            }
            if (Para[b].Type == TypeCode.Decimal)
            {
                da.SelectCommand.Parameters.Add(new OleDbParameter(Para[b].name, OleDbType.Decimal));
                da.SelectCommand.Parameters[da.SelectCommand.Parameters.Count - 1].Value = decimal.Parse(Para[b].value.ToString());

            }
        }
    }
    DataTable dt = new DataTable();
    da.Fill(dt);


    c.Close();


    return dt;
}
Était-ce utile?

La solution

Oracle does not allow bind variables in DDL. So you cannot use a bind variable in a CREATE TABLE statement. If you really want to create a table, you would have to hard-code the query in the DDL (that is, you would probably need to use string concatenation to build the DDL statement rather than using bind variables).

Why would you want to create a table at runtime in your application in the first place? That is generally not something that you would want to do-- tables should be created when you are installing your application, not at runtime.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top