Better way of handling incorrect date format in a column with “char(10)” data type / TRY_CONVERT equivalent in PLSQL

I have a source table with below structure:

create table customer_info (customer_num    number,  birth_date      char(10)) 

Unfortunately the birth_date column data type is char(10) instead of date. Some example data for this table would be like below:

customer_num    |  birth_date         --------------------------------   1             |  2001/01/01               1             |  2010/01/01               1             |  2021/01/01                1             |  12hhhhuu6   --> Incorrect date             1             |  2001/01/01               1             |  2001/23/01  --> Incorrect date 

what I’ve done is writing a function to evaluate every single record and return it’s correct format but as you know , using a function for every single record is nod a good idea and it somehow kills performance. I was wondering if you could suggest a better way for this.

create or replace function new_to_date_en(d varchar2) return DATE is   v_date date; begin   select to_date(d,'yyyy/mm/dd' ) into v_date from dual;   return to_date(d,'yyyy/mm/dd');   exception when others then return to_dateto_date('2021/03/07', 'yyyy/mm/dd'); end;   

Using the function:

 select customer_num,         new_to_date_en(birth_date)  from customer_info; 

There is a way in T-SQL COALESCE(TRY_CONVERT(date, @date, 111), '2012-01-01'). Is there a similar way in oracle plsql?

Thanks in advance

Is incorrect what Thirsting Blade affirms that would be the rule without it? [closed]

By RAW:

"Thirsting Blade

Prerequisite: 5th level, Pact o f the Blade feature

You can attack with your pact weapon twice, instead of once, whenever you take the Attack action on your turn."

So, by RAW: If it says "instead", then otherwise (A.K.A. without that eldrich invocation) the rule would be: "You can attack with your pact weapon once whenever you take the Attack action on your turn."

But the "original" rule is not this, you can’t "attack with your pact weapon once whenever you take the attack action", actually, you can attack with your pact weapon once when you take the attack action AND choose to attack with your pact weapon. So, is incorrect what that invocation affirms that would be the rule without it?

MySQL: message “Incorrect key file for table” “try to repair it”

I’m using MySQL 5.7.10

I have a table like this, with 100M rows and a size of 16GB .

CREATE TABLE `my_table` (     `id` DOUBLE NOT NULL AUTO_INCREMENT,     `entity_id` DOUBLE NOT NULL,     `concept_id` VARCHAR(50) NOT NULL COLLATE 'utf8_spanish_ci',     `value` DOUBLE(15,6) NOT NULL,     `increment` DOUBLE(10,6) NULL DEFAULT NULL,     PRIMARY KEY (`id`),     INDEX `IDX_concept` (`concept_id`),     INDEX `IDX_entity` (`entity_id`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB ROW_FORMAT=DYNAMIC AUTO_INCREMENT=118166425 

Once a month, I execute:

ALTER TABLE my_table ENGINE=InnoDB; 

My intention is to defrag the table, so the data are put together and the size keeps as low as possible.

This time, it failed and the failure message is: "Incorrect key file for table ‘my_table’; try to repair it".

I have made the following steps:

  1. Create a table like this: my_table2.
  2. Use mysqldump to dump my_table data in a file.
  3. Replace the create and the inserts to be done in "my_table2".
  4. Execute the file. my_table2 is created and each row in my_table exists in my_table2.
  5. Execute ALTER TABLE my_table2 ENGINE=InnoDB;

And it failed too, with the same message "Incorrect key file for table ‘my_table2’; try to repair it".

How could I fix the error? Thank you.

EDIT 1: I have executed CHECK TABLE for both tables, and the result is status OK, for both of them.

Why am I getting this error: Incorrect syntax for definition of the table constraint

CREATE TABLE COMPUTER_ASSIGNMENT ( SerialNumber Int NOT NULL, EmployeeNumber Int NOT NULL, DateAssigned Date NOT NULL, DateReassigned Date NULL, CONSTRAINT SerialNumberPK PRIMARY KEY (SerialNumber, EmployeeNumber), REFERENCES COMPUTER (SerialNumber), CONSTRAINT SerialNumberFK FOREIGN KEY (SerialNumber, EmployeeNumber) REFERENCES EMPLOYEE (EmployeeNumber) );

Is it incorrect too say that this function problem cannot be in $FNP$?

Decision Problem: Is $ 2^k$ + $ M$ NOT a prime?

Function Variant: Output the non-prime result of $ 2^k$ + $ m$

We can consider, $ M$ = $ 0$ .

Proof that calculating 2^n requires 2^n digits as the result

Question

Is it true that a non-deterministic machine cannot output $ 2^n$ digits in polynomial time?

Does this mean that the problem is not in $ FNP$ ?

Is the DMG 3/4 cover diagram in 5e incorrect?

From page 250 and 251 of the DMG:

To determine whether a target has cover against an attack or other effect on a grid, choose a corner of the attacker’s space… trace imaginary lines from that corner to every corner of any one square the target occupies. If one or two of those lines are blocked by an obstacle (including another creature), the target has half cover…

grid diagrams taken from the DMG. The final diagram shows the construction lines provided in the DMG to determine cover (showing 3/4th cover) as well as the question askers own construction lines, superimposed showing it should be half cover.

It looks like they just chose the wrong corner. If the attacker was moved one square to the north it would be 3/4 cover. Or do you think they meant "choose the closest corner"?

Is it correct or incorrect to say that an input say $C$ causes an average run-time of an algorithm?

I was going through the text Introduction to Algorithm by Cormen et. al. where I came across an excerpt which I felt required a bit of clarification.

Now as far as I have learned that that while the Best Case and Worst Case time complexities of an algorithm arise for a certain physical input to the algorithm (say an input $ A$ causes the worst case run time for an algorithm or say an input $ B$ causes the best case run time of an algorithm , asymptotically), but there is no such physical input which causes the average case runtime of an algorithm as the average case run time of an algorithm is by it’s definition the runtime of the algorithm averaged over all possible inputs. It is something I hope which only exists mathematically.

But on the other hand inputs to an algorithm which are neither the best case input nor the worst case input is supposed to be somewhere in between both the extremes and the performance of our algorithm is measured on them by none other than the average case time complexity as the average case time complexity of the algorithm is in between the worst and best case complexities just as our input between the two extremes.

Is it correct or incorrect to say that an input say $ C$ causes an average run-time of an algorithm?

The excerpt from the text which made me ask such a question is as follows:

In context of the analysis of quicksort,

In the average case, PARTITION produces a mix of “good” and “bad” splits. In a recursion tree for an average-case execution of PARTITION, the good and bad splits are distributed randomly throughout the tree. Suppose, for the sake of intuition, that the good and bad splits alternate levels in the tree, and that the good splits are best-case splits and the bad splits are worst-case splits. Figure(a) shows the splits at two consecutive levels in the recursion tree. At the root of the tree, the cost is $ n$ for partitioning, and the subarrays produced have sizes $ n- 1$ and $ 0$ : the worst case. At the next level, the subarray of size $ n- 1$ undergoes best-case partitioning into subarrays of size $ (n-1)/2 – 1$ and $ (n-1)/2$ Let’s assume that the boundary-condition cost is $ 1$ for the subarray of size $ 0$ .

The combination of the bad split followed by the good split produces three sub- arrays of sizes $ 0$ , $ (n-1)/2 – 1$ and $ (n-1)/2$ at a combined partitioning cost of $ \Theta(n)+\Theta(n-1)=\Theta(n)$ . Certainly, this situation is no worse than that in Figure(b), namely a single level of partitioning that produces two subarrays of size $ (n-1)/2$ , at a cost of $ \Theta(n)$ . Yet this latter situation is balanced! Image

Tabled Value Function returns incorrect or no results

I recently learned of TVF’s and it seemed like it was exactly what I was looking for. I did my first attempt at one and it is not going well.

Here is my code:

USE [RMC_Tracker] GO /****** Object:    UserDefinedFunction [dbo].[TFV_Dashboard] 9:08:08 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO    Script Date: 4/13/2020  -------------------------------------------- Author:    John Clark Create date: 4/12/2020 Description: Returns a recordset for the RMC Tracker  ALTER FUNCTION [dbo].[TVF_Dashboad] ( -- Add the parameters for the function here @CompDate datetime = NULL  ) RETURNS TABLE AS RETURN ( -- Add the SELECT statement with parameter references here SELECT    dbo.ACTIVE.RECORD_ID, dbo.ACTIVE.CMD_ID, dbo.ACTIVE.EQUIPMENT, dbo.ACTIVE.EquipDes,            dbo.ACTIVE.CASREP,dbo.ACTIVE.[UPDATE], dbo.ACTIVE.TYAST,                dbo.ACTIVE.STATUS,dbo.ACTIVE.JCN, dbo.COMMANDS.Trigrpah  FROM      dbo.ACTIVE INNER JOIN dbo.COMMANDS ON dbo.ACTIVE.CMD_ID = dbo.COMMANDS.CMD ID   WHERE    (dbo.ACTIVE. RECCLS = @CompDate) ) 

I call this Function from within MS Access via a Pass Through Query:

SELECT * FROM dbo.TVF_DashBoard(default) 

It returns an empty set. What I am trying to do is create a simple Function that allows me to return a table that can be toggle based on whether a field (RECCLS) is either Null or Not Null.

Any assistance would be appreciated.

Proving a Greedy Algorithm is Incorrect by Providing Counter Example and Coming up with another correct algorithm

I want to come up with a counter example that proves the following greedy algorithm doesn’t work and give an alternative correct algorithm. The problem is I have an array of numbers and I want to reach the last element of the array in the minimum number of steps. At each step, I can move to any element with the same value, move forward one, or move backward one. The greedy criterion is to move furthest to the right as much as possible. For example, if we have array {1,2,3,4,1,5}, the algorithm will start at 1 move to 1 before the 5 then moves to 5 with number of steps of 2.

An an example of input instance that proves the given greedy algorithm wrong might be {1,2,1,3,2} where the given algorithm crosses the array in 3 steps whereas there is an optimal solution of moving from 1 to the second 2 right to last 2 in two steps. Now, what is a correct algorithm for solving this problem ?