Mcode= Table.ReplaceValue(#"Renamed Columns2", each if Text.Contains([Rate_Card.Payee],"Financial Services") and [Externalidinvestorlevel] = null then null else [Rate_Card.Payee]
Error Message:
Expression.SyntaxError: Token RightParen expected.
I think maybe you want to do this
Mcode= Table.ReplaceValue(#"Renamed Columns2",
each [Rate_Card.Payee],
each if Text.Contains([Rate_Card.Payee],"Financial Services")
and [Externalidinvestorlevel] = null
then null else [Rate_Card.Payee]
,Replacer.ReplaceValue,{"Rate_Card.Payee"})
in #"Replaced Value"
Related
I am trying to run the query in power query editor and it failed with below error
where as the same query works fine in winserver 2016 and it fails with above error in win server 2019. Am I missing any thing ?
I did compared the settings and everything looks good.
let
//Get data Report H1
Source1 = Excel.Workbook(File.Contents("\\path\filename.xlsx"), null, true),
#"classic_Sheet1" = Source1{[Item = "classic", Kind = "Sheet"]}[Data],
#"Trimmed Text1" = Table.TransformColumns(#"classic_Sheet1", Text.Trim),
#"Third Row as Header1" = Table.PromoteHeaders(Table.Skip(#"Trimmed Text1", 2)),
#"Selected Columns1" = Table.SelectColumns(
#"Third Row as Header1",
{" ID", " Status", "Customer Id ", "Agent", "Leg"}
),
//Get Report H2
Source2 = Excel.Workbook(File.Contents("\\path\filename.xlsx"), null, true),
#"classic_Sheet2" = Source2{[Item = "classic", Kind = "Sheet"]}[Data],
#"Trimmed Text2" = Table.TransformColumns(#"classic_Sheet2", Text.Trim),
#"Third Row as Header2" = Table.PromoteHeaders(Table.Skip(#"Trimmed Text2", 2)),
#"Selected Columns2" = Table.SelectColumns(
#"Third Row as Header2",
{" ID", "Status", "Customer Id ", "Agent", "Leg"}
)
in
#"Excluded IDs"
The error message is pointing you to the problem:
Table.TransformColumns expects a list as the second parameter,
while you are providing a function:
Table.TransformColumns(
table as table,
transformOperations as list,
optional defaultTransformation as nullable function,
optional missingField as nullable number
) as table
Please read the official documentation here:
https://learn.microsoft.com/en-us/powerquery-m/table-transformcolumns
The issue has nothing to do with winserver 2016 or winserver 2019.
You want something along these lines
= Table.TransformColumns(#"classic_Sheet1",{{"ColumnNameHere", Text.Trim, type text}})
= Table.TransformColumns(#"classic_Sheet1"",{{"ColumnNameHere", Text.Trim, type text}, {"DifferentColumnNameHere", Text.Trim, type text}})
This program compiles correctly, we are on V7R3 - but when running it receives an SQLCOD of -101 and an SQLSTATE code is 54011 which states: Too many columns were specified for a table, view, or table function. This is a very small JSON that is being created so I do not think that is the issue.
The RPGLE code:
dcl-s OutFile sqltype(dbclob_file);
xfil_tofile = '/ServiceID-REFCODJ.json';
Clear OutFile;
OutFile_Name = %TrimR(XFil_ToFile);
OutFile_NL = %Len(%TrimR(OutFile_Name));
OutFile_FO = IFSFileCreate;
OutFile_FO = IFSFileOverWrite;
exec sql
With elm (erpRef) as (select json_object
('ServiceID' VALUE trim(s.ServiceID),
'ERPReferenceID' VALUE trim(i.RefCod) )
FROM PADIMH I
INNER JOIN PADGUIDS G ON G.REFCOD = I.REFCOD
INNER JOIN PADSERV S ON S.GUID = G.GUID
WHERE G.XMLTYPE = 'Service')
, arr (arrDta) as (values json_array (
select erpRef from elm format json))
, erpReferences (refs) as ( select json_object ('erpReferences' :
arrDta Format json) from arr)
, headerData (hdrData) as (select json_object(
'InstanceName' : trim(Cntry) )
from padxmlhdr
where cntry = 'US')
VALUES (
select json_object('header' : hdrData format json,
'erpReferenceData' value refs format json)
from headerData, erpReferences )
INTO :OutFile;
Any help with this would be very much appreciated, this is our first attempt at creating JSON for sending and have not experienced this issue before.
Thanks,
John
I am sorry for the delay in getting back to this issue. It has been corrected, the issue was with the "values" statement.
This is the correct code needed to make it work correctly:
Select json_object('header' : hdrData format json,
'erpReferenceData' value refs format json)
INTO :OutFile
From headerData, erpReferences )
I have a MySQL expression that uses a conditional IF statement. As a MySQL expression, it returns TRUE or FALSE, but when I use it in CodeIgniter's query builder, I get an error. The error suggests that the outcome of the conditional is reading like a column, but how can I fix this? Thanks.
MySQL:
SELECT
positions.max_vol AS attendee_limit,
COUNT(users_positions.user_id) AS total_attendees,
IF(COUNT(users_positions.user_id) < positions.max_vol
OR positions.max_vol IS NULL,
TRUE,
FALSE) AS result
FROM
positions
INNER JOIN
users_positions ON positions.id = users_positions.position_id
WHERE
positions.id = 16
AND users_positions.calendar_date = '2016-09-05'
Function:
private function check_attendee_limit($pos_id = NULL, $date = NULL)
{
$this->db->select('positions.max_vol, COUNT(users_positions.user_id), IF(COUNT(users_positions.user_id) < positions.max_vol OR positions.max_vol IS NULL, TRUE, FALSE)');
$this->db->from('positions');
$this->db->join('users_positions', "positions.id = users_positions.position_id", 'inner');
$this->db->where('positions.id', $pos_id);
$this->db->where('users_positions.calendar_date', $date);
$query = $this->db->get();
return $query->result(); // return the rows selected
}
Error:
A Database Error Occurred
Error Number: 1054
Unknown column 'TRUE' in 'field list'
SELECT `positions`.`max_vol`, COUNT(users_positions.user_id), IF(COUNT(users_positions.user_id) < positions.max_vol OR positions.max_vol IS NULL, `TRUE`, FALSE)
FROM `positions`
INNER JOIN `users_positions` ON `positions`.`id` = `users_positions`.`position_id`
WHERE `positions`.`id` = '15'
AND `users_positions`.`calendar_date` = '2016-09-05'
Filename: models/projects/Calendar_model.php
Line Number: 141
CI adds backticks - which means you've to prevent CI from escaping your select
Try this instead
$this->db->select('positions.max_vol, COUNT(users_positions.user_id), IF(COUNT(users_positions.user_id) < positions.max_vol OR positions.max_vol IS NULL, TRUE, FALSE)', false);
If you are worry about security - in your case it doesn't matter because you don't use any user input in your select query.
You can find more informations about the Query Builder here
The table I'm working with has these weird coded times, I'm trying to format them. The error I'm getting is "Missing Keyword". TRANS_NUMBER is a string of numbers that I need reformat.
CASE POST_TIME.TRANS_NUMBER
WHEN '' THEN ''
WHEN NULL THEN ''
WHEN SUBSTR(POST_TIME.TRANS_NUMBER,10,1) =':' THEN CONCAT('0', SUBSTR(POST_TIME.TRANS_NUMBER,9,1))
ELSE SUBSTR(POST_TIME.TRANS_NUMBER,9,2)
END AS "POSTED_HOUR",
CASE POST_TIME.TRANS_NUMBER
WHEN '' THEN ''
WHEN NULL THEN ''
WHEN SUBSTR(POST_TIME.TRANS_NUMBER,12,1) =':' THEN CONCAT( CONCAT( '0', SUBSTR(POST_TIME.TRANS_NUMBER,11,1) ), CONCAT(' ', SUBSTR(POST_TIME.TRANS_NUMBER,13,2) ) )
ELSE CONCAT( CONCAT( '0', SUBSTR(POST_TIME.TRANS_NUMBER,11,2) ), CONCAT(' ', SUBSTR(POST_TIME.TRANS_NUMBER,13,2) ) )
END AS "POSTED_MINUTE"
You're mixing up the syntax for simple and searched CASE statements which is why you're getting the error.
You can rewrite this as:
CASE WHEN POST_TIME.TRANS_NUMBER IS NULL THEN NULL
WHEN SUBSTR(POST_TIME.TRANS_NUMBER,10,1) = ':' THEN '0'||SUBSTR(POST_TIME.TRANS_NUMBER,9,1)
ELSE SUBSTR(POST_TIME.TRANS_NUMBER,9,2)
END AS "POSTED_HOUR",
CASE WHEN POST_TIME.TRANS_NUMBER IS NULL THEN NULL
WHEN SUBSTR(POST_TIME.TRANS_NUMBER,12,1) =':' THEN '0'||SUBSTR(POST_TIME.TRANS_NUMBER,11,1)||' '||SUBSTR(POST_TIME.TRANS_NUMBER,13,2)
ELSE '0'||SUBSTR(POST_TIME.TRANS_NUMBER,11,2)||' '||SUBSTR(POST_TIME.TRANS_NUMBER,13,2)
END AS "POSTED_MINUTE"
N.B. I've replaced each of your CONCAT()s with the more common and (IMHO) easily read ||
Plus the above is untested, since you didn't provide any example data for us to test with.
ETA: You don't even need to explicitly handle the case when POST_TIME.TRANS_NUMBER is null, as SUBSTR() of a null value returns null.
Your 3rd when should be nested case:
CASE POST_TIME.TRANS_NUMBER
WHEN '' THEN ''
WHEN NULL THEN ''
else
case WHEN SUBSTR(POST_TIME.TRANS_NUMBER,10,1) =':' THEN CONCAT('0', SUBSTR(POST_TIME.TRANS_NUMBER,9,1))
ELSE SUBSTR(POST_TIME.TRANS_NUMBER,9,2)
end
END AS "POSTED_HOUR",
I started a new database named GREEN.db with one TABLE defined as followed:
CREATE TABLE articles(
"articleID" serial NOT NULL,
"articleTitle" character varying(21) NOT NULL,
"articleContent" text NOT NULL,
"articleAuthor" character varying(7) NOT NULL ,
"articleTime" timestamp without time zone DEFAULT now(),
CONSTRAINT articles_pkey PRIMARY KEY ("articleID")
)
And my code was written as followed:
db = web.database(dbn='postgres', db='green',user='YOng',password='xxx')
......
i = web.input()
t = time.localtime(time.time())
st = time.strftime("%Y-%m-%d %H:%M:%S", t)
datas = list(db.query("""SELECT * FROM articles ORDER BY "articleID" DESC"""))
n = db.insert("articles",
articleID=len(datas)+1, \
articleTitle=i.post_title, \
articleContent=i.post_content, \
articleAuthor="YOng", \
articleTime=st)
web.seeother('/')
The error threw out saying:
psycopg2.ProgrammingError: column "articleid" of relation "articles"
does not exist LINE 1 : INSERT INTO articles (articleTitle,
articleAuthor, articleID... ^
I don't know what happened to this code. Does Anyone have any suggestion? Any help appreciated~
Perhaps because of the uppercase letters?
the Error is :
column "articleid" of relation "articles" does not exist
your column name is "articleID"