Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> Problem with Oracle Parameter

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: Problem with Oracle Parameter
 Probi  Posted: May 21, 2008 07:36:24 AM

 Total Post: 4
 Joined: May, 2008






 Hello,

I have come accros this problem, altough I have been using this code before

I have an oracle command with 1 parameter

string cmd = " Select value from Database where id = :p1";
OracleCommand command1 = new OracleCommand ( cmd, connection); OracleParameter p1= new OracleParameter ( "p1", OracleType.Varchar, 8);
p1.Direction = ParameterDirection.InputOutput;
OracleDataReader rdr = null;
try { connection.Open();

command.Parameters.Clear();
command.Parameters.Add(p1);
p1.Value = id_1;
command.ExecuteNonQuery();
rdr = command .ExecuteReader();

......
}


the problem I get is in this line p1.Value=id_1;

id_1 is a string of max 8 characters,

and in p1.Value I get just the 1character

any idea why?

thanks Probi

 fozturk
Posted: May 21, 2008 07:44:46 AM  

 Total Post: 69
 Joined: Sep, 2007






 

i guess you shall assing the parameter value before you add to the commands parameters,
reverse the order of
"command.Parameters.Add(p1);
p1.Value = id_1;
"
with
"
p1.Value = id_1;
command.Parameters.Add(p1);
"
hope works

 Probi
Posted: May 21, 2008 08:43:11 AM  

 Total Post: 4
 Joined: May, 2008






 
Hello,

I tried your idea
but still no change

to better explain

ex. atring id_1 = " valuse";

after this line

p1.Value = id_1;

id_1 = value and p1.Value = v

so it gets some value just not the whole string

any other ideas?

thanks
Probi

 GOPU
Posted: May 22, 2008 06:39:20 AM  

 Total Post: 335
 Joined: Apr, 2008






 
when you execute this query what the error you are getting ?

 Probi
Posted: Jun 18, 2008 11:55:36 AM  

 Total Post: 4
 Joined: May, 2008






 
Ok,
I´m still with the same problem, but now I have more details

Example: I have a string of 4 characters ( string car = "abcd";)
and I pass it to parameter p1

p1.Value = car;

in the debug I see that car has the value "abcd"
but p1.Value gets only "ab"

I tryed more examples and in every situation it get just half of the string

the parameter is defined as

OracleParameter p1 = new OracleParameter("p1", OracleType.VarChar, 8);
p1.Direction = ParameterDirection.InputOutput;

so it should get all 8 characters

any help is more than wellcomed, Im getting frustrated

Thanks,
Probi


 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gopu Gopi335
  Gitesh Trivedi322
  Vinoth Kumar264
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software