|
Maybe vision - those little characters are just to hard to see?
|
|
|
|
|
Hmm, interesting explanation...
So, zoom doesn't work either?
|
|
|
|
|
This question is not specific enough to answer well, because the answer is "write the code."
Do you have a more specific question?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
What else could cause this error beside the sequence not being created?
I have recreated the sequence using SQL code, also recreated it using Oracle SQL Developer "New Sequence" menu but still nothing. I only have a single class and and a single table, being a learning project, I don't want to complicate things. Project made using Maven.
hibernate.cfg.xml:
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">
org.hibernate.dialect.Oracle10gDialect
</property>
<property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="hibernate.connection.url">
jdbc:oracle:thin:@localhost:1521:xe
</property>
<property name="hibernate.connection.username">
SYSTEM
</property>
<property name="hibernate.connection.password">
testingdatabasepassword
</property>
<mapping resource="com/testing/classes/Person.hbm.xml" />
</session-factory>
</hibernate-configuration>
Person.java
package com.testing.classes;
public class Person {
private int id;
private String firstName;
private String lastName;
private int age;
public Person(String firstName, String lastName, int age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
Person.hbm.xml
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name = "com.testing.classes.Person" table = "PERSON">
<id name = "id" type = "int" column = "ID">
<generator class="sequence">
<param name="sequence">CREATE_PERSON_ID</param>
</generator>
</id>
<property name = "firstName" column = "FIRST_NAME" type = "string"/>
<property name = "lastName" column = "LAST_NAME" type = "string"/>
<property name = "age" column = "AGE" type = "int"/>
</class>
</hibernate-mapping>
Sequence:
CREATE SEQUENCE CREATE_PERSON_ID INCREMENT BY 1 START WITH 1 MAXVALUE 9999 MINVALUE 1 CACHE 10;
Testing main:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Person person = new Person("Name", "Last name", 48);
session.save(person);
session.beginTransaction().commit();
modified 18-Feb-19 8:55am.
|
|
|
|
|
I don't use Oracle, so this is just a guess: do you need to grant SELECT permissions on the sequence to the user you're connecting as?
To use a sequence, your schema must contain the sequence or you must have been granted the SELECT object privilege for another user's sequence.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well, as you can see in my hibernate.cfg.xml, I'm using SYSTEM, so that isn't the problem unfortunately.
Edit:
After some more research I found the problem. All the sites with tutorials google suggested were using either
<generator class="native"> or <param name="sequence" />SEQUENCE_NAME
The problem is that hibernate devs changed <param name="sequence" /> to <param name="sequence_name" />. It is weird that you get sequence does not exist error, instead of something like invalid value for param or something to suggest that is the problem.
modified 18-Feb-19 8:54am.
|
|
|
|
|
To solve this problem you have to change:
<generator class="sequence">
<param name="sequence">SEQUENCE_NAME</param>
</generator>
into
<generator class="sequence">
<param name="sequence_name">SEQUENCE_NAME</param>
</generator>
The value for param was changed from just "sequence" to "sequence_name".
|
|
|
|
|
After you install Oracle 11g XE, it will automatically create some tables (from what I've read, some are used for "Application Express", and you shouldn't drop them), but having them listed in Tables view is really annoying.
Is there a way to filter them out? And why do you use $ in table name for?
modified 16-Feb-19 14:04pm.
|
|
|
|
|
Can't help you with the filtering since I don't work with Oracle anymore, but the V$ is just the naming standard Oracle uses for "Volatile" files, containing statistics and such stuff
|
|
|
|
|
Oh OK, I though they have some special meaning, something that I will have to use in the future too, guess not. Thanks!
|
|
|
|
|
For some reason, last time I searched on google it didn't showed me anything useful (on any of the first 4 pages), but this time, I got the answer I needed.
Solutions:
1. Use a different user then SYSTEM. I didn't though at this, after all I didn't wanted to complicate things on a learning project.
2. Filter each group using %. When I tried it before it didn't worked, but now after I started the DB again, the filter worked as it should have. Maybe there was an error connecting to the DB, don't know, it's good that now it is working.
|
|
|
|
|
When i execute the procedure what i get the output is like -
ALTER PROC [dbo].[PROC_EMPLOYEE_PAY_SLIP]
@EmplopyeeCode varchar(100),
@MonthName varchar(50),
@Year Float
As
Begin
SELECT ISNULL(HR_EmployeeMaster.em_EmplopyeeCode,'') As EmplopyeeCode,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'A' THEN fa_ComponentMaster.Cm_Name ELSE '' END,'') As Additions,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'D' THEN fa_ComponentMaster.Cm_Name ELSE '' END,'') As Deductions,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'A' THEN Fa_MonthSalary.Ms_Amount ELSE 0 END,0) As AdditionsAmount,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'D' THEN Fa_MonthSalary.Ms_Amount ELSE 0 END,0) As DeductionsAmount
FROM HR_EmployeeMaster
LEFT JOIN Fa_MonthSalary ON Fa_MonthSalary.ms_EmpCode = @EmplopyeeCode
LEFT JOIN Fa_MonthDetails ON Fa_MonthDetails.mo_id = Fa_MonthSalary.Ms_MonCode
LEFT JOIN fa_ComponentMaster ON fa_ComponentMaster.cm_code = Fa_MonthSalary.Ms_CompCode
WHERE HR_EmployeeMaster.em_EmplopyeeCode = @EmplopyeeCode AND
(SELECT CONVERT(CHAR(3), Fa_MonthDetails.mo_name)) = @MonthName AND
Fa_MonthDetails.mon_year = @Year
End
Current Output -
EmployeeCode Additions Deductions AdditionsAmount DeductionsAmount
M1010 ALLOWANCE 960.00 0
M1010 BASIC SALARY 1390.00 0
M1010 OT1 171.35 0
M1010 OTHERS-DED 0.00 1800.00
Required Output -
EmployeeCode Additions Deductions AdditionsAmount DeductionsAmount
M1010 ALLOWANCE OTHERS-DED 960.00 1800.00
M1010 BASIC SALARY 1390.00 0
M1010 OT1 171.35 0
Any help would be appreciated
|
|
|
|
|
|
I am trying to figure out how to use transactions. I've read a lot of info, including this, but it's limited.
Does anyone know of a decent MongoDB Transactions tutorial?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
I'm very new with MongoDb, so excuse my ignorance.
I know that MongoDb doesn't store data in "tables" like SQL Server, but is there any way to look at the "structure" of a container? Basically I'd like to see the shape of the data.
Thanks.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You do have the mongo cli, which allows you to query the data, etc. But there is no "shape" to the data, like there is with SQL Data. Mongodb has "collections" which are roughly equivalent to tables, but unlike SQL tables, they have no structure imposed on them. e.g.
MongoDB shell version: 3.2.12
connecting to: test
> db.mycoll.find()
> db.mycoll.insertOne( { x: 1} )
{
"acknowledged" : true,
"insertedId" : ObjectId("5c62fb2a93ce6e6b14a14369")
}
> db.mycoll.insertOne( { able: 1, baker: "hello world", charlie: {xray: 0, zulu: 6.9} } )
{
"acknowledged" : true,
"insertedId" : ObjectId("5c62fb5293ce6e6b14a1436a")
}
> db.mycoll.find()
{ "_id" : ObjectId("5c62fb2a93ce6e6b14a14369"), "x" : 1 }
{ "_id" : ObjectId("5c62fb5293ce6e6b14a1436a"), "able" : 1, "baker" : "hello world", "charlie" : { "xray" : 0, "zulu" : 6.9 } }
modified 12-Feb-19 12:29pm.
|
|
|
|
|
That other reply is precise but not very useful.
If you have a Mongodb where collections do not have some specific form then you are using it wrong.
Besides the CLI I have also used two different UI clients for Mongo and both show the data that are in the collections in a reasonable way.
Now if you are starting with a empty collection you won't know what will go in there and with a SQL table you would but that that is somewhat a matter of degree and not usability. In that case you should go look to your design, which you should have regardless, or the code.
|
|
|
|
|
Hello everybody.
I have no database experience so I apologize in advance if my question is too trivial.
I'm writing an application in C++ (Embarcadero C++ Builder Tokyo) and I'm using sqlite.
I have a database with a table "EVENTI" with two columns ("DataOra" and "Evento") and about 6000 rows and I want to delete the first ~5000 rows to reduce the database size to about 1000 rows.
I have to use a command like:
"DELETE FROM EVENTI WHERE (condition)"
but I don't know exactly how to write the condition.
Is there a line identifier so I can write a condition like:
"DELETE FROM EVENTI WHERE (LineId < 5000)"
Or I have to read line 5000 (how?) and build a condition on the content of that line?
Someone can help me?
Thank you
|
|
|
|
|
You'll need to use a command like
"DELETE FROM EVENTI WHERE (condition)",
but we can't tell you what that condition is, since we don't know the table structure.
You can't think of SQL tables like flat files. Successive SELECTS from a table won't necessarily return the rows in the same order.
All tables should have a PRIMARY KEY, which uniquely identifies a given row. You should be able to use this to select the rows you wish to delete. Alternatively you may have a timestamp or other identifying piece of information in the row that will help you choose which rows to delete.
|
|
|
|
|
Thank you k5054.
I have not set a PRIMARY KEY in my table but the "DataOra" column contains a timestamp in the form "YYYY/MM/DD hh:mm:ss" so I think I could use this information to select the rows to delete.
But to do this I need to read the value of row 5000 without any information about this row, I mean that I have not a PRIMARY KEY and I just know the row number, is this information enought to read row 5000?
And if I read row 5000, then I can use a command like:
"DELETE FROM EVENTI WHERE DataOra < 'YYYY/MM/DD hh:mm:ss'"
or I have to convert in some way my timestamp?
Thank you
|
|
|
|
|
You should probably use a DATETIME field type for DataOra, but if you know that all your timestamps are 'YYYY/MM/DD hh:mm:ss', then then comparing as strings should work out OK.
How you truncate your data is somewhat dependent on exactly what your need is. If you just want to delete approximately 5000 records, you could do
SELECT count(*) FROM EVENT where DataOra < 'YYYY/MM/DD 00:00:00'
and adjust the date and or time up/down until you get about 5000 and then use that date as your comparison. Or maybe you would be happy with just deleting records before Feb 01/2019 in which case you could just use '2019/02/01 00:00:00' as your comparison
Alternatively, if you want to delete exactly 5000 records, ordering by timestamps, then this might work for you:
CREATE TEMP TABLE TMP(id INTEGER PRIMARY KEY AUTOINCREMENT, DataOra text);
INSERT INTO TMP(DataOra) SELECT DataOra from EVENT order by DataOra;
DELETE FROM EVENT where DataOra <= (SELECT DataOra from TMP where id = 5000);
hope this helps. Don't forget to back up your data before you begin - just in case!
|
|
|
|
|
Sorry for the delay.
Thank you for your detailed answer.
Where is created the TMP table? In the same database where there is the EVENTI table?
Thanks.
|
|
|
|
|
In my example the TMP table is created with the attribute TEMP, which means that the table will be TEMPORARY, and are dropped when the connection that created them closes. TEMP tables are created in the "temp" database (as per sqlite docs). Other than only existing for the current session, TEMP tables are just like regular tables - they can be indexed, altered, updated, etc.
|
|
|
|
|
Thank you very much k5054 for your explanation!
|
|
|
|