Click here to Skip to main content
15,888,046 members
Home / Discussions / Database
   

Database

 
QuestionCreating Access database with VB6 Pin
Member 121949778-Dec-15 18:05
Member 121949778-Dec-15 18:05 
AnswerRe: Creating Access database with VB6 Pin
Mycroft Holmes8-Dec-15 20:46
professionalMycroft Holmes8-Dec-15 20:46 
GeneralRe: Creating Access database with VB6 Pin
Member 121949778-Dec-15 21:03
Member 121949778-Dec-15 21:03 
GeneralRe: Creating Access database with VB6 Pin
Mycroft Holmes9-Dec-15 1:23
professionalMycroft Holmes9-Dec-15 1:23 
AnswerRe: Creating Access database with VB6 Pin
CHill609-Dec-15 5:29
mveCHill609-Dec-15 5:29 
GeneralRe: Creating Access database with VB6 Pin
Member 121949779-Dec-15 21:18
Member 121949779-Dec-15 21:18 
GeneralRe: Creating Access database with VB6 Pin
CHill6010-Dec-15 5:23
mveCHill6010-Dec-15 5:23 
QuestionHow to update sequence in MySQL Pin
Jassim Rahma8-Dec-15 4:10
Jassim Rahma8-Dec-15 4:10 
Hi,

I have order_tier database and I am adding tiers by checking what's the max number then add 1 to it. Now I have a problem when deleting because if the order has 4 tiers then it should have from 1 to 4, if the user deleted tier 4 then it will be 1 to 3, if the user deleted tier 2 then tier 3 should be 2 and 4 should be 3.. By this I mean it should have always a sequence without a gap in the middle and it should move from the bottom so if user deleted tier 6 of 7 tier's order then tier 7 will be 6, etc.

How can I implement this in using PL/SQL in MySQL?
SQL
DECLARE param_last_tier INT;

IF EXISTS (SELECT tier_number FROM order_tiers WHERE order_id = param_order_id) THEN
BEGIN
    SET param_last_tier = (SELECT MAX(tier_number) FROM order_tiers WHERE order_id = param_order_id) + 1;
END;
ELSE
BEGIN
    SET param_last_tier = 1;
END;
END IF;

INSERT INTO order_tiers (order_id, tier_type, tier_number, created_user)
VALUES (param_order_id, param_tier_type, param_last_tier, param_created_user);

Thanks,
Jassim[^]

Technology News @ www.JassimRahma.com

AnswerRe: How to update sequence in MySQL Pin
CHill608-Dec-15 4:40
mveCHill608-Dec-15 4:40 
QuestionGiving access permissions to user webadminqa_iispool Pin
indian1434-Dec-15 12:23
indian1434-Dec-15 12:23 
AnswerRe: Giving access permissions to user webadminqa_iispool Pin
Mycroft Holmes4-Dec-15 13:03
professionalMycroft Holmes4-Dec-15 13:03 
AnswerRe: Giving access permissions to user webadminqa_iispool Pin
Richard Deeming7-Dec-15 1:34
mveRichard Deeming7-Dec-15 1:34 
QuestionHow to manage 1000 millions of record in Mysql database Pin
Member 120698693-Dec-15 20:28
Member 120698693-Dec-15 20:28 
AnswerRe: How to manage 1000 millions of record in Mysql database Pin
Richard MacCutchan3-Dec-15 22:44
mveRichard MacCutchan3-Dec-15 22:44 
AnswerRe: How to manage 1000 millions of record in Mysql database Pin
jschell4-Dec-15 12:39
jschell4-Dec-15 12:39 
QuestionSQL Linq, IQueryable, ToList, just get 1 result Pin
jkirkerx3-Dec-15 11:43
professionaljkirkerx3-Dec-15 11:43 
AnswerRe: SQL Linq, IQueryable, ToList, just get 1 result Pin
Richard Deeming4-Dec-15 1:17
mveRichard Deeming4-Dec-15 1:17 
GeneralRe: SQL Linq, IQueryable, ToList, just get 1 result Pin
jkirkerx4-Dec-15 7:04
professionaljkirkerx4-Dec-15 7:04 
QuestionReport View Error Pin
Member 121385253-Dec-15 1:55
Member 121385253-Dec-15 1:55 
QuestionRe: Report View Error Pin
Richard MacCutchan3-Dec-15 2:10
mveRichard MacCutchan3-Dec-15 2:10 
Questionhandle transaction without deadlock Pin
Member 106619971-Dec-15 5:03
Member 106619971-Dec-15 5:03 
AnswerRe: handle transaction without deadlock Pin
Afzaal Ahmad Zeeshan1-Dec-15 5:20
professionalAfzaal Ahmad Zeeshan1-Dec-15 5:20 
GeneralRe: handle transaction without deadlock Pin
Richard Deeming1-Dec-15 5:37
mveRichard Deeming1-Dec-15 5:37 
QuestionHELP ME ADD EXCEPTION Pin
VicPat25-Nov-15 2:14
VicPat25-Nov-15 2:14 
AnswerRe: HELP ME ADD EXCEPTION Pin
Mycroft Holmes25-Nov-15 12:04
professionalMycroft Holmes25-Nov-15 12:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.