Useful Oracle SQL syntax features for column updates

  1. Multiple Column Updates using IN clause:
UPDATE table_name
SET (col1, col2, col3) = 
    (SELECT val1, val2, val3 FROM source_table WHERE condition)
WHERE condition;
  1. MERGE statement for conditional updates/inserts:
MERGE INTO target_table t
USING source_table s
ON (t.key = s.key)
WHEN MATCHED THEN
    UPDATE SET t.col1 = s.col1, t.col2 = s.col2
WHEN NOT MATCHED THEN
    INSERT (col1, col2) VALUES (s.col1, s.col2);
  1. Using DEFAULT values in updates:
UPDATE employees
SET (salary, commission) = (DEFAULT, DEFAULT)
WHERE department_id = 90;
  1. Updating with RETURNING clause to get modified values:
UPDATE employees
SET salary = salary * 1.1
WHERE department_id = 20
RETURNING employee_id, salary INTO :emp_id, :new_salary;
  1. Using row constructor expression:
UPDATE table_name
SET (col1, col2) = (SELECT * FROM (VALUES (val1, val2)));
  1. Conditional updates using CASE:
UPDATE employees
SET salary = CASE 
    WHEN department_id = 10 THEN salary * 1.1
    WHEN department_id = 20 THEN salary * 1.2
    ELSE salary
END;
  1. Using WITH clause (Common Table Expression) in updates:
WITH avg_sal AS (
    SELECT dept_id, AVG(salary) avg_salary
    FROM employees
    GROUP BY dept_id
)
UPDATE employees e
SET salary = (
    SELECT a.avg_salary 
    FROM avg_sal a 
    WHERE e.dept_id = a.dept_id
)
WHERE condition;

These syntaxes are particularly useful when:

  • You need to update multiple columns at once
  • The update values come from another table or subquery
  • You want to perform conditional updates
  • You need to track what was updated
  • You're dealing with complex data transformations

Remember that while these features provide more elegant solutions, it's important to:

  1. Test performance with your specific data volumes
  2. Ensure the business logic is clear to other developers
  3. Consider maintainability of the code
  4. Check if indexes are being used effectively

Update your flutter app icons with a custom one

1. Prepare Your Icon Image

  • Create a square PNG image (preferably 1024x1024 pixels) for best quality

2. Use the flutter_launcher_icons Package

Add the package to your pubspec.yaml:

flutter pub add flutter_launcher_icons

3. Configure the Icons

Add this configuration to your pubspec.yaml file:

flutter_launcher_icons:
  android: true
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icon/app_icon.png"  # Path to your icon image
  adaptive_icon_background: "#FFFFFF"  # For Android adaptive icons (optional)

4. Run the Package

Run this command in your terminal:

flutter pub get
dart run flutter_launcher_icons

done!

网友语录 - 第31期 - 想要的东西要争取,不想要的东西要拒绝,感到不爽的事情要反击

这里记录我的一周分享,通常在周六发布。


为什么敢一直挑衅你?因为你一直表现的很软蛋。国家外交如此,个人交往也是。不要老拿实力当借口,当没有决心时,有实力也等于没实力


成功者因它成功,失败者因它失败。它是谁?它是你的习惯


mtfront 今天和朋友聊到了一些传统行业的人觉得厌班的一个原因是工作太 repetitive。只在科技行业干过的我确实完全没有意识到自己确实每天都在处理新的 challenge ,完全不会觉得工作 repetitive 这件事(厌班有别的理由)。

