parameters

How to pass a parameter from vb.net

假装没事ソ 提交于 2019-12-18 09:35:14
问题 I have a Program that will auto run each night, run a query, and email results. In my program I am calling a function as part of the query... What i'd like to is pass the date the program is run as the parameter. (@startdate and @enddate) @startdate will always be "today's" date at 00:00:00 and enddate will always be "Todays date" at 23:59:59. So for example. If the program was run tonight, it would pass 1/31/13 as the date. Tomorrow, it would pass 2/1/13 as the date, the next date 2/2/13,

Iterating through method parameters

安稳与你 提交于 2019-12-18 07:41:48
问题 It's a simple and maybe trivial question: in Java how can I iterate through the parameters passed to the method where I'm working? I need it to trim() all of them that are strings. EDIT To be more precise an example of use can be this (written in a pseudo-code reflecting how I wish it to work): public void methodName(String arg1, int arg2, int arg3, String arg4, double arg5) for(Object obj : getThisMethod().getParameters() ) System.out.println(obj.getName() + " = " + obj.toString()) The point

Java assigning a new value to a parameter, is this considered a bad practice?

情到浓时终转凉″ 提交于 2019-12-18 07:36:30
问题 I have read the question here: Is it problematic to assign a new value to a method parameter?. However it is not clear to me if doing something like: public void myMethod(Object obj) { doSomething(obj); obj = getNewObj(); } or: public void anotherMethod(Object obj) { obj = doSomething(obj): } This is basically just to avoid declaring a new local variable, is this worth it?, is this seen as a bad practice?. 回答1: This is a bad practice. You will be hard pressed to find a scenario where the

How to return a specific element of an array?

强颜欢笑 提交于 2019-12-18 07:08:07
问题 I want to return odd numbers of an array yet Eclipse doesn't seem to accept my return array[i]; code. I think it requires returning a whole array since I set an array as a parameter to my method. As I said before, I need to pass an array and get a specific element of that array in return. Even if I make that array static, how do I return a single element? Edit : Alright then, here it is: public class newClass{ public static void main(String[] args) { int [] newArray= new int [4]; int [] array

GROUP BY using parameters in SQL

不打扰是莪最后的温柔 提交于 2019-12-18 06:44:06
问题 I am trying to somehow group a report based on a drop-down list of parameters that is pre-defined. I want to be able to subtotal the Total Hours or Total Pay of my report based on Department or JobCode. I have created the parameters and have no problem with that, I just am not sure if it's possible to use those parameters to call out a grouping command. Below is the spirit of what I am wanting, but the GROUP BY clause doesn't work for me even without a parameter. SELECT EmployeeID, LastName,

Pass column name as parameter to PostgreSQL using psycopg2

▼魔方 西西 提交于 2019-12-18 05:38:05
问题 I'm trying to add columns to a table using psycopg2 row1 below is a list of column names to be added to the table. I can do it manually but when I try to do it programatically I get an error. for c in row1: cur.execute("ALTER TABLE HHV2PUB ADD COLUMN %s text", (c,)) The error is: cur.execute("ALTER TABLE HHV2PUB ADD COLUMN %s text", (c,)) psycopg2.ProgrammingError: syntax error at or near "'HOUSEID'" LINE 1: ALTER TABLE HHV2PUB ADD COLUMN 'HOUSEID' text My guess is that it has something to do

confusion with value type and reference type in c#

扶醉桌前 提交于 2019-12-18 05:25:26
问题 I have bit confusion about parameters. When we should have to use reference parameter and when should have to use value type parameters while programming with methods/functions in c# ? 回答1: You need to be very clear on the distinction between reference types vs value types, and "by value" parameters vs "by reference" parameters. I have articles on both topics: Reference types and value types Parameter passing The two interact somewhat when using a "by value" parameter which is a reference

mod_rewrite: Pass the path & query string URL as a parameter

半城伤御伤魂 提交于 2019-12-18 05:18:28
问题 I'm using mod_rewrite to rewrite pretty URLs to a form supported by a Spring 2.5 application. e.g. /category/cat1?q=x => /controller?category=cat1&q=x However from my controller I want to know the original URL the request came from (so I can generate a link if required). This approach is needed generically across all pages so it is difficult to hard code. How can I access the original path + query string from my controller? I have tried using $0 to include the full path but this doesn't

Conventions for order of parameters in a function

僤鯓⒐⒋嵵緔 提交于 2019-12-18 04:52:45
问题 In writing functions my brain always spends a few milliseconds to check which order of parameters would be best for a given function. should I write: public Comment AddComment(long userID, string title, string text) Or probably: public Comment AddComment(string title, string text, long userID) Why not: public Comment AddComment(string title, long userID, string text) Do you follow any rules when ordering the parameters for your functions? Which parameter would you place first and which would

Custom error from parameters in PowerShell

血红的双手。 提交于 2019-12-18 04:37:11
问题 Is it possible to have ValidateScript generate a custom error message when a test fails, like say Test-Path ? Instead of this: Test-Folder : Cannot validate argument on parameter 'Folder'. The "Test-Path $_ -Path Type Container" validation script for the argument with value "blabla" did not return a result of True. Determine why the validation script failed, and then try the comma and again. It would be nice to have it report this instead in the $Error variable: The 'Folder' is not found,