Skip to content

How to do a batch commit in plpgsql?

When I do the below function, some errors occurs: Here is my sample code. So could anyone give me a sample of how to finish my job as the above code? I’m using PostgreSQL 9.2. Answer In general, I think there are three approaches you can take: Do without. Just let the whole thing be committed at once, l…

How to find last weekday of current month using SQL

How would I calculate the last weekday of the current month given a date using SQL? I was able to get the last day of current month, but not sure how to do the last weekday programmatically. I don’t want to generate a calendar look-up table. Here’s the last day of month code i’m currently us…

MSSQL BIT_COUNT (Hammingdistance)

Is there any function similar to the MYSQL BIT_COUNT function in MSSQL? I want to create a very simple Hammingdistance function in MSSQL that i can use in my selects. Here is what i have for MYSQL: Answer Why not just write your own bit_count code in T-SQL? There’s no need to use SQL CLR if all you need…

How to know if a user has a privilege on Object?

I would like to know if a user has a privilege on an object or not. I’m working on SQL Developer. When I query manually the table DBA_TAB_PRIVS, I get all the information needed. However, I need this information to be used in some triggers and functions. So, I’m writing PL/SQL function that will r…