Postgres update value with plus sign - postgresql

Can anyone please explain why this is failing?
testDB=# Update users set email = ‘Alex+check#test.com’ where id = 106;
ERROR: syntax error at or near "check"
LINE 1: Update users set email = ‘Alex+check#test.com’ where id = 1...

This might be a long shot but check your apostrophes. They look wrong.
Does this work if you cut/paste it?
Update users set email = 'Alex+check#test.com' where id = 106;
Your apostrophes: ‘foo‘
My apostrophes: 'foo'
It's subtle but I think you have some kind of unicode character instead of a simple '.

Related

SAP Unicode: Offset exceed

I got some account issues in the SCN so I make a attempt here.
We switched to Unicode and got some issues with that. INFTY_TAB = PS+2. This coding gets an error that "the offset + length is exceeding".
I found some hints but couldn't really figure out how to fix this. And even when I manage to fix those errors I got a new error called 'Iclude-Report %HR_P9002 not found'. The IT is still there so is there something else I can check?
Definition of PS:
DATA: BEGIN OF PS OCCURS 0.
*This indicates if a record was read with disabled authority check.
data: authc_disabled(1) type c.
DATA: TCLAS LIKE PSPAR-TCLAS.
INCLUDE STRUCTURE PRELP.
DATA: ACRCD LIKE SY-SUBRC.
DATA: END OF PS.
TCLAS is a char(1) field.
This is the part where the error pops up:
INFTY_TAB = PS+2.
Error: I had to translate so sorry for some mistakes that could appear.
Offset and Length (=2432) exceed the length of the character based beginning (=2430) of the structure.
Depends on the length of INFTY_TAB. You have to explicitly set length:
INFTY_TAB = PS+2(length).
Official information is here. The important point to note is that the inclusion of SY-SUBRC (which is an INT4 field) places a limit to the range of fields you can access using this (discouraged) method of access.
ASSIGN field+off TO is generally forbidden from a syntactical
point of view since any offset <> 0 would cause the range to be
exceeded.
Although the sentence above is related to ASSIGN command, it is also valid for this situation.

OpenEdge Progress 4GL Query returns (MISSING) after % sign

DEFINE TEMP-TABLE tt_pay_terms NO-UNDO
FIELD pt_terms_code LIKE payment_terms.terms_code
FIELD pt_description LIKE payment_terms.description.
DEFINE VARIABLE htt AS HANDLE NO-UNDO.
htt = TEMP-TABLE tt_pay_terms:HANDLE.
FOR EACH platte.payment_terms
WHERE (
active = true
AND system_id = "000000"
)
NO-LOCK:
CREATE tt_pay_terms.
ASSIGN
pt_terms_code = payment_terms.terms_code.
pt_description = payment_terms.description.
END.
htt:WRITE-JSON("FILE", "/dev/stdout", FALSE).
I have written this query and it returns data like this
[pt_terms_code] => 0.4%!N(MISSING)ET46
[pt_description] => 0.4%! (MISSING)DAYS NET 46
While I believe (from using a SQL query) that the data should be
0.4%45NET46
0.4% 45 DAYS NET 46
I'm making an assumption that the % is probably some special character (as I've run into similar issues in the past). I've tried pulling all the data from the table, and I get the same result, (ie, not creating a temp table and populating it with all the only the two fields I want).
Any suggestions around this issue?
I'm still very new to 4gl, so the above query might be terribly wrong. All comments and criticisms are welcome.
I suspect that if you try this:
FOR EACH platte.payment_terms NO-LOCK
WHERE ( active = true AND system_id = "000000" ):
display
payment_terms.terms_code
payment_terms.description
.
END.
You will see what the query actually returns. (WRITE-JSON is adding a layer after the query.) You will likely discover that your data contains something unexpected.
To my eye the "%" looks more like formatting -- the terms are likely 0.4%.
You then seem to have some issues in the contents of the description field. My guess is that there was a code page mismatch when the user entered the data and that there is gibberish in the field as a result.

mysql query not working - it's not selecting the table information

