I have a problem with closing a connection to MySQL. I’m getting the error: java.sql.SQLException: Operation not allowed after ResultSet closed My code: public static ResultSet sqlquery (String …
Tag: sql
How to iterate over a record when the columns are dynamic
I have this function in postgres which takes PVH_COLS_DYNA that contains the columns that are going in to the query: CREATE OR REPLACE FUNCTION DRYNAMIC_DATA_F(PVH_COLS_DYNA VARCHAR) RETURNS numeric …
Delphi 7 Syntax error (comma) in ADO query
I’m trying to create a record in a database using a SQL query in Delphi 7. I’m using an ADO Query and I’ve tried both with and without parameters, but to no avail. The error occurs between ShowMessage 1 and 2. The commented out part was the one way I tried doing this, and it gave this error:…
Can you define a custom “week” in PostgreSQL?
To extract the week of a given year we can use: However, I am trying to group weeks together in a bit of an odd format. My start of a week would begin on Mondays at 4am and would conclude the following Monday at 3:59:59am. Ideally, I would like to create a query that provides a start and end date,
How to search for for strings/keywords in Access database using PHP?
I’m working on a school assignment and I’ve an Access database which has a memo field that stores lots of text. I wanna know how I can search for specific keywords in that memo field. For instance, …
Find records which cross-reference each other
I want to extract all the rows from a database table, where the rows cross-reference each other. My table contains 2 rows: ref1 & ref2 Table example: In this case, I want my query to return only rows 01 and 03, because they cross-reference each other. Is this possible using a single query, or will I need …
SQL Update if parameter is not null or empty
I searched some ways to check if a SQL Server parameter is not null or empty but I’m not sure what’s the best way to use this when updating several columns: I had this code at first that was updating without checking for empty or Null values: Then I added an IF clause before updating, it is workin…
Stackoverflow with Hibernate using sql IN (id, id, id, id..id)
I am getting the error below saying there was a stack overflow. This is happening because a SQL statement with IN (id, id, id…id) has a ton of parameters. Is there anyway to fix this? This is happening in my local environment with Eclipse. JPA Error Hibernate Query Answer In our Grails project (2.3.6) w…
How to allow only one row for a table?
I have one table in which I would like only one entry. So if someone is trying to insert another row it shouldn’t be allowed, only after someone deleted the previously existing row. How do I set a rule for a table like this? Answer A UNIQUE constraint allows multiple rows with NULL values, because two N…
Passing a non-column parameter in a MyBatis ResultMap to a nested select
I’ve a One-to-Many relationship in my domain model where I basically want to read Foos and a filtered set of Bars with one MyBatis select statement using a nested select for the Bars. To explain: My domain model classes look more or less like this (the real domain model is more complex of course, but my…