UTF-8 coding question (what is the last unicode character) - utf-8

we are opening up our application to allow support for multiple languages. one of the problems we have encountered along the way is a feature we provide our customers. Imagine for a moment the user is presented with 3 fields.
All customers is a toggle
From Customer Name is a field they can type in
To Customer Name is a field they can type in.
what happens from the user experience standpoint is if you select all customers "from" and "to" are disabled
what happens in the code is if the customer selects "all customers" we look for all customer records that have customer names greater than or equal to "" (blank) and less than or equal to "}}}}}}}}}}}}" (which works fine in ANSI).
when we put a chinese character in the first letter of the name this does not work since the code for the Chinese glyph is greater than "}". Is there a character in UTF-8 that is "the last character" so I could replace it?
We are intending on supporting multiple languages so if the solution only works for Chinese it won't help us.
Thanks
Kevin

When "all customers" is selected run a query without any conditions on customer name.
Yes, this means a new, alternate path of execution. Yes, it's not "smart".
At the same time it will be a lot more readable and easier to troubleshoot later. KISS

Wouldn't it be simpler to create a base select statement with all other conditions and then add the from/to conditions based on whether the from/to fields were filled in or not? Something like this:
sql = "select a,b,c from users where c = 123";
if(!from.empty())
sql += " and name >= '" + from + "'";
if(!to.empty())
sql += " and name < '" + to + "'";

Why not use CUSTOMERNAME IS NOT NULL instead? That would allow any range of characters without worrying about what's the first and last character in any particular text encoding.

I would rework the logic of the application so that you don't have to search for the names of the customers in order to get references to them.
Simply add all customers to the list of customers if the "all customers" switch is toggled on.

Related

How to compare two columns in netsuite in a saved Search

I have two columns Vendor Account (in the bill) and the default payables account in the vendor record. We have some wrong postings and I want to create a saved search to control this.
I've isolated the account number and default account number, however i can't seem to create a formula column that compares them (with a case formula i.e)
Is it because one of the account columns might be in text? What are the problems that can be happening here?
Columns to be compared
Assuming that "Vendor Account" and "Vendor Payables Account" are both number/integer fields the following case statement should work. Be sure to replace the field ids to match your account.
CASE WHEN {VendorAccount}={VendorPayablesAccount} THEN 'T' ELSE 'F' END
If the fields are not number fields use the following:
CASE WHEN TO_NUMBER({VendorAccount}) = TO_NUMBER({VendorPayablesAccount}) THEN 'T' ELSE 'F' END

Referencing fields in BI Publisher RTF template conditional regions

I'm putting together a report in the BI Publisher Word .rtf plugin with very specific layout needs. One of those needs is the ability to switch company logos depending on parameters entered. I've been using conditional fields to selectively display each logo, but for some reason I can't reference data fields in the conditional code.
I've used these methods:
<?if: column_name = 'desired_value'?> [logo1] <?end if?>
<?choose:?><when: column_name = 'desired_value'?> [logo1] <?end when?>
Both of these methods seem to work when given raw values (i.e. instead of column_name = desired_value, I used 1=1 and it printed) but not when I use the name of the column I'm trying to compare.
For a more concrete example:
<?if: p_jno_in > 0?>
is always false, as if p_jno_in is null rather than having a value. (this variable represents the job number of the report and will never be null, even in my test data/sample xml.)
EDIT: Here is an example of what I've used, and the output.
If you host the image on the server, you can do all sorts of stuff with BI Publisher logic and concatenating an image path string. Make sure you or your DBA makes the path readable by BI Publisher. They can also map it to an FTP connection so you can edit/add images without being in Unix.
Insert any dummy placeholder image in RTF template (Insert Picture)
Right click on image and click “Edit Alt Text” and enter dynamic path. (See below for example)
url:{concat('${OA_MEDIA}/XX_LOGOS',/XML_PATH/LOGO_NAME,'_','small','.jpg')}
Other older versions of Word may have this data stored in the Size/AltText or Format Picture/Web menus
I looked around a bit and found the answer to my question. Turns out I was actually using the correct format the whole time! The issue was actually that I was referencing fields inside a for-each grouping, which I think might limit the scope. So, for example, if my BI Publisher data model has a query block A that has been split into two groups AA and AB, trying to reference a field from AA when you're in a for-each looping on an element from AB will not work.

Validate Oracle Column Names

