All posts by Social marketing master

Warn when returning const copy of object

Look at the function declarations below:

int Foo();        // [1] Ok
const int &Foo(); // [2] Ok
const int Foo();  // [3] Not Ok. Same as [1]. Compiler can warn.

Bar Foo();        // [4] Ok
const Bar &Foo(); // [5] Ok
const Bar Foo();  // [6] Ok, not same as [4] or [5], but more likely a typo then intended design.

Is it possible to ask Clang and/or GCC to warn about [5]?

I know this is legal, but I don’t think it is very useful. I am pretty sure that all declarations like this in our code base are typos, and I would like to detect those at compile time.

read more

Alert if Duplicate entry is inserted in data base on unique condition javascript

Am trying to create a alert condition if the duplicate value is inserted to DB on duplicate entry of data on unique state
Example on my code below as test table’s all columns are unique and insert query has a repeated entry of data on that i need to show sql error

Create Query

    var db = openDatabase("demo", "1.0", "demo", 200000);

            db.transaction(function(tx) {
            tx.executeSql( "CREATE TABLE IF NOT EXISTS test (Slno INTEGER PRIMARY KEY AUTOINCREMENT, column1 TEXT UNIQUE, column2 TEXT UNIQUE, column3 TEXT UNIQUE, column4 TEXT UNIQUE, column5 TEXT UNIQUE)");
        });

Insert Query

db.transaction(function(tx) {
            tx.executeSql("INSERT INTO test (column1, column2 ,column3, column4,column5) VALUES ('insert1','insert2','insert3','insert4','insert5'),('insert1','insert2','insert3','insert4','insert5');");
        });

read more

Alert if Duplicate entry is inserted in data base on unique condition javascript

Am trying to create a alert condition if the duplicate value is inserted to DB on duplicate entry of data on unique state
Example on my code below as test table’s all columns are unique and insert query has a repeated entry of data on that i need to show sql error

Create Query

    var db = openDatabase("demo", "1.0", "demo", 200000);

            db.transaction(function(tx) {
            tx.executeSql( "CREATE TABLE IF NOT EXISTS test (Slno INTEGER PRIMARY KEY AUTOINCREMENT, column1 TEXT UNIQUE, column2 TEXT UNIQUE, column3 TEXT UNIQUE, column4 TEXT UNIQUE, column5 TEXT UNIQUE)");
        });

Insert Query

db.transaction(function(tx) {
            tx.executeSql("INSERT INTO test (column1, column2 ,column3, column4,column5) VALUES ('insert1','insert2','insert3','insert4','insert5'),('insert1','insert2','insert3','insert4','insert5');");
        });

read more

How to return a statements in stored procedure

This is my procedure :

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[uspChangeMemberRole]
    @TeamID INT,
    @MemberID INT,
    @MemberRole TINYINT
AS 
BEGIN
    SET NOCOUNT ON;

    UPDATE [dbo].[TeamMember] 
    SET MemberRole = @MemberRole 
    WHERE TeamID = @TeamID 
      AND MemberID = @MemberID;

    RETURN @MemberRole;
END

When I execute this procedure I want to return “MemberRole Successfully Changed”.

Please give me a solution how to return

How to return a statements in stored procedure

read more