coldfusion.tagext.sql.QueryParamTag$InvalidDataException: Invalid data value [Column Name] exceeds maxlength setting 20 - coldfusion

I have an email field.
<cfqueryparam cfsqltype="cf_sql_nvarchar" maxlength="200" value="#structform.Email#">
On insertion, when I supply 20 or fewer characters as input, then insertion goes successful but when I supply more than 20 characters, then I get an exception.
The cause of this output exception was that:
coldfusion.tagext.sql.QueryParamTag$InvalidDataException: Invalid data
value nisar.ahmad#usefp.org exceeds maxlength setting 20..
Given that in the database (SQL server) the length of this field is 200.
and the following insert query successfully run
Insert into table (Email) values ('ggggggggggggggggtttttttttttttttttttttttttttttggggggggggggggggg#gmail.com')
The input is greater than 20 charachetr.

May be some where else in your code you have the maxlength set. Also check the SQL where clauses. Please also check the max length attribute in the cfqueryparam. You may have explicitly defined it in your code.

Related

PowerBI custom combined column with Text.Combine and with embeded conditions leading to the insertion of different strings

I created a custom column in PowerBI, which concatenate columns.
I have the following:
Text.Combine({[Nip],[Nap],[Noup]]},"_")
However, I would like to have a specific text which change based on whether or not data is present in columns. I need to check if there is data in four columns. If there is data, a specific string of character should be inserted, if there is not, no data should be inserted.
I am trying to insert the outcome of the "IF"s, but there is some complexity, I have tried this, but this is not working, Power BI is telling me "Token Eof expected" :
If [Lapino] <> null or [Lapinou] <> null or [Werwolf] <> null or [Ciocolato] then
Text.Combine({[Nip],"Snoubadiuba",[Nap],[Noup]},"_")
else Text.Combine({[Nip],"BruttoCativo",[Nap],[Noup]},"_")
I believe this is as simple as changing your If to lowercase if. M code is case-sensitive.

How to show alert if user tries to save values, that are already present my table for my Oracle Apex Form based application

I have a form in my Oracle APEX based application, I want to have validation on submit button, so that the combination of two specific entries, if they already are present in the SQL table/View, I want to show an alert, like "The entry for this combination of values of A and B already exists, please enter correct values."
If those two specific entries are represented by two form items (e.g. :P1_ONE and :P2_TWO), then the validation procedure might be a function that returns error text, such as
declare
l_cnt number;
retval varchar2(200);
begin
select count(*)
into l_cnt
from your_table t
where t.column_one = :P1_ONE
and t.column_two = :P1_TWO;
if l_cnt > 0 then
retval := 'The entry for this combination already exists';
end if;
end;
The query itself might need to be modified, depending on what exactly you meant by describing the problem; that's the way I understood it.
Then you should have a unique constraint on the table, and let that validate incoming data.
Any violation of this constraint will have exception raised, which can be transformed within the APEX error handling procedure.

DynamoDB QuerySpec {MaxResultSize + filter expression}

