job not working earlier now working - cron-task

Ok.
it is working now. Did the required modifications to the task and now it is working fine. Thanks for your help.
Thanks

You have misquoted your string. Ruby is interpreting this:
'*/30 * * * * salt '*' saltutil.sync_modules'
^
...as two separate strings with a multiplication between them:
'blah blah' * 'blah blah'
This is invalid Ruby code. You cannot multiply two strings, hence the error message.
Perhaps this is what you really meant instead:
"*/30 * * * * salt '*' saltutil.sync_modules"
^ ^
Note the use of double quotes instead of single quotes.

Related

Ingres SQL illegal pattern match and illegal escape sequence, unexpected results

I am querying a database that uses Ingres 10.2. I cannot seem to get any of my pattern matching code to work as I expect it to.
For example:
SELECT TOP 20 *
FROM table_name
WHERE variable_name IN ('XaKDG', 'XaKDH')
returns both XaKDG and XaKDH as expected.
However, when trying this:
SELECT TOP 5 *
FROM table_name
WHERE variable_name LIKE 'XaKD\[GH\]' escape '\'
I get the following errors:
ERROR '22025' 1315172
Illegal pattern match specified
Illegal ESCAPE sequence.
I am baffled, as the user guide states the following:
"To match any string starting with 0 through 4, followed by an uppercase letter, then a [, any two characters and a final ]:"
name like '\[01234\]\[A-Z\][__]' escape '\'
As far as I can tell, my query should be correct. I also tried without the escape characters at all, and with double escape characters. These didn't produce any errors, but also did not return anything.
I appreciate any help.
The User guide is here: https://supportactian.secure.force.com/help/servlet/fileField?id=0BEf3000000PLPf

BigQuery - Illegal Escape Sequence at REGEXP_REPLACE

I'm having an issue matching regular expression in BigQuery.
REGEXP_REPLACE(tc.metadata->>'document_number', '\D', '', 'g') = m.document_number
However, BigQuery doesn't seem to like escape sequences for some reason and I get this error that I can't figure out:
Syntax error: Illegal escape sequence: \D
This code works fine, but BigQuery is unhappy with it and I can't figure out why. Thanks in advance for the help
You need to double escape the the character in BigQuery, as the first / will be consumed by JavaScript.
Try double escaping, e.g. \\D and that should work for you.
In [1] if you scroll down you can see the escaping sequences of standard SQL and none is \D, so as Ben P says, you need to double escape to have the backslash escaping sequence. I assume it's what is missing but if you could elaborate further your question the answer would be indeed more accurate.
[1] https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#string_and_bytes_literals

PostgreSQL RETURNING fails with REGEXP_REPLACE

