I need to have a null value in a prompt for in my BOE Universe. How do I do this?
#Prompt('Special Claims Indicator','A','Special Claims Analytics\Special Claim Type Code',MULTI,CONSTRAINED,,{' '})
When I change my prompt value of ' ' to null or '' my error is Parse Failed: Invalid definition (UNV0023). Error parsing default values parameter (7th parameter)
I did some digging:
"Note: you cannot use the operators NULL and Not NULL when creating prompted filters. "
http://reports.is.ed.ac.uk/areas/itservices/busintel/TrainingMaterials/advUser/Lesson2-Step4.html
Related
I have a redshift table with a column which has empty values rarely. It is expected to have only integer values but some places empty values exist. When I try to cast it using :: it throws error -
[Code: 500310, SQL State: XX000] [Amazon](500310) Invalid operation: Invalid digit, Value 'B', Pos 0, Type: Integer
Details:
-----------------------------------------------
error: Invalid digit, Value 'B', Pos 0, Type: Integer
code: 1207
context: BEVEL_ON
query: 34112149
location: :0
process: query1_836_34112149 [pid=0]
-----------------------------------------------;
So to clarify you have a text column that contains numeric characters most of the time and you want to case this to integer, right? It also sounds like you believe that the only only non-numeric values are the empty string ''.
If this is the case then the solution is fairly simple - change the empty string to NULL before casting. The DECODE statement is my go to for this:
DECODE(col_X, '', NULL, col_X)::INT
If a more varied set of strings are in the column then using regexp_replace() to strip all the non-numeric characters would be needed.
text_to_int_alt(
case
when regexp_replace(convert(varchar, creative_id), '[^0-9]', '') <> '' then
regexp_replace(convert(varchar, creative_id), '[^0-9]', '')
end)
I read this
But when i'm passing string value in the variable at that time i'm getting error
Code :
type(${value}).__name__
Error:
Evaluating expression 'type(Robot).__name__' failed: NameError: name 'Robot' is not defined
String value converting as a variable
Please help me.
You should remove brackets {} around value and leave only $value.
Update to comment:
Robotframework treats everything as string unless you explicitly convert it to other datatype.
${value_str} Set Variable 4
${value_number} Convert To Number ${value_str}
${type1} Evaluate type($value_str).__name__
${type2} Evaluate type($value_number).__name__
Log ${type1}
Log ${type2}
I need to check whether the given input value of date is valid or not in python. I normally used datetime.strptime is to check for date. Am getting Value Error doesn't match format when i given the input value date '06-06-'. It's wrong only but i want to display the output like invalid.
if (datetime.strptime(s,'%m-%d-%y')):
print "valid"
else:
print "Invalid"
1 . s = '06-06-15'
when i given the input value like above, it display the correct output value "Valid"
s = '06-06-'
when i given the input value like above, am getting error like time data '06-13' does not match format '%m-%d-%y'. But i want to display the output "Invalid"
Please anyone suggest me to do that. Thanks in advance.
This is just how it works.
ValueError is raised if the date_string and format can’t be parsed by
time.strptime()
Just turn it to
datetime.strptime(s,'%m-%d-%y'):
print "valid"
except ValueError:
print "Invalid"
query = "select * results where id = '";
query.append(ID);
query.append("'");
res = PQexec(conn, query.c_str());
After executing this statement, i get the following error.
row number 0 is out of range 0..-1
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
However, when I run the same query in postgresql, it does not have any problem.
select * from results where id = 'hello'
The only problem is that if the query parameter passed is not in database, it would throw runtime error. If you provide the exact query parameter which is in database, it executes normally.
That's two separate errors, not one. This error:
row number 0 is out of range 0..-1
is from libpq, but is reported by code you have not shown here.
The error:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
is not from PostgreSQL, it is from your C++ runtime.
It isn't possible for me to tell exactly where it came from. You should really run the program under a debugger to tell that. But if I had to guess, based on the code shown, I'd say that ID is null, so:
query.append(ID);
is therefore aborting the program.
Separately, your code is showing a very insecure practice where you compose SQL by string concatenation. This makes SQL injection exploits easy.
Imagine what would happen if your "ID" variable was set to ';DROP TABLE results;-- by a malicious user.
Do not insert user-supplied values into SQL by appending strings.
Instead, use bind parameters via PQexecParams. It looks complicated, but most parameters are optional for simple uses. A version for your query, assuming that ID is a non-null std::string, would look like:
PGresult res;
const char * values[1];
values[0] = ID.c_str();
res = PQexecParams("SELECT * FROM results WHERE id = $1",
1, NULL, values, NULL, NULL, 0);
If you need to handle nulls you need another parameter; see the documentation.
Maybe, a bit too late but just want to put in my 5 cents.
Got this error also these days with a very simple stored procedure of the kind like:
CREATE OR REPLACE FUNCTION selectMsgCounter()
RETURNS text AS
$BODY$
DECLARE
msgCnt text;
BEGIN
msgCnt:= (SELECT max(messageID)::text from messages);
RETURN 'messageCounter: ' || msgCnt;
END
$BODY$
LANGUAGE plpgsql STABLE;
Made some debugging with:
if (PQntuples(res)>=1)
{
char* char_result=(char*) realloc(NULL,PQgetlength(res, 0,0)*sizeof(char));
strcpy( char_result,PQgetvalue(res, 0, 0));
bool ok=true;
messageCounter=QString(char_result).remove("messageCounter: ").toULongLong(&ok);
if (!ok) messageCounter=-1;
qDebug()<<"messageCounter: " << messageCounter;
free(char_result);
PQclear(res);
PQfinish(myConn); // or do call destructor later?
myConn=NULL;
}
else
{
fprintf(stderr, "storedProcGetMsgCounter Connection Error: %s",
PQerrorMessage(myConn));
PQclear(res);
PQfinish(myConn); // or do call destructor later?
myConn=NULL;
}
Turned out that the owner of the stored procedure was not the one whose credentials I used to log in with.
So - at least - in my case this error "row number 0 is out of range 0..-1" was at first sight a false positive.
I have a console application in c++ using boost program_options.
I have a parameter named --list-timezones
now I want to use it like that
either
myapp --list-timezones
which gives me all available timzones
or
myapp --list-timezones AT
which gives me onle the timezones for Austria
My options inializitation is the following
options.add_options()
("date-format,d", po::value<string>()->value_name("<Formatstring>")->default_value("%Y-%m-%d %H:%M:%S","\"%Y-%m-%d %H:%M:%S\""),"Format-string for input or output\ne.g. \"%Y-%m-%d %H:%M:%S\"")
("input-format,i", po::value<string>()->value_name("<Representation>")->default_value("HEX"),"HEX hex value\nBIN binary value\nDEC decimal value")
("output-format,o", po::value<string>()->value_name("<Representation>")->default_value("HEX"),"HEX hex Value\nBIN binary value\nDEC decimal value")
("to,t", po::value<string>()->value_name("<Date-Format>"),"CHROME\nMAC\nUNIX\nUNIX_ms\nWin64\nWinCookie\nWinOle\nWinFiletime\nDOS\nHFS\nHFS+")
("from,f", po::value<string>()->value_name("<Date-Format>")/*->default_value("UNKNOWN")*/,"CHROME\nMAC\nUNIX\nUNIX_ms\nWin64\nWinCookie\nWinOle\nWinFiletime\nDOS\nHFS\nHFS+\nUNKNOWN")
("timezone,z", po::value<string>()->value_name("<Time-Zone>")->default_value("UTC"),"e.g \"Europe/Vienna\"\n execute '--list-timezones ALL' to see all available timezones")
("list-timezones,l", po::value<string>()->value_name("<ISO-3166 Country Code>"), "List all available timezones\nyou can filter with ISO3166 country code(e.g AT for Austria)")
("value,v", po::value<string>()->value_name("<value>"), "Input Value")
("swap-bytes,s", "Swap bytes of result")
;
Any ideas how I can handle that?
If I use --list-timezones without an parameter I get an Exception
Thanks
florian
You want this:
("list-timezones,l", po::value<string>()->implicit_value("")->value_name(...
Then you'll be able to give an argument or not. If none is given, the string value will be empty, which seems like a reasonable sentinel value in your case.