Getting Issue when running migration but through console its works - ruby-on-rails-3

When i am running this query through migration it gives Error-
Query -
ActionEvent.includes([:historic_task_allocation, {:task_results =>[:task_result_status, :user]}]).where("action_events.ae_type = 0 AND action_events.result_status <> 2 AND task_result_statuses.is_completion AND users.id NOT IN (SELECT user_id FROM allocation_user_links aul WHERE aul.task_allocation_id = task_allocations.id AND aul.valid_from < action_events.date AND (aul.valid_to > action_events.date OR aul.valid_to IS NULL))")
Error -
Mysql2::Error: Unknown column 'task_allocations.can_complete_late' in
'field list':
But through console its work.
Where is the problem?

Resolved This Issue By just adding the below line in above the query in self.up methods.
TaskAllocation.reset_column_information # Resets all the cached information about columns, which will cause them to be reloaded on the next request.

Related

What changes need to do to work with rails 7 without postgres_ext

I am maintaining a rails 4.2.11 project and using postgres_ext as a dependency. Now as we are planning to update to rails 5 and higher. I noticed that postgres_ext is not maintained anymore and will not work with rails 5 and above. so I am getting this error in the following SQL query. It seems to be in the array IN query. How to fix it? What are more probable changes I have to do in my project?
[2023-01-25T09:10:33.409Z] 1) ChangeRequestActions::DestructionService#destroy_without_transaction when change request have more than one change request action delete action from change request
[2023-01-25T09:10:33.409Z] Failure/Error: company.sections.find_or_create_by(section)
[2023-01-25T09:10:33.409Z]
[2023-01-25T09:10:33.409Z] ActiveRecord::StatementInvalid:
[2023-01-25T09:10:33.409Z] PG::InvalidTextRepresentation: ERROR: malformed array literal: ""
[2023-01-25T09:10:33.409Z] LINE 1: ..."position" = $4 AND "sections"."block_titles" IN ('', 'Perso...
[2023-01-25T09:10:33.409Z] ^
[2023-01-25T09:10:33.409Z] DETAIL: Array value must start with "{" or dimension information.
[2023-01-25T09:10:33.409Z] : SELECT "sections".* FROM "sections" WHERE "sections"."company_id" = $1 AND "sections"."name" = $2 AND "sections"."title" = $3 AND "sections"."position" = $4 AND "sections"."block_titles" IN ('', 'Personal Employee Information', 'Employee W4 Form Request', 'VETS/EEO-1 Reporting', 'Asset & Equipment Management') ORDER BY sections.id LIMIT 1

Invalid procedure call error in MS Access Sum

I use the following SQL select query in MS Access to generate result on large input data:
SELECT "1.01" AS Item
,"Name" AS Test
,Count([Item]) AS [Count]
,Sum(IIf([Results] = "Invalid", 1, 0)) AS [# Invalid]
FROM [Test 1-01]
GROUP BY "1.01"
,"Name"
,"Yes";
I got an 'Invalid Procedure call' error. I traced down the part of the query that caused the error is
Sum(IIf([Results]="Invalid",1,0)) AS [# Invalid]
Does anyone have any idea of how to fix this error ?
#Sergery S. You're right. I found the problem was due to one damaged row data. It works fine again after I removed that row. Thahks again.

PostgreSQL : Operator does not exist: Integer < Interval

I have wrote a query so I can view people who are overdue an order based on their average order dates. The query is to be ran on a PostgreSQL database, and will be executed from a Java process.
However in the line :
CASE WHEN
(max(date_trunc('day', dateordered))-
min(date_trunc('day', dateordered)) ) /
count(distinct dateordered) + 5 <
date_trunc('day',now()) -
max(date_trunc('day', dateordered)) THEN 'ORDEROVERDUE' ELSE
null
END
I receive the error message :
Operator does not exist : integer < interval
I have read a lot of questions which have a similar issue, but none which seem to fix my particular issue.
If I alter my query to this :
CASE WHEN
(max(dateordered::date) - min(dateordered::date) )/
count(distinct dateordered) + 5 <
now()::date - max(dateordered::date) THEN
'ORDEROVERDUE' ELSE null
END
Then it runs on the database, however I can't get this syntax to work in my process in eclipse.
My understanding of SQL is letting me down. I understand the general reason behind the error, but I am unable to create a solution.
Is there a way of altering this line in a way which removes the error and I can still get the desired result?

ERROR - SQL Error '[Cache ODBC][State : S1000][Native Code 29]

I have been using the query below and it was working fine but now it's giving a SQL error.
There were no changes made that could cause this to stop working.
There is no Field 'APPLICATIONID' in the table.
QueueSQL=select distinct (convert(char(5),SkillsetID)+'='+Skillset) from iagentbySkillsetStat where ApplicationID > 10000
QueueMappingSQL=SELECT DISTINCT (convert(char(5),SkillsetID)+'='+Skillset), SkillsetID FROM iagentbySkillsetStat iagentbySkillsetStat WHERE (iagentbySkillsetStat.ApplicationID>10000)
DB- Intersystems Cache
Error details for the log files are below.
14/09/2016 11:20:05 a.m. > ERROR - SQL Error '[Cache ODBC][State : S1000][Native Code 29]
[C:\xlink\xlink Compiled Package\Xlink Application\Isps_Ul.exe]
[SQLCODE: <-29>:<Field not found in the applicable tables>]
[Cache Error: <<SYNTAX>errdone+2^%qaqqt>]
[Details: <Prepare>]
[%msg: < SQL ERROR #29: Field 'APPLICATIONID' not found in the applicable tables^select distinct ( convert ( char ( 5 ) , SkillsetID ) + :%qpar(1) + Skillset ) from iagentbySkillsetStat where ApplicationID >>]'
Question was also asked at InterSystems Developer Community, where I noticed that table names are different. So, the answer is, that table name is suddenly changed somehow.

IBMDB2 simple query error 901 - system error

I'm working on a IBM iseries v6r1m0 system.
I'm trying to execute a very simple query :
select * from XG.ART where DOS = 998 and (DES like 'ALB%' or DESABR like 'ALB%')
The columns are:
DOS -> numeric (3,0)
DES -> Graphic(80) CCSID 1200
DESABR -> Garphic(25) CCSID 1200
I get :
SQL State : 58004
SQL Code : -901
Message : [SQL0901] SQL System error.
Cause . . . . . : An SQL system error has occurred. The current SQL statement cannot be completed successfully. The error will not prevent other SQL statements from being processed. Previous messages may indicate that there is a problem with the SQL statement and SQL did not correctly diagnose the error. The previous message identifier was CPF4204. Internal error type 3107 has occurred. If precompiling, processing will not continue beyond this statement.
Recovery . . . : See the previous messages to determine if there is a problem with the SQL statement. To view the messages, use the DSPJOBLOG command if running interactively, or the WRKJOB command to view the output of a precompile. An application program receiving this return code may attempt further SQL statements. Correct any errors and try the request again.
If I change DES into REF (graphic(25)), it works...
EDIT :
I run some tests this afternoon, and it is very strange :
Just after the creation of the table/indexes, I have no errors.
If I insert some datas : error
If I clear the table : error
If I remove an index (see below) : it works (with or without datas)
!!
The index is :
create index XG.GTFAT_ART_B on XG.ART(
DOS,
DESABR,
ART_ID
)
Edit 2 :
Here is the job log (sorry, it is in French...)
It sais :
Function error X'1720' in machine instruction. Internal snapshot ID 01010054
Foo file created in library QTEMP.
*** stuff with the printer
DBOP *** FAILED open. Exception from call to SLIC$
Internal error in the query processor file
Sql system error
I finally contacted IBM.
It was an old bug from v5.
I have installed the latest PTF, and now, it works.
You need to use the GRAPHIC scalar function to convert your character literals on the LIKE predicate.
CREATE TABLE QTEMP/TEST (F1 GRAPHIC(80))
INSERT INTO QTEMP/TEST (F1) VALUES (GRAPHIC('TEST'))
SELECT * FROM QTEMP/TEST WHERE F1 LIKE GRAPHIC('TE%')
I know this guy got his problem fixed with an update. But here is something that worked for me that might work for the next guy here who has the problem.
My problem query had a lot of common table expressions. Most of them did not create tables with a whole lot of records. So if I figured that the maximum number of records a CTE would make was 1000, I added a "Fetch first 9999 rows only" to it. I knew that the CTE couldn't possibly have more rows than that. I guess the query optimizer had less to think about with that added.
If you have that problem and you don't have the option to upgrade or talk to IBM, I hope this help you.
For other people getting this errore, I encountered it on an IBM i Series v7r3, when tried an UPDATE, retrieving the value to be set on a field using a inner SELECT where multiple results where reduced to 1, using DISTINCT. I solved the problem removing DISTINCT and adding FETCH FIRST 1 ROW ONLY at the end of the inner SELECT.
E.g.: changed from
UPDATE MYTABLE AS T1
SET T1.FIELD1 = (
SELECT DISTINCT T2.FIELD5
FROM MYTABLE AS T2
WHERE T1.FIELD2 = T2.FIELD2
AND T1.FIELD3 = T2.FIELD3
)
WHERE T1.FIELD4 = 'XYZ'
to
UPDATE MYTABLE AS T1
SET T1.FIELD1 = (
SELECT T2.FIELD5
FROM MYTABLE AS T2
WHERE T1.FIELD2 = T2.FIELD2
AND T1.FIELD3 = T2.FIELD3
FETCH FIRST 1 ROW ONLY
)
WHERE T1.FIELD4 = 'XYZ'