In one scenario we are dynamically creating sql to create temp tables on-fly. There is no issue with table_name as it is decided by us however the column-names are provided by sources not in our control.
Usually we would check the column names using below query:
select ..
where NOT REGEXP_LIKE (Column_Name_String,'^([a-zA-Z])[a-zA-Z0-9_]*$')
OR Column_Name_String is NULL
OR Length(Column_Name_String) > 30
However is there any build in function which can do a more extensive check. Also any input on the above query is welcome as well.
Thanks in advance.
Final query based on below answers:
select ..
where NOT REGEXP_LIKE (Column_Name_String,'^([a-zA-Z])[a-zA-Z0-9_]{0,29}$')
OR Column_Name_String is NULL
OR Upper(Column_Name_String) in (select Upper(RESERVED_WORDS.Keyword) from V$RESERVED_WORDS RESERVED_WORDS)
Particularly not happy with character's like $ in column name either hence won't be using..
dbms_assert.simple_sql_name('VALID_NAME')
Instead with regexp I can decide my own set of character's to allow.
This answer does not necessarily offer either a performance or logical improvement, but you can actually validate the column names using a single regex:
SELECT ...
WHERE NOT
REGEXP_LIKE (COALESCE(Column_Name_String, ''), '^([a-zA-Z])[a-zA-Z0-9_]{0,29}$')
This works because:
It uses the same pattern to match columns, i.e. starting with a letter and afterwards using only alphanumeric characters and underscore
NULL column names are mapped to empty string, which fails the regex
We use a length quantifier {0,29} to check the column length directly in the regex
" is there any build in function which can do a more extensive check."
Oracle has the DBMS_ASSERT.SIMPLE_SQL_NAME() function. This returns the passed name if it meets the Oracle naming rules ...
select dbms_assert.simple_sql_name('VALID_NAME') from dual;
... and hurls ORA-44003 if the name is invalid.
Valid names permit any characters if the name is double-quoted (yuck, but then so is creating "temp tables on-fly"). Also the function doesn't check the length of the name, so you will still need to validate that yourself.
Find out more in the docs.
Also here is a SQL Fiddle.
"creating a table with comment column is not possible as its a invalid identifier"
Fair point. DBMS_ASSERT is primarily aimed at preventing SQL injection. So it verifies that a value conforms to Oracle's naming rules, not that the value is a valid Oracle name. To catch things like comment you will also need to check the value against V$RESERVED_WORDS, probably where reserved != 'Y'. As this is a V$ view select on it is not granted by default; if you don't have access you'll need to ask your friendly DBA to help out.
" For validating column names I believe I should check with the entire list"
Up to you. The distinction is that some keywords can legitimately be used as identifiers. For instance TYPE only became a reserved word in Oracle version 8 when they introduced the object-relational stuff. But there were a lot of tables and views in existing systems which used 'TYPE' as a column name (not least the Oracle data dictionary). If Oracle had made TYPE a properly reserved word it would have broken all those systems. So the list of reserved words which cannot be used as identifiers is a sub-set of all the Oracle keywords.
Opinions on the general task:
"we are getting data from external sources (files) and the job of the program/script is to push that data to oracle tables."
There are two parts to this task.
The first is that you should have agreed a standard format for these files with the third parties. There should be no need for discovery of the files' structure or content. (Or if there is such a need because the files are randomly sourced from a carousel of third parties probably you should not be using a relational database but something else: Endeca? Python Pandas library?)
The second is the creating tables on the fly. If you have an agreed file structure then you should be loading into standard tables, using either SQL*Loader or external tables according to your circumstances. If you're on 12c maybe SQL*Loader Express Mode could be of interest.

Concatenating two values then update to one field

I am new person in salesforce can you please help me .
I have one custom filed opportunityName this is auto number field,In this field i have to add two fields values those two are pick list fields. (Like:opportunityName-field1-field2)
Thanks,
Autonumber fields are generated by the system and that's it. You can change their format (to include some prefix or dates, so you could have OPP-00123 or OPP-2013-05-01). They won't allow you to use pieces of other fields though, they'll be always just that - number with some (identical) formatting applied to it.
If your field should be always calculated and not directly writeable for your users - I'd suggest a formula field. If what you're after has to offer option of changing (for example for System Administrators) - then probably a text field + workflow would field update would be best.
You can read more about field types & workflows by simply going to "Help & Support" in your Salesforce instance. You can also go to Customize -> Opportunities -> Fields (or Create -> Workflow Rules) and hit "Help for this page" link in the upper right corner.
The formula (which can be either used directly in the formula field or as part of the workflow) will most likely look like Name + '-' + TEXT(Field1__c) + '-' + TEXT(Field2__c).
So - now you should at least have some keywords you can use to search for solutiions :) If you're a new System Administrator I strongly recommend going through some of the youtube videos and online trainings they've provided in "Help & Training".

Split a Value in a Column with Right Function in SSIS

I need an urgent help from you guys, the thing i have a column which represent the full name of a user , now i want to split it into first and last name.
The format of the Full name is "World, hello", now the first name here is hello and last name is world.
I am using Derived Column(SSIS) and using Right Function for First Name and substring function for last name, but the result of these seems to be blank, this where even i am blank. :)
It's working for me. In general, you should provide more detail in your questions on places such as this to help others recreate and troubleshoot your issue. You did not specify whether we needed to address NULLs in this field nor do I know how you'd want to interpret it so there is room for improvement on this answer.
I started with a simple OLE DB Source and hard coded a query of "SELECT 'World, Hello' AS Name".
I created 2 Derived Column Tasks. The first one adds a column to Data Flow called FirstCommaPosition. The formula I used is FINDSTRING(Name,",", 1) If NAME is NULLable, then we will need to test for nullability prior to calling the FINDSTRING function. You'll then need to determine how you will want to store the split data in the case of NULLs. I would assume both first and last are should be NULLed but I don't know that.
There are two reasons for doing this in separate steps. The first is performance. As counter-intuitive as it sounds, doing less in a derived column results in better performance because the SSIS engine can better parallelize the operations. The other is more simple - I will need to use this value to make the first and last name split so it will be easier and less maintenance to reference a column than to copy paste a formula.
The second Derived Column is going to actually perform the split.
My FirstNameUnicode column uses this formula (FirstCommaPosition > 0) ? RTRIM(LTRIM(RIGHT(Name,FirstCommaPosition))) : "" That says "If we found a comma in the preceding step, then slice out everything from the comma's position to the end of the string and apply trim operations. If we didn't find a comma, then just return a blank string. The default string type for expressions will be the Unicode (DT_WSTR) so if that is not your need, you will need to cast the resultant into the correct string codepage (DT_STR)
My LastNameUnicode column uses this formula (FirstCommaPosition > 0) ? SUBSTRING(Name,1,FirstCommaPosition -1) : "" Similar logic as above except now I use the SUBSTRING operation instead of RIGHT. Users of the 2012 release of SSIS and beyond, rejoice fo you can use the LEFT function instead of SUBSTRING. Also note that you will need to back off 1 position to remove the comma.

Resources