Split string into variables(sqlserver) - delimiter

Any way to split below string using & as delimiter and store the result in five variables without using table variable in sqlserver
Input=11&12&13&14&15
output
a=11,b=12,c=13,d=14,e=15

Related

Lua, using table of strings as keys to call values from different tables

What I want
ores = {"Bauxite", "Coal", "Hematite"}
properties={["Bauxite"]={name="Bauxite", density=1.2808},["Coal"]={name="Coal" , density=1.3465},["Quartz"]={name="Quartz" , density=2.6498},["Hematite"]={name="Hematite" , density=5.0398}}
system.print(properties.ores[1].name)
system.print(properties.ores[1].density)
Should Output
Bauxite
1.2808
This is a recurrent question regarding indexing tables by a value rather than by a constant string. You're currently using ((properties.ores)[1]).name; this is not parsed as properties.(ores[1]).name as you seem to have expected. That's because . is always followed by an identifier - a constant string - which is used to index the table. table.key is just shorthand for table["key"] for keys matching [a-zA-Z_][a-zA-Z0-9_]*. If you want to dynamically index a table with some expression, you have to use table[expr].
To fix your code, simply do:
system.print(properties[ores[1]].name)
system.print(properties[ores[1]].density)

Filenet - How to get the Property values in Workflow group

I have 2 Filenet Workflows where the firstWF takes the userids and store it on document property as String separated by comma. What I want from my SecondWF is that it should take that userids and assign it to workflow group when secondWF launch. I think it could be possible if it would be any step except Launch step on SecondWF by converting String to array & then assign it to Workflow group but I am unsure how to do it at the Launch step of SecondWF.
to create a STRING data field dfA in WF2 to store the comma-separated string.
to mapping property from document to workflow launch step (expose dfA) using entry template (or you can use CREATE function in WF 1).
on Launch step property page -> Assignments tab, use the Expression Builder to parse dfA and prefix each cell value with '#' and append to your WfGrp (participants array type) field.
Done.

How can I prevent SQL injections during CSV uploads?

I've just started learning about Rails security, and I'm wondering how I can avoid security issues while allowing users to upload CSV files into our database. We're using Postgres' "copy from stdin" functionality to upload the data from the CSV into a temp table, which is then used for upserts into another table. This is the basic code (thanks to this post):
conn = ActiveRecord::Base.connection_pool.checkout
raw = conn.raw_connection
raw.exec("COPY temp_table (col1, col2) FROM STDIN DELIMITER '|'")
# read column values from the CSV line by line in the following format:
# attributes = {column_1: 'column 1 data', column_2: 'column 2 data'}
# line = "#{attributes.values.join('|')}\n"
rc.put_copy_data line
# wrap up copy process & insert into & update primary table
I am wondering what I can or should do to sanitize the column values. We're using Rails 3.2 and Postgres 9.2.
No action is required; COPY never interprets the values as SQL syntax. Malformed CSV will produce an error due to bad quoting / incorrect column count. If you're sending your own data line-by-line you should probably exclude a line containing a single \. followed by a newline, but otherwise it's rather safe.
PostgreSQL doesn't sanitize the data in any way, it just handles it safely. So if you accept a string ');DROP TABLE customer;-- in your CSV it's quite safe in COPY. However, if your application reads that out of the database, assumes that "because it came from the database not the user it's safe," and interpolates it into an SQL string you're still just as stuffed.
Similarly, incorrect use of PL/PgSQL functions where EXECUTE is used with unsafe string concatenation will create problems. You must use of format and the %I or %L specifiers, use quote_literal / quote_ident, or (for literals) use EXECUTE ... USING.
This is not just true of COPY, it's the same if you do an INSERT of the manipulated data then use it unsafely after reading it back from the DB.

FullTextIndex in NexusDB, How to tokenize the searchstring

We are using NexusDB for a small database. We have a table with a FulltextIndex defined on it.
The index is configured with the following options:
Character separator
ccPunctuationDash
ccPunctuationOther
The user enters a search text in an edit box, and then an SQL statement is constructed with the following WHERE clause (%s substituted with the Editbox.text of course):
WHERE CONTAINS(FullIdx, ''%s'')
When the user enters multiple words in the editbox this goes wrong as the two separate words should have been embedded in the WHERE clause like this:
WHERE CONTAINS(FullIdx, 'word1' and 'word2')
So i have to parse the textbox value, scan it for spaces and split the text at those points. That made me wonder if it was possible to parse the search text for every setting of the fulltextindex, using the actual definition of the fulltextindex to create the correct where clause.
So if ccPunctuationDash is enabled in the FulltextIndex definition, than the search text is also split on a '-'.
If you think of it, it is exactly the same process as when the index is created and all strings are tokenized ...
My question: what is the easiest way of tokenizing a searchstring according to the settings of a FUlltextIndex?
The easiest way is... to create an empty #temporary table with a string field, with the same fulltext index settings as your real table. Set the TnxTable.Options to include dsoAddKeyAsVariantField. Load the string to tokenize into the string field, then view the table indexed by the fulltext index. Presto, you get an extra field displayed, which is the sorted tokens. You can now iterate over the table to read the tokens.

Getting String Value when delimiter exists vb.net

I am working on finishing up a mvc 3 vb.net app... I have to parse about 2000 entries in a database and get the string value to the right of a " : " delimiter from one of the columns... Everything to the left I am not worried about but I need the value that is to the right of the colon for that item.. I have more issues involving needing to select string characters to the right or left of a delimiter... But if someone can show me how to achieve the above I can figure out the rest from there... Thanks again...
a example of the string is Jackson Smokehouse Fish Food:John Jacob JinggleHimer Schmit
I would want to eliminate the first part of the string or just select the second part and put it in a variable for later processing...
You could use string.Split(':') which will split your string into a string array. so you can just grab the string to the right. My VB is rusty:
Dim stringToRight as String
stringToRight = databaseString.Split("1"c)(1)
There are probably better ways, but this is straight forward.

Resources