Skip to content

Using PostgreSQL COPY

I’m using JMeter for insert summary data file to PostgreSQL. I tried copy instead of COPY but I’m getting error at copy syntax. I found out COPY is for only server-side, so I us copy for client-side. Here is my query Here is the error: org.postgresql.util.PSQLException: ERROR: syntax error at or n…

store function into variable that expects parameters

So given the following example query I want to fetch all documents created in a range of two dates. As you can see I put some calculations into variables because I can reuse them in the WHERE clause. Further those calculations only differ by one value, the month at the end. So the calculation could also be Is…

Exclude specific rows from table in Stored Procedure

I have a table named Blacklist and table named Order. Both have CustomerId column. Stored Procedure ExecOrder manipulates Order table. My goal is to exclude Orders that have Blacklisted CustomerId (meaning : Order’s CustomerId is in Blacklist table). I edited ExecOrder SP like this: @Temp table returns …

Problem in using group by statement in sql

I am not able to group by table which has all the values same but has two rows. I am not understanding what is the reason behind that. After running this query i am getting the table below and i want to group the table along the LOT_No. TABLE : Now when i am trying to Group by LOT_No, i

how to create fraud detection with SQL?

I have a scenario where: User A is (fraudster). User B is not (fraudster). However, the system will not allow user B to do any action. Because B and A are using the same Phone Number(Shared attribute …

value in column between commas delimited

I have data in the table where all values in the column between double commas example: ‘EGHU3158543’ when inquiry the data I need to delete the first comma and last comma, I used the following code : it gives me error as result : Invalid length parameter passed to the LEFT or SUBSTRING function. A…