Drupal 7 I need to change the sku directly in the commerce_product table and want to know if this is possible to do without creating a drush script - drupal-7

I need to change the sku directly in the commerce_product table and want to know if this is possible to do without creating a drush script.

This can be done by changing the same sku in both commerce_product & commerce_product_revision then truncating all of the cache tables.
UPDATE `commerce_product` SET `sku` = 456 WHERE `sku` = 123;
UPDATE `commerce_product_revision` SET `sku` = 456 WHERE `sku` = 123;

Related

1 variable with 2 different values QlikView LoadScript

I need to put 2 different values for 1 variable in the LoadScript of a report.
I am using the syntax with let -
LET Customer_name ='XXXX';
LET Customer_name ='YYYY';
But when I load data, I have data only for one customer but not the second one as well.
I solved the problem -
I created 2 variables -
LET Customer_name ='XXXX';
LET Customer_name2 ='YYYY';
and in the Load Script I called them in the WHERE CLAUSE with OR.
WHERE Customer_name = 'XXXX' OR Customer_name2 = 'YYYY';

using variables to create tasks in snowflake

I want to use variables while creating tasks in snowflake. Below for example:
Instead of this:
CREATE OR REPLACE TASK BEAST_DSC_SBX.DSC_STG.DTCI_DSC_R2O_AVAIL_INCREMENTAL_TRUNCATE
WAREHOUSE = 'BEAST_DSC_ADHOC_WH_SBX' SCHEDULE = '10 MINUTE' WHEN SYSTEM$STREAM_HAS_DATA('BEAST_DSC_SBX.KAFKA.DTCI_DSC_R2O_AVAIL_CHANGES') = True
AS
TRUNCATE TABLE BEAST_DSC_SBX.DSC_STG.DTCI_DSC_R2O_AVAIL_INCREMENTAL;
I want to use this:
SET STG_SCHEMA_NAME = 'BEAST_DSC_SBX.DSC_STG';
SET KAFKA_SCHEMA_NAME = 'BEAST_DSC_SBX.KAFKA';
CREATE OR REPLACE TASK $STG_SCHEMA_NAME.DTCI_DSC_R2O_AVAIL_INCREMENTAL_TRUNCATE
WAREHOUSE = $WAREHOUSE SCHEDULE = '10 MINUTE' WHEN SYSTEM$STREAM_HAS_DATA($KAFKA_SCHEMA_NAME'.DTCI_DSC_R2O_AVAIL_CHANGES') = True
AS
TRUNCATE TABLE $STG_SCHEMA_NAME.DTCI_DSC_R2O_AVAIL_INCREMENTAL;
I am getting errors while executing the above. is it even possible to variablize snowflake tasks? if yes, how?
You cannot create the task name with a combination of both text and variable in the Snowflake UI. That doesn't work.
The workaround is to use SnowSQL and use this format:
&{<variable>}_<TEXT>
Please refer to this KB article as an example: https://community.snowflake.com/s/article/How-to-use-variable-when-creating-user-account-in-Snowflake-UI-and-SnowSQL
In the KB article above, we show that you can combine the text and variable in the SnowSQL like so:
create USER &{DIV}_LOCAL_&{ENV}_ADMIN`
PASSWORD = '&passwd'
LOGIN_NAME = '&{DIV}_LOCAL_&{ENV}_ADMIN'
COMMENT = "&DIV &ENV local account admin user"
DISPLAY_NAME = '&{DIV}_LOCAL_&{ENV}_ADMIN'
FIRST_NAME = '&{DIV}_LOCAL_&{ENV}_ADMIN'
LAST_NAME = '&{DIV}_LOCAL_&{ENV}_ADMIN'
EMAIL = 'test#test.com'
MUST_CHANGE_PASSWORD = TRUE;
The example above is to create a user, you can adopt the SQL statement for creating a task.

Conditional Update Statement returning incorrect results on SQL Server 2012

I'm trying to update a table in SQL Server 2012 Management Studio. Rather than writing four separate Update statements, I'm attempting to see if it is possible to write one query that will update the same table for one column in four different ways depending on what the value of a column stores.
Assume I have a table called table_food with the following structure
|Customer|Preference|
+--------+----------+
|John |McDs |
|Div |KFC |
|Paul |KFC |
|Pablo |Wasabi |
My idea is to update the Preference column to new values and the query I had written was:
UPDATE table_food
SET Preference =
CASE WHEN Preference = 'McDs' Then 'Burger'
WHEN Preference = 'KFC' Then 'KingsMeal'
END
Now on my actual table, there are only 8 different options selected for preference and I just need two update 4. (I've just done two as an example above but I have four when statements...so just another two lines)
When I run the query it shows far more rows being affected and checking the results after I notice now there's only one option shown "Burger" with a count of 8 and all the other rows have been set to null. Is there something I'm missing?
That query will update every row on your table since it lacks a WHERE clause. And a CASE WHEN expression returns NULL if none of the WHEN conditions are true. You might want a query like:
UPDATE table_food
SET Preference =
CASE WHEN Preference = 'McDs' Then 'Burger'
WHEN Preference = 'KFC' Then 'KingsMeal'
END
WHERE Preference in ('McDs','KFC')
add else on your case statement.
UPDATE table_food
SET Preference =
CASE WHEN Preference = 'McDs' Then 'Burger'
WHEN Preference = 'KFC' Then 'KingsMeal'
ELSE Preference
END
or if you only want to update affected rows, you do update from
UPDATE table_food
SET Preference = t2.newPreference
FROM
(SELECT CASE WHEN Preference = 'McDs' Then 'Burger'
WHEN Preference = 'KFC' Then 'KingsMeal'
WHEN Preference = 'KFC1' Then 'KingsMeal1'
WHEN Preference = 'KFC'2 Then 'KingsMeal2'
END as newPreference, Preference
FROM table_food) t2
WHERE t2.Preference = table_food.Preference and coalesce(t2.newPreference, '') != ''

Oracle trigger implementation

I have to implement a trigger which would:
7) Show the DDL for how a trigger can be used to transfer all rental copies from a store being deleted from the Store information table to the central store
8) Show how this trigger can be extended to make
sure that the central store is never deleted from the database
So far I have done this:
CREATE OR REPLACE TRIGGER stores BEFORE DELETE ON stores FOR
EACH ROW BEGIN IF DELETING WHERE cvr = 123456789 THEN
Raise_Application_Error ( num => -20050, msg => 'You can
not delete Main Store.'); END IF; IF DELETING THEN
UPDATE store_id=123456789 ON movies WHERE isActive = 0 END
IF; END;
so main store is with cvr which is written, but it gives me a compilation error. Any help? Thanks in advance.
You have two errors in your code.
there is no "DELETING WHERE" expression, you have to use two boolean exceptions like this:
IF DELETING AND :old.cvr = 123456789 THEN...
:old.cvr refers to value of cvr column in deleted record
Syntax of UPDATE clause is
UPDATE table_name
SET column_name1 = value1,
column_name1 = value2
WHERE where_clause;
in your case probably somethink like this:
UPDATE movies
set store_id = 123456789
WHERE store_id = :old.cvr
I guess, I don't know required functionality

How to update the field value of specific's column in SQL Server using Query in one shot?

I have Imported Data Form XLS my CMS. but finally realize that it has wrong data without any Extension at the end of the data, in One of the column of the table, so now I want to change the column data of multiple rows based on specific ID? How to do that using single SQL Query?
I just want to add '.jpg' at the end on these data.
Image
UPDATE a
SET a.Imagepath = a.ImagePath + '.jpg'
FROM aspx_itemimages a
WHERE a.ItemId = yourid
Try this one -
UPDATE aspx_itemimages
SET ImagePath = ImagePath + '.jpg'
--WHERE itemid = 755
Try:
UPDATE ImagePath SET ImagePath = ImagePath + '.jpg'
According to your screenshot, some entries actually do end with .jpg. If you want to append .jpg only where it is absent, you could use a NOT LIKE predicate:
UPDATE aspx_itemimages
SET ImagePath = ImagePath + '.jpg'
WHERE ImagePath NOT LIKE '%.jpg'
;
That will also prevent you from adding the extension multiple times if you run the query again accidentally.
The above answers are correct but adding 2 strings returns 0, you will have to concat two strings.
here is the example:
UPDATE a
SET a.Imagepath = concat(ImagePath , '.jpg')
FROM aspx_itemimages a
WHERE a.ItemId = yourid
Best and Easiest way to do this...
"UPDATE aspx_itemimages
SET itempath = itempath +'.jpg'
WHERE itemid = 755 ";
Note: The Update doesn't generate a result set. If you want to know which records will be modified, first run a Select query that uses the same criteria. If the results are satisfactory, then run the update query.

Resources