Prepared Statement does not insert [closed] - oracle

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am new to JDBC and trying following code. Could not find the error in it:
try{
Connection con = ConnectionProvider.getCon();
stmt=con.prepareStatement("insert into create_request values((select count(reqno) from create_request)+1,?,?,?,?,?)");
stmt.setString(1,obj_Leaverequest.getUser_name());
stmt.setString(2,obj_Leaverequest.getLeave_Type());
stmt.setInt(3,obj_Leaverequest.getLeave_Units());
stmt.setString(4,obj_Leaverequest.getLeave_Reason());
stmt.setString(5,"pending");
count=stmt.executeUpdate();
if(count>0){
status=true;
}
}
Update:
If I replace my code like this it works:
String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Getters are working fine, I could print their values. I guess I am wrong with the query. Please point out my mistake. Thanks in advance!!

String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Check for the "?" prepared statements index . You have 6 , but you need only 5
Hope this helps

Related

r.PostForm() works only if I call before r.PostFormValue() [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
As the title say, I have a code like this:
//if i don't use this line r.postform() don't works and return absolute nothing.
//html form works correctly
// I don't need to call r.PostFormValue for every key, just one
fmt.Println(r.PostFormValue("oldpass"))
if r.PostForm.Has("oldpass") && r.PostForm.Has("newpass1") && r.PostForm.Has("newpass2")
{ //if i don't call r.PostFormValue() the program stop before the if }
}
Make no sense to me... Also I remember to have used it without in the past, so I don't think it depend on parsing the value... What could be?

Object required error when executing the code [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am getting this error in QTP when using GetCellData and Childitem.
These are very simple pieces of code, but return an error.
set mytable1=Browser("name:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").WebTable("name:=Home","index:=0").GetCellData(7,2)
msgbox mytable1
AND
set mytable=Browser("name:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").WebTable("name:=Home","index:=0").ChildItem(1,1,"Link",0)
msgbox mytable
This is not an object variable. Remove set and you are set :)
mytable1=Browser("name:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").WebTable("name:=Home","index:=0").GetCellData(7,2)
msgbox mytable1

Check if Hash is included in output [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to check if a specific element is included in an output. I run:
results.include? {"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100}
but I get an error:
Syntax error, unexpected =>, expecting '}'
What did I do wrong?
The problem is that the curly brackets in this case are interpreted as start of a block. Just put () around:
results.include?({"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100})

Trying to access array within a hash in ruby [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am trying to parse a hash in ruby. I have an array an array of 'entries'. I want to take each entity and get array of runs within it (I want to store the runs in a different variable as seen below). My problem is that runs always turns out nil. Below is my code:
entries = test_plan['entries']
entries.each do |ent|
puts "in entries"
puts ent
runs = ent['runs]']
runs.each do |run|
and what an 'entries' hash looks like.
{"id"=>"7", "suite_id"=>729, "name"=>"Regression", "runs"=>[{"id"=>2588, "suite_id"=>729}]}
There is a simple typo. Change
runs = ent['runs]']
to
runs = ent['runs']

Apply regex to a string in irb [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am trying to get this to work. Its driving me nuts.
'/leisure/venuename/news'.gsub(/\^(.*)(\/.*)$/, $1#$2)
This should return
/leisure/venuename#/news
so eventualy I can do it to this
venue_news_index_path(sensitive_venue).gsub(/\^(.*)(\/.*)$/, $1#$2)
This?
'/leisure/venuename/news'.gsub(/^(.*)(\/.*)$/, '\1#\2')

Resources