How to get value from a specific row and column in MS ACCESS database? - visual-studio-2010

First, I don't have unique value to directly point out a value I want to retrieve, so there for, I cannot use the WHERE Statement. The reason for that, because I have a database where I constantly updated or deleted, so if I use WHERE statement I have to edit the code again.

Then do apply a unique value - add a field of data type AutoNumber or you will never get out of this mess.

Related

Informatica cloud: use field in pre/post sql commands

I am trying to delete a set of data in the target table based on a column (year) from the lookup in IICS (Informatica Cloud).
I want to solve this problem using pre/post sql commands but the constraint is I can't pass year column to my query.
I tried this:
delete from sample_db.tbl_emp where emp_year = {year}
I want to delete all the employees in a specific year i get from lookup return
For Ex:
I got year as '2019', all the records in table sample_db.tbl_emp containing emp_year=2019 must be deleted.
I am not sure how this works in informatica cloud.
Any leads would be helpful.
How are you getting the year value? A pre/post SQL may not be the way to go unless you need to do this as part of another transformation, i.e., before or after the transformation runs. Also, does your org only have ICDI, or also ICAI? ICAI may be a better solution depending on the value is being provided.
The following steps would help you achieve this.
Create an input-output parameter in your mapping.
Assign the result of your lookup in an expression transformation to the parameter using SetMaxVariable
Use the parameter in your target pre SQL as
delete from sample_db.tbl_emp where emp_year = $$parameter
Let me know if you have any further questions

SAP BODS - Getting PK violation from a Table Comparison

I want to read from a table, change a couple column values for a few lines in a query, then update those lines on the same table.
I'm using SAP BODS, and that's what I tried:
I was about to insert images but just found out I can't insert images until 10 rep.
Anyway, I created a DataFlow where I have the same table as source and target.
A query to filter (using where) and change values (using mapping). And then a Table Comparison (where I expected those lines to be set to update, in this particular case), set table name on first entry, then PK in 'input primary key' and then the two columns I want to change in 'Compare columns'. No other changes from default that I can recall.
Got no warnings on 'validate all', and on execution I receive an ORA-00001 for the PK.
So ... I thought the Table Comparison would try to update, but seems like it's trying to insert instead. I want to know what I'm doing wrong and how could I get the job to do those updates. Thanks in advance.
Ps. I did search SO before asking and didn't find anything relevant.
Ok
So, turns out I just found what's going on a few minutes after posting the question.
Wasn't sure if I should answer my own question and took a look at this Etiquette for answering your own question
and decided to come back here and answer my own question.
For some reason I got stuck thinking that it was something to do with the Table Comparison trying to insert a line with a PK that's already there, instead of doing the update I wanted.
But after going back to the job to take another look at the issue, it occurred to me that maybe the problem could be a duplicate in the incoming data set. Made a few adjustment to filter those, and voilĂ .

Why does DSUM work incorrectly in a Named Data Macro?

SUMMARY:
I am trying to use a named data macro with a DSUM to maintain a parents record's total of the child records. When I edit the child record the data macro does change the parent record, but the result seems to be based on the old value's of the current record.
DETAILS:
I have a database similar to the Northwind Database from Microsoft. A copy can be found at http://www.thetechmentors.com/freestuff/exerciseFiles/msAccess/DlookupDatamacroProblem2.zip.
It has tblOrder and tblOrderDetail. The tblOrder has a named data macro that is called in the tblOrderDetail's After Update data macro. The named data macro uses DSUM("Ext Price","tblOrderDetail", "Order ID" & #OrderID). The data macro runs, but the results seem to be based on the child record's old value.
I discovered a work around. Instead of using a DSUM I used a local variable and a "For Each Record In" Loop to calculate the correct sum.
While my work around works, I would still like to know why the DSUM approach did not work. Any help you can provide is much appreciated.

Where to store random values in Magento database

Where/how would I store a value in the Magento database, such as the last time a process ran?
I have an extension that updates data in the database, and I want to timestamp the last time that was run. Basically, is there a table with a key -> value pair that I can put anything into?
if you want to looking for tracking of scheduler/process than you can look into this plugin(http://www.magentocommerce.com/magento-connect/aoe-scheduler.html). If you want to store some smaller value than you can save it in config table with or without serialize data.
Mage::getModel('core/config')->saveConfig('MY_PROCESS_NAME', $value );

making a global variable and incrementing in function - CodeIgniter

I'm trying to make a global variable in my model to increment an id field in my mysql table, but CI won't allow me to make global variables.
I've searched around and people are mentioning having to create a library and declaring the global variable there, and then loading the library in the model and using the variable.
I understand that approach, but how/where would I be able to increment the variables value so that the next time it's called in a function it will be +1?
Thank you in advance for any help
edit: the thing I'm trying to do is whenever I insert a new row in a table, I want to continue on from the last entries id number i.e. last id number in the table is 9, I want to increment on from that number and make the new rows id number 10
If you're able to access the database through CI you can use the Active Record count_all() function.
From CI docs http://ellislab.com/codeigniter/user-guide/database/active_record.html
Permits you to determine the number of rows in a particular table.
Submit the table name in the first parameter. Example:
echo $this->db->count_all('my_table');
// Produces an integer, like 25
You would just get the number of rows in the table returned and add 1 for the row in your new entry.

Resources