[SQL] error codes
Hi guys. Does anyone know the error code for '*currval of sequence * is not yet defined in this session*' error ? Is there one at all? I am aware of *others *code but I'd like to avoid using that. Thanks in advance. Regards mk
[SQL] Desc Commnad in pgsql?
Hello All, I like to know how can I achieve the same functionality that is give by desc commnad in mysql or oracle. Also specify me the book related to pgsql as a beginner. Presently my task is going to be communication of ruby with pgsql Thanks in advanced. Vikas
Re: [SQL] Desc Commnad in pgsql?
am Thu, dem 17.04.2008, um 14:17:45 +0530 mailte VG folgendes: > > > Hello All, > > I like to know how can I achieve the same functionality that is give by desc > commnad in mysql or oracle. 'desc'? descending, describe, desc... wild guess: describe, like ORA. You can use \d within psql, please read the welcome-message. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Desc Commnad in pgsql?
VG wrote: Hello All, I like to know how can I achieve the same functionality that is give by desc commnad in mysql or oracle. http://www.postgresql.org/docs/8.3/static/app-psql.html See the \d command, e.g. "\d mytable" There are many different backslash commands that can give you details on tables, views, functions, schemas etc. Also specify me the book related to pgsql as a beginner. http://www.postgresql.org/docs/8.3/static/index.html http://www.postgresql.org/docs/books/ Presently my task is going to be communication of ruby with pgsql Start here I suppose: http://rubyforge.org/projects/ruby-pg/ -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] error codes
Marcin Krawczyk wrote:
> Hi guys. Does anyone know the error code for '/currval of sequence * is
> not yet defined in this session/' error ? Is there one at all?
A quick JDBC test program shows:
ERROR: currval of sequence "customer_id_seq" is not yet defined in this
session (SQLState: 55000)
which, looking up the error code in the docs:
http://www.postgresql.org/docs/current/static/errcodes-appendix.html
turns out to be:
55000 OBJECT NOT IN PREREQUISITE STATE
... which makes sense, but I wouldn't call blindingly and immediately
obvious.
Here's a trivial little utility for running a statement, catching an
error, and reporting the error along with the Pg error code. Sorry for
the horrible formatting (short lines for email).
--- Put in file `JdbcTest.java' ---
import java.sql.SQLException;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
class JdbcTest {
public static void main(String[] args)
throws ClassNotFoundException, InterruptedException, SQLException
{
Class.forName("org.postgresql.Driver");
Connection c =
DriverManager.getConnection("jdbc://YOUR_PARAMS_HERE");
try {
CallableStatement st =
c.prepareCall("SELECT currval('customer_id_seq')");
st.execute();
} catch (SQLException ex) {
System.out.println(
"DB error string: " + ex.getMessage()
+ " (SQLState: " + ex.getSQLState() + ")");
}
}
}
end
You'll need the PostgreSQL JDBC driver.
To compile (assuming you don't use a Java IDE of some sort, but have the
JDK installed) run:
javac -d /out/dir JdbcTest.java
and to run (all on one line):
java -classpath /path/to/postgresql-8.3-603.jdbc4.jar:/out/dir JdbcTest
where /out/dir is wherever you want the generated .class file to be put.
--
Craig Ringer
--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] error codes
Craig Ringer wrote:
> Marcin Krawczyk wrote:
>> Hi guys. Does anyone know the error code for '/currval of sequence * is
>> not yet defined in this session/' error ? Is there one at all?
>
> A quick JDBC test program shows:
>
> ERROR: currval of sequence "customer_id_seq" is not yet defined in this
> session (SQLState: 55000)
I've just realised I've been doing this a stupid way without thinking
about it. Unsurprisingly it turns out that no Java/JDBC snippets are
required. The much, much easier way to find the error code:
$ psql
... blah blah blah ...
test=# \set VERBOSITY verbose
test=# select currval('test_seq');
ERROR: 55000: currval of sequence "test_seq" is not yet defined in this
session
LOCATION: currval_oid, sequence.c:644
In retrospect it seems kind of obvious - "surely psql must have way to
show this information, maybe I should look at the manual".
--
Craig Ringer
--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
[SQL] Error in restore the Database in Postgres
Dear Sir, I have Mysql database backup file ( xyz.sql ). Now i want to restore this ( xyz.sql ) file into Postgres Database. I try following command to restore but Postgres gives me the Error. psql -d tracker -f /home/postgres/backup/tracker_db.sql In xyz.sql file Lock Table; statement is written on each table. I use Postgres 8.1 version. Kindly Help me as early as possible. Or, give me another command. -- With Warm Regards, Dipesh Mistry Information Technology Dept. GaneshaSpeaks.com -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Error in restore the Database in Postgres
dipesh wrote: Dear Sir, I have Mysql database backup file ( xyz.sql ). Now i want to restore this ( xyz.sql ) file into Postgres Database. I try following command to restore but Postgres gives me the Error. You have a mysql dump, which is designed to restore to a MySQL database. It will include mostly standard SQL and also all the specific MySQL differences. You'll need to convert it to produce something that PostgreSQL can understand. http://pgfoundry.org/search/?type_of_search=soft&words=mysql&Search=Search Perhaps one of these two projects: http://pgfoundry.org/projects/mysql2pgsql/ http://pgfoundry.org/projects/my2postgres/ -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