之前一直觉得科技行业不配 getting paid this much,因为做的东西也就是一些草台班子糊弄根本不高级没什么技术含量。但压根没想过可能很多别的工作真的是非常机械重复。从处理新的 challenge 这个角度来看,或许可能 maybe 这些草台班子 bullshit job 里还是有一丝丝含金量的?(not saying it's worth the pay though)

(很多解决方案不需要高级技术一样能甚至更好的解决用户的痛点。有价值的是解决方案不是科技含量。传统行业单调重复的解决方案很可能是不怕苦不怕累的机器人,但那个解决方案会直接导致大量工人失业,会更痛。是坏事也是好事。因为它会逼迫失业的人另找出路,而有些出路的结果会很好。)


郑芝麻『世界就是这样。哭什么呢,举杯吧各位!』 奥斯卡最佳女配得主尹汝贞说。

她的嗓音粗哑,问她是否被人嘲笑过?。 她说:“有过,但他们现在都去世了。那些嘲笑你的人迟早会挂的,又何必在意?!!”


Advice from a tree

  • Stand tall and proud
  • Go out on a limb
  • Remember your roots
  • Drink plenty of water
  • Be content with your natural beauty
  • Enjoy the view
…more

Introducing changesummary: A Git Change Summary Script

The changesummary script is a powerful tool for developers to quickly understand the key changes made between two Git commits. It leverages AI to analyze the diff and provide a concise summary of the modifications.

Functionality

The script takes one or two arguments: the start commit hash and an optional end commit hash. If the end commit hash is not provided, it defaults to HEAD.

Usage

To use changesummary, simply run it in your Git Bash terminal:

./changesummary <start_commit_hash> [<end_commit_hash>]

Example

./changesummary abc123 def456

Result:

The key changes between the specified commit hashes are:

* Renamed `TrmWithRiaSettlementPricingTask` to `TrmWithRiaDetailsPricingTask` and refactored its logic into a base class `TrmConfigPricingTaskBase`.
* Removed `RiaRawRateDataDecorator` and updated `TrmWithRiaDetailsPricingTask` to use `RiaRate` instead of `RiaRawRate`.
* Updated the `RequiredData` enum to remove `RiaRawRate` and updated the `TrmWithRiaDetailsPricingTask` to require `RiaRate`.
* Updated error codes and messages to reflect the changes.

These changes simplify the pricing task logic and improve maintainability.

Benefits

  • Provides a quick and meaningful summary of changes, saving time during code reviews.
  • Helps in understanding the impact of changes made between commits.
  • Easy to integrate into existing Git workflows.
  • Flexible comparison range with optional end commit hash.

By using changesummary, developers can streamline their code review process and focus on the most important changes.

here's the source code:

#!/bin/bash

# Check if commit hash is provided
if [ -z "$1" ]; then
    echo "Error: Commit hash is required as an argument."
    exit 1
fi

convert_to_uppercase() {
    # Enable case-insensitive matching
    shopt -s nocasematch
    
    if [[ $1 =~ ^(HEAD|FETCH_HEAD|ORIG_HEAD|MERGE_HEAD)(\~[0-9]+|\^[0-9]*)* ]]; then
        # Convert to uppercase
        echo "${1^^}"
    else
        # Return original string
        echo "$1"
    fi
    
    # Reset case-sensitivity to default
    shopt -u nocasematch
}

start_hash=$(convert_to_uppercase "$1")
end_hash=$(convert_to_uppercase "${2:-HEAD}")

# Define static prompt text
static_prompt=$(cat <<-END
Analyze the following code diff. Generate a concise summary (under 100 words) of the **key changes** made between the specified commit hashes. Present the changes in a bullet-point list format, focusing on the main modifications and their impact.
Code changes:
END
)

# Define model and system message variables
model="meta-llama/llama-4-maverick:free"
system_message="You are a programmer"

# Execute git diff and pipe its output to the AI model
git diff -w -b $start_hash..$end_hash | jq -R -s --arg model "$model" --arg system_content "$system_message" --arg static_prompt "$static_prompt" \
    '{
        model: $model,
        messages: [
            {role: "system", content: $system_content},
            {role: "user", content: ($static_prompt + .) }
        ],
        max_tokens: 16384,
        temperature: 0
    }' | curl -s --request POST \
        --url https://openrouter.ai/api/v1/chat/completions \
        --header "Authorization: Bearer $OR_FOR_CI_API_KEY" \
        --header "Content-Type: application/json" \
        --data-binary @- | jq -r '.choices[0].message.content'

网友语录 - 第 30 期 - 预测未来最好的方法是去创造未来。

这里记录我的一周分享,通常在周六发布。


萧覃含 不要因为熟悉而不珍惜。


老爷爷/学习汉语很开心 @shushuglad 不要为明天担心。明天自有明天的烦恼,今天的烦恼已经够多


所有人的焦虑都来自一个词:“怕来不及”。


懂是第一步,践行是第二步,只有第三步不需要努力,它是收获。丰收还是欠收就看你的前两步


被窝哲学家 在一起马上就9年了,我才习惯他几乎不口头表露心意这个事情。爱表达又直率的我一直默认,对方不说出口就是没有,不说想念就是不想、不说爱就是不爱。但我又确实接收到了实实在在的关心、照顾和珍视。好像有人的爱情就跟面包一样,我拿到手里就是我的了,面包确实也不会说话


一个人学会拒绝了,也就长大了。


求达即求信。信而不达,读者不能通过译文了解作者的真实意思,是假的忠于原文,还不如不译。


要让自己的人生道路越走越光明,需要改变的不是运气也不是社会,而是自己。所有的问题都出在自己身上。


…more