I'm running PostgreSQL 9.4 and are inserting a lot of records into my database. I use the RETURNING clause for further use after an insert.
When I simply run:
... RETURNING my_car, brand, color, contact
everything works, but if I try to use REGEXP_REPLACE it fails:
... RETURNing my_car, brand, color, REGEXP_REPLACE(contact, '^(\+?|00)', '') AS contact
it fails with:
ERROR: invalid regular expression: quantifier operand invalid
If I simply run the query directly in PostgreSQL it does work and return a nice output.
Tried to reproduce and failed:
t=# create table s1(t text);
CREATE TABLE
t=# insert into s1 values ('+4422848566') returning REGEXP_REPLACE(t, '^(\+?|00)', '');
regexp_replace
----------------
4422848566
(1 row)
INSERT 0 1
So elaborated #pozs suggested reason:
set standard_conforming_strings to off;
leads to
WARNING: nonstandard use of escape in a string literal
LINE 1: ...alues ('+4422848566') returning REGEXP_REPLACE(t, '^(\+?|00)...
^
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
ERROR: invalid regular expression: quantifier operand invalid
update
As OP author says standard_conforming_strings is on as supposed from 9.1 by default working with psql and is off working with pg-prommise
update from vitaly-t
The issue is simply with the JavaScript literal escaping, not with the
flag.
He elaborates further in his answer
The current value of environment variable standard_conforming_strings is inconsequential here. You can see it if you prefix your query with SET standard_conforming_strings = true;, which will change nothing.
Passing in a regEx string unescaped from the client is the same as using E prefix from the command line: E'^(\+?|00)'.
In JavaScript \ is treated as a special symbol, and you simply always have to provide \\ to indicate the symbol, which is what needed for your regular expressions.
Other than that, pg-promise will escape everything correctly, here's an example:
db.any("INSERT INTO users(name) VALUES('hello') RETURNING REGEXP_REPLACE(name, $1, $2)", ['^(\\+?|00)', 'replaced'])
To understand how the command-line works, prefix the regex string with E:
db.any("INSERT INTO users(name) VALUES('hello') RETURNING REGEXP_REPLACE(name, E$1, $2)", ['^(\\+?|00)', 'replaced'])
And you will get the same error: invalid regular expression: quantifier operand invalid.

How do you escape this regular expression?

I'm looking for
"House M.D." (2004)
with anything after it. I've tried where id~'"House M\.D\." \(2004\).*'; and there's no matches
This works id~'.*House M.D..*2004.*'; but is a little slow.
I suspect you're on an older PostgreSQL version that interprets strings in a non standards-compliant C-escape-like mode by default, so the backslashes are being treated as escapes and consumed. Try SET standard_conforming_strings = 'on';.
As per the lexical structure documentation on string constants, you can either:
Ensure that standard_conforming_strings is on, in which case you must double any single quotes (ie ' becomes '') but backslashes aren't treated as escapes:
id ~ '"House M\.D\." \(2004\)'
Use the non-standard, PostgreSQL-specific E'' syntax and double your backslashes:
id ~ E'"House M\\.D\\." \\(2004\\)'
PostgreSQL versions 9.1 and above set standard_conforming_strings to on by default; see the documentation.
You should turn it on in older versions after testing your code, because it'll make updating later much easier. You can turn it on globally in postgresql.conf, on a per-user level with ALTER ROLE ... SET, on a per-database level with ALTER DATABASE ... SET or on a session level with SET standard_conforming_strings = on. Use SET LOCAL to set it within a transaction scope.
Looks that your regexp is ok
http://sqlfiddle.com/#!12/d41d8/113
CREATE OR REPLACE FUNCTION public.regexp_quote(IN TEXT)
RETURNS TEXT
LANGUAGE plpgsql
STABLE
AS $$
/*******************************************************************************
* Function Name: regexp_quote
* In-coming Param:
* The string to decoded and convert into a set of text arrays.
* Returns:
* This function produces a TEXT that can be used as a regular expression
* pattern that would match the input as if it were a literal pattern.
* Description:
* Takes in a TEXT in and escapes all of the necessary characters so that
* the output can be used as a regular expression to match the input as if
* it were a literal pattern.
******************************************************************************/
BEGIN
RETURN REGEXP_REPLACE($1, '([[\\](){}.+*^$|\\\\?-])', '\\\\\\1', 'g');
END;
$$
Test:
SELECT regexp_quote('"House M.D." (2004)'); -- produces: "House M\\.D\\." \\(2004\\)

SQL LIKE Command trouble searching for '

Hi I am facing a problem with the like command in SQL,
I want to search for special characters within a column .
The special characters are a single quotation mark ' and { and }..
I have tried placing these special characters under [] but still it doesn't work for '
I have also used the except option but that was also of no help..
Waiting for a response soon
When you specify a value which has single quote, you need to double it.
SELECT *
FROM dbo.Northwind
WHERE Summary LIKE 'single''quotes%'
Try using this-
select * from <table> where <column> like '%''%'
SQL Server escaping is a pain because there are various ways to escape characters, each with different meaning and use case.
A single quote is escaped with another single quote: WHERE myfield LIKE '%''%'.
The general solution is to escape the special character like so:
SELECT .... WHERE my_column like '%\'%' ESCAPE '\'