I have an application that accepts an address and writes it to the db. I then want to take that address and convert it to something I can send through Google Maps, so I need to replace all the spaces with "+" symbols. I understand how to do that with a regex:
address.gsub(/\s/, "+")
And can create a variable that does it, voila. But I want the converted address to live in the DB as well, so it doesn't have to be processed every time. I'm not sure how I process that when I'm creating the entry to begin with and save it to the db as a separate entity ("gmapaddress" or something).
Thanks!
given a table name of rails_db_table and columns userid and gmapaddress and instance vars #gmapaddress and #userid it's as simple as
UPDATE rails_db_table
SET gmapaddress=#gmapaddress
WHERE userid=#userid
of course a more rails way of doing this is with active_record that allows a construct such as:
#user.update_attribute :gmapaddress, #gmapaddress
#user.save
Related
I have two tables in different databases. In a table A is the data, in the other table B are information for incremental load of the data from the first table. I want to load from table B and store the date of the last successful load from table A in a mapping variable $$LOAD_DATE. To achieve this, I read a date from table B and use the SETVARIABLE() function in a expression to set the $$LOAD_DATE variable. The port in which I do this is marked as output and writes into a dummy flat file. I only read on row of this source!
Then I use this $$LOAD_DATE variable in the Source Filter of the Source Qualifier of table A to only load new records which are younger than the date stored in the $$LOAD_DATE variable.
My problem is that I am not able to set the $$LOAD_DATE variable correctly. It is always the date 1753-1-1-00.00.00, which is the default value for mapping variables of the type date/time.
How do I solve this? How can I store a date in that variable and use it later in a Source Qualifiers source filter? Is it even possible?
EDIT: Table A has too much records to read them all and filter them later. This would be to expensive, so they have to be filtered at source filter level.
Yes, it's possible.
In the first map you have to initialize the variable, like this:
In first session configuration you have to define the Post-session on success variable assignment:
The second map (with your table A) will get the variable after this configuration of the session in Pre-session variable assignment:
It will work.
It is not possible to set a mapping variable and use it's value somewhere else in the same run, because, the variable is actually set when the session completes.
If you really want to implement it using mapping variables you have to create two mappings, one for setting the mapping variable and another for actual incremental load. You can pass a mapping variable value from one session to another in a workflow using a workflow variable. https://stackoverflow.com/a/26849639/2626813
Other solutions could be to use a lookup on B and a filter after that.
You can also write some scripts to query table B and modify the parameter file with the latest $LOAD_DATE value prior to executing the mapping.
Since we're having two different DBs, use two sessions. Get values in the first one and pass the parameters to the second one.
I need to do some operations on one collection and at the end store the result in another collection. Will be doing this via aggregation. Platform is node, mongoose, mongodb.
One of the required operations which I can't figure out is urlEncoding a particular field. The field can be constrained to only contain alphabets, numbers and spaces, so basically what I need to do is convert spaces to %20
Note that I need to do this while using node. I am pretty new in node, mongoose, mongodb, etc, so I'm not sure If I can run custom javascript code from node into mongoose or if that will be a good idea.
You can use encodeURIComponent() to url encode a string in javascript.
You could do this on all field values before storing them, but only if you're sure you'll never need the original value (the converse method, decodeuricomponent() may not always honor things such as case).
Alternatively, you could store the value 'as is', and use encodeURIComponent() when retrieving the value.
I'm using the PurchReqImport Service hosted out of the AOT. Everything is working in terms of the data I'm providing except for an error I mention in the subject.
I've looked at the DB, and it looks like what gets stored there is a record number in a user table. However, the interface will not accept a valid user name, nor a record number as valid.
I presume the value passed in line.Requisitioner is what the interface is looking at.
What data needs to be passed in this field?
You need to pass in a recid from the worker (HcmWorker) table.
This is foreign key field that must match the value in the associated table...you can see all of these in the AOT under the Table>Relations node.
Hope this helps!
I have a String Set attribute i.e SS in a dynamodb table. I need to scan the database to check the value present in the any one list of the items.
Which comparison operator should I use for this scan?
example the db has items like this:
name
[email1, email2]
phone
I need to search for a items containing a particular email say email1 alone not giving the entire tuple.
It seems like you are looking for the CONTAINS operator of Scan operation. It basically is the equivalent of in in Python.
This said, if you need to perform this often, you probably should de-normalize your data to make it faster.
For example, you could build a second table like this:
hash_key: name
range_key: email
Of course, you would have to maintain this index yourself and query it manually.
Can a SharePoint expert explain to me the ;# in data returned by the GetListItems() call to the Lists web service?
I think I understand what they are doing here. The ;# is almost like a syntax for making a comment... or better yet, including the actual data (string) and not just the ID. This way you can use either, but they are nicely paired together in the same column.
Am I way off base? I just can't figure out the slighly different use. For example
I have a list with:
ows_Author
658;#Tyndall, Bruno
*in this case the 658 seems to be an ID for me in a users table somewhere*
ows_CreatedDate (note: a custom field. not ows_Created)
571;#2009-08-31 23:41:58
*in this case the 571 seems to be an ID of the row I'm already in. Why the repetition?*
Can anyone out there shed some light on this aspect of SharePoint?
The string ;# is used as a delimiter by SharePoint's lookup fields, including user fields. When working with the object model, you can use SPFieldLookupValue and SPFieldUserValue to convert the delimited string into a strongly-typed object. When working with the web services, however, I believe you'll need to parse the string yourself.
You are correct that the first part is an integer ID: ID in the site user list, or ID of the corresponding item in the lookup list. The second part is the user name or value of the lookup column.
Nicolas correctly notes that this delimiter is also used for other composite field values, including...
SPFieldLookupValueCollection
SPFieldMultiColumnValue
SPFieldMultiChoiceValue
SPFieldUserValueCollection
The SPFieldUser inherits from the SPFieldLookup which uses the ;# notation. You can easily parse the value by creating a new instance of the SPFieldLookupValue class:
string rawValue = "1;#value";
SPFieldLookupValue lookupValue = new SPFieldLookupValue(rawValue);
string value = lookupValue.LookupValue; // returns value