I have a query that is working in all my other php files but it will not work here. Can someone please look at what I have and let me know why the query is not selecting the fields?
Please keep in mind that $res is my database connection that's open, and all the table fields are spelled correctly to the table. I have tried not having those single quotes that are sideways and as you can see in the code I have tried it with them. I have also tried not having ' ' and have tried it with them. I can remark out the lines and the code works, but put them back live and the code stops working with no error given.
I don't know if this helps, but my PHP version is 5.3.3-40.el6_6
$result2 = mysqli_query($res, "SELECT pre_sponsor_sponsor, slid FROM `pres` WHERE `pre_sponsor` = '$spospo' AND `slid` = '$slid' AND `pre_id` <= '$pre_id' LIMIT 1");
$row2 = mysqli_fetch_array($result2)
$spospo = $row2[pre_sponsor_sponsor];
$slid = $row2[slid];
First of all you missed semicolon at line 3.
But I think you should write
$row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC);
Regards.
I see my problem after posting it here. I forgot the semi-colon after the $row2 = mysqli_fetch_array($result2) - it should have a ; after it.
Sorry for posting this.

how to replace all the email id records with progress 4gl

The problem here is I want to update the email ids, I want to update like user#abc.com to user#xyz.com
I have selected all the email ids like this,
for each table where
table.email matches "*" + "#abc.com" + "*" no-lock :
Display
I can't use replace function, since each email ids will be of different length.
Is it possible to change email ids like this ? Please share with me.
Replacing exactly "abc" with "xyz" is done like this:
/* You need to change NO-LOCK to EXCLUSIVE-LOCK if you want to update or change! */
FOR EACH table WHERE table.email MATHES"*" + "#abc.com" + "*" EXCLUSIVE-LOCK:
ASSIGN
table.email = REPLACE(table.email, "#abc.com", "#xyz.com").
END.
But maybe you need to elaborate your question or is this all you want to do?
About performance
This query wont be very fast. Matches does not utilize any indices so the entire table will be scanned.
On later versions of Progress you can add a TABLE-SCAN option. This will increase speed but not by a lot. If you do this you will have to remove the MATCHES expression in the query and do like this:
FOR EACH table EXCLUSIVE-LOCK TABLE-SCAN:
IF table.email MATCHES etcetera
END.
END.
If this is a one time thing to fix e-mail addresses perhaps it doesn't need to be that fast? If not I suggest you add a logical field to the table (table.fixed) and create an index with the field in it. Then you can very fast go through all not fixed records.
I tried myself, and I wrote like this, and it worked.
def var cmail1 as char.
def var cmail2 as char.
assign
cmail1 = "#abc.com"
cmail2 = "#xyz.com".
for each table where
exclusive-lock :
Assign
table.email = REPLACE(table.email, cmail1, cmail2).
but the performance is low. If you any alternate for this, please post.

T-SQL SELECT Statment to Exclude Text Between ( And ) Without Update or Variables

I'm wondering if this is possible, I have a messy set of first name data to work with, and it's shared by other applications so I don't want to run any update statements. But the data will sometime include an AKA such as:
Robert (AKA Bob)
And I am trying to get a clean data where it just says "Robert".
One way I thought of is to use a temp table then CHARINDEX for ( and ) then REPLACE what's between ( and ). This seems like a long winded way to do this.
Is there a smarter way?
EDIT: More examples of the data hell. Sometimes the parenthesis comes in the front or mixed up such as:
(Bill) William
Richard (Dick) Jr.
Untested:
FirstName = case when charindex('(AKA', FirstName) = 0
then FirstName
else substring(FirstName, 1, charindex('(AKA', FirstName)) end
If the noisy string pattern is unpredictable, better to use SQL CLR TVF(table value function), utilize C# code regex. Taking an xml as input parameter, which includes data you need to process, return a table with data processed.
Pieter got the ball rolling for me! Thank you for getting me started on the right track!
SELECT
CASE WHEN FirstName like '%)%'
THEN REPLACE(FirstName,
SUBSTRING(FirstName,CHARINDEX('(',FirstName),CHARINDEX(')',FirstName)-CHARINDEX('(',FirstName)+1),'')
ELSE FirstName END