Questions tagged [named-parameters]

Named parameters enable you to specify an argument for a particular parameter by associating the argument with the parameter's name rather than with the parameter's position in the parameter list.

371 questions
1
vote
1 answer

CallableStatement setInt named parameter exception

I am trying to call a stored procedure by parameter name: int processId = 1; CallableStatement stmt = conn.prepareCall("{call get_process_log_latest(?)}"); stmt.setInt("process_id", processId); But setInt() throws a…
plantbeard
  • 358
  • 7
  • 16
1
vote
3 answers

named parameter passing multiple times

I was wondering if there is a best practice or a convention for this kind of "chained" named parameter. I am trying to pass the first variable d to bar through foo. It is kind of awkward to do it this way and I believe there should be a smarter way…
Bill Cheng
  • 732
  • 1
  • 8
  • 15
1
vote
2 answers

sql - return a row of constant values if row does not exist

I want to be able to return a row of none, none, 0 if no row is returned from query. I have this SQL: select first, last, count(address) from employee where last in ('james', 'smith', 'hankers') group by first, last union all select 'none', 'none',…
qollers
  • 43
  • 1
  • 5
1
vote
0 answers

When capturing Django named groups from a URL, how not to decode them?

I have the following url pattern defined (simplified for clarity) that captures the asset key (an arbitrary string) from a url: url(r'^assets/(?P.+)$', views.AssetDetail.as_view()) And my view is defined like this: def get(self, request,…
Cloud Artisans
  • 4,016
  • 3
  • 30
  • 37
1
vote
1 answer

Closure with keyword arguments named after parameters in Python 2.7

I need to declare a funktion dynamically at runtime that has an arbitrary number of named arguments (keywords), so that a different library can call this function with a dictionary as arguments. Here is an example of what I need: def…
RunOrVeith
  • 4,487
  • 4
  • 32
  • 50
1
vote
1 answer

Yii2: How do you use named parameters in console commands?

How can I write the console command yii controller/action --param1=something --param2=anything and retrieve those named parameters in the action?
TheStoryCoder
  • 3,403
  • 6
  • 34
  • 64
1
vote
0 answers

How can I configure a H2 database connection using spring to get scrollable result sets?

I am using a H2 database for reading data. I was configuring the connection with spring:
manuelvigarcia
  • 1,696
  • 1
  • 22
  • 32
1
vote
2 answers

Is there a neat (pythonic?) way to use named parameter defaults in Python given a condition?

I have a function with some named parameters, and a dictionary that contains keys with those names, as well as some other keys. I want to call the function with values from the dictionary. I can't use **data because Python will raise TypeError:…
Lee Netherton
  • 21,347
  • 12
  • 68
  • 102
1
vote
1 answer

How to provide optional parameters in Go?

I'm coming from a Node.js background, and there a typical pattern is to have a function which takes an options object, i.e. an object where you set properties for optional parameters, such as: foo({ bar: 23, baz: 42 }); This is JavaScript's…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
1
vote
1 answer

Force specific function signatures

I just caught myself writing code like this: def register(self, *, # * enforces keyword-only parameters key_value_container:dict=None, # legal parameter set #1 key:str=None, value=None): # legal parameter set…
frans
  • 8,868
  • 11
  • 58
  • 132
1
vote
1 answer

Calling query having multiple IN Clause from JAVA

This query runs fine from SQL Developer : select * from MYTABLE where (field1, field2) IN (('A', '1'), ('B','2'), ('C','3')) ; But when I try to call it from java I am getting exception. public List callDB(List sourceAndIdList) { …
Zeeshan
  • 11,851
  • 21
  • 73
  • 98
1
vote
2 answers

Swift function Parameter: Name and Object type

I have a question regarding the syntax of function parameters. Take this function for example: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ //code goes here } In the function…
Jay Patel
  • 1,266
  • 6
  • 20
  • 38
1
vote
1 answer

Multiple Parameter Sets Not Working

I'm trying to write a failure simple script utilizing parameter sets to simplify input and validation. I'd like the script to look like this: .\zipandrotate.ps1 -Zip [-AllButDays ] -Rotate [-MaxRetentionDays ] -Zip and therefore…
Mr. Lost IT Guy
  • 137
  • 2
  • 12
1
vote
1 answer

Swift: Why no labeled arguments in this situation?

For this code let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! NSString I will have forgot what the third argument stands for, soon. For some reason Swift (2.0) doesn't allow me to label the…
fiship
  • 15
  • 2
1
vote
1 answer

Using named arguments with variable length un-named arguments in Python

I apologize if this question has already been asked/answered, I would have expected that to be the case but was unable to find any related questions... I'd like to create a python function that takes two mandatory arguments, one named argument, and…
sfletche
  • 47,248
  • 30
  • 103
  • 119