Pass select result as parameter of stored procedure

1.One way is: a) Declare your variables b) Assign values to them with a single select statement c) Execute the procedure passing the local variables d) Execute the following in a loop using WHILE or CURSOR in order to apply this for all rows in TABLE1 DECLARE @param1 <DATATYPE>, @param2 <DATATYPE>, … SELECT TOP 1 … Read more

Angular 2 custom validator with parameters

Here is a sample. It’s a min value validator where you pass in a number to validate. import {Control} from ‘angular2/common’; export const minValueValidator = (min:number) => { return (control:Control) => { var num = +control.value; if(isNaN(num) || num < min){ return { minValue: {valid: false} }; } return null; }; }; More details can … Read more

Optional argument in PL/pgSQL function

Since PostgreSQL 8.4 (which you seem to be running), there are default values for function parameters. If you put your parameter last and provide a default, you can simply omit it from the call: CREATE OR REPLACE FUNCTION foofunc(_param1 integer , _param2 date , _ids int[] DEFAULT ‘{}’) RETURNS SETOF foobar — declare return type! … Read more

“Order By” using a parameter for the column name

You should be able to do something like this: SELECT * FROM TableName WHERE (Forename LIKE ‘%’ + @SearchValue + ‘%’) OR (Surname LIKE ‘%’ + @SearchValue + ‘%’) OR (@SearchValue=”ALL”) ORDER BY CASE @OrderByColumn WHEN 1 THEN Forename WHEN 2 THEN Surname END; Assign 1 to @OrderByColumn to sort on Forename. Assign 2 to … Read more

How can C# nullable value typed values be set on NHibernate named IQuery parameters?

OK, it turns out there are some overrides on SetParameter that allow the type to be set explicitly. For example: query.SetParameter(position, null, NHibernateUtil.Int32); The full extension methods (for Int32 and DateTime only) are now: public static class QueryExtensions { public static void SetInt32(this IQuery query, int position, int? val) { if (val.HasValue) { query.SetInt32(position, val.Value); … Read more

Default Values to Stored Procedure in Oracle

Default values are only used if the arguments are not specified. In your case you did specify the arguments – both were supplied, with a value of NULL. (Yes, in this case NULL is considered a real value :-). Try: EXEC TEST() Share and enjoy. Addendum: The default values for procedure parameters are certainly buried … Read more

Get all parameters from JSP page

<%@ page import = “java.util.Map” %> Map<String, String[]> parameters = request.getParameterMap(); for(String parameter : parameters.keySet()) { if(parameter.toLowerCase().startsWith(“question”)) { String[] values = parameters.get(parameter); //your code here } }

What is the scope of a defaulted parameter in Python? [duplicate]

The scope is as you would expect. The perhaps surprising thing is that the default value is only calculated once and reused, so each time you call the function you get the same list, not a new list initialized to []. The list is stored in f.__defaults__ (or f.func_defaults in Python 2.) def f(a, L=[]): … Read more

Why does passing null to a params method result in a null parameter array?

A params parameter is only meant to provide a convenient way of specifying values – you can still pass an array reference directly. Now, null is convertible to either string[] or string, so both interpretations are valid – it’s up to the spec which is preferred. The spec states in section 10.6.1.4 that: The argument … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)