From the DynamoDB documentation
The Query operation allows you to limit the number of items that it
returns in the result. To do this, set the Limit parameter to the
maximum number of items that you want.
For example, suppose you Query a table, with a Limit value of 6, and
without a filter expression. The Query result will contain the first
six items from the table that match the key condition expression from
the request.
Now suppose you add a filter expression to the Query. In this case,
DynamoDB will apply the filter expression to the six items that were
returned, discarding those that do not match. The final Query result
will contain 6 items or fewer, depending on the number of items that
were filtered.
Looks like the following query should return (at least sometimes) 0 records.
In summary, I have a UserLogins table. A simplified version is:
1. UserId - HashKey
2. DeviceId - RangeKey
3. ActiveLogin - Boolean
4. TimeToLive - ...
Now, let's say UserId = X has 10,000 inactive logins in different DeviceIds and 1 active login.
However, when I run this query against my DynamoDB table:
QuerySpec{
hashKey: null,
rangeKeyCondition: null,
queryFilters: null,
nameMap: {"#0" -> "UserId"}, {"#1" -> "ActiveLogin"}
valueMap: {":0" -> "X"}, {":1" -> "true"}
exclusiveStartKey: null,
maxPageSize: null,
maxResultSize: 10,
req: {TableName: UserLogins,ConsistentRead: true,ReturnConsumedCapacity: TOTAL,FilterExpression: #1 = :1,KeyConditionExpression: #0 = :0,ExpressionAttributeNames: {#0=UserId, #1=ActiveLogin},ExpressionAttributeValues: {:0={S: X,}, :1={BOOL: true}}}
I always get 1 row. The 1 active login for UserId=X. And it's not happening just for 1 user, it's happening for multiple users in a similar situation.
Are my results contradicting the DynamoDB documentation?
It looks like a contradiction because if maxResultSize=10, means that DynamoDB will only read the first 10 items (out of 10,001) and then it will apply the filter active=true only (which might return 0 results). It seems very unlikely that the record with active=true happened to be in the first 10 records that DynamoDB read.
This is happening to hundreds of customers that are running similar queries. It works great, when according to the documentation it shouldn't be working.
I can't see any obvious problem with the Query. Are you sure about your premise that users have 10,000 items each?
Your keys are UserId and DeviceId. That seems to mean that if your user logs in with the same device it would overwrite the existing item. Or put another way, I think you are saying your users having 10,000 different devices each (unless the DeviceId rotates in some way).
In your shoes I would just remove the filterexpression and print the results to the log to see what you're getting in your 10 results. Then remove the limit too and see what results you get with that.

Minimum date for WDDX

I recently had a User enter a data of 6/13/204. SQL Server 2008 happily stored the date. The date was later retrieved and serialized to WDDX. It was encoded as
<field name='BASECYCLEDATE'><dateTime>204-6-13T0:0:0-8:0</dateTime></field>
Later when I deserialized it, I get
WDDX packet parse error at line 1, column 8772..
Invalid date string 204-6-13T0:0:0-8:0.
...
614 : </cfscript>
615 :
616 : <cfwddx action = "wddx2cfml" input = "#qryLabel.Config#" output = "stDat">
My question is, what is the minimum date to deserialize dates in WDDX?
Edit:
To answer your original question, that encoded string is wrong. The serialized dates should be in ISO8601 format, meaning they should have four digit years. A cursory test suggests cfwddx rejects any non-four digit years ie years < 1000 or > 9999.
SQL Server stores the date as 0204.
No, sql server does not store dates as formatted strings. Internally, they are stored as numbers. Ignoring validation for a moment, the cause is strictly on the CF side. When serializing that date into a wddx string, CF fails to generate the leading zero required by ISO8601. So the resulting string 204-6-13T0:0:0-8:0 is malformed and that is why the deserialization fails. That said, since that date range is not valid for your application, you should probably add some validation to reject invalid values like that one.
SQL Server stores the date as 0204. Apparently ColdFusion converts 0204 into 204. If users start doing this often, I will add an additional check to the data coming in. If necessary, I will
<cfif year(basecyledate) LT 1000>
...
</cfif>

Validation to detect text in numeric field

I'm trying to prevent users crashing the create new product apex page. On the create page i have a text field:product_name and a numeric field: product_quantity.
Currently when they enter text in the product_quantity field and click 'Save' they get the following error:
Error processing validation.
ORA-01722: invalid number
I have investigated the error however i thought in Apex, if you selected a numeric field, it would detect whether the user entered text or numeric characters?
Is there a method to display a validation message if the user has entered text, it shouts, otherwise it enables the user to save the new entry?
UPDATE
I know why its happening but dont know how to solve it.
I recreated my page and it worked. I then added two pieces of validation in my page processing and when i then try it i get the error in my intial post. If i disable them it works again. The validation use NOT EXISTS to find whether the entered value already exists in the table before they add it.
If only the validation kicks in after looking whether a numerical value has been entered. I stopped the validation looking at an associated item, and turned off the 'when button pressed' but still no joy.
select 1 from MY_TABLE where column_name = :P6_TEXT_FIELD
Is there a way to run the text box validation (checking whether its text entered) before the validation i have created in the page processing?
That's the thing with validations: they all get executed and do not short-circuit. You can actually clearly see this happening when you debug the page.
In the case of a number field, you'd see it does not pass the number validation. But this does not stop validation. So your second validation will be run which uses the submitted value, but would obviously fail when you entered text for instance.
There are some work-arounds for that.
For example, you could change your NOT-EXISTS validation to a PLSQL function returning an error message and execute something like this (example):
DECLARE
v_test_nbr NUMBER;
v_check_exists NUMBER;
BEGIN
BEGIN
v_test_nbr := to_number(:P6_TEXT_FIELD);
EXCEPTION
WHEN OTHERS THEN
-- or catch 1722 (invalid number) and 6502 (char to number conversion error)
v_test_nbr := NULL;
END;
IF v_test_nbr IS NOT NULL
THEN
-- if v_test_nbr is not null then the field should be numerically valid
-- if it isn't then this code would be skipped and this validation
-- will not throw an error.
-- However, the previous validation will still fail when text is entered,
-- so this shouldn't matter.
BEGIN
SELECT 1
INTO v_check_exists
FROM my_table
WHERE column_name = :P6_TEXT_FIELD;
EXCEPTION
WHEN no_data_found THEN
v_check_exists := 0;
END;
IF v_check_exists = 1
THEN
RETURN 'A record with this key already exists';
END IF;
END IF;
RETURN NULL;
END;
HOWEVER - in this case, where you want to check for duplicate entries a better option may exist if you are at least on version 4.1. If your table has the correct constraints defined, then you would have a unique key defined on the field you are performing the not-exists on. This means that if you would not have this validation on the field, you would get an ora-00001 DUP_VAL_ON_INDEX error.
You could then use the error processing provided by apex to catch this error, and produce a user-friendly message.
You can find an example of how to use and implement this on the blog of Patrick Wolf of the apex development team:
apex-4-1-error-handling-improvements-part-1/
apex-4-1-error-handling-improvements-part-2/