Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Problem with oracle primary key / trigger / sequence
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom808  
View profile  
 More options Jun 19 2009, 6:12 am
From: Tom808 <thomas_80...@yahoo.com>
Date: Fri, 19 Jun 2009 03:12:29 -0700 (PDT)
Local: Fri, Jun 19 2009 6:12 am
Subject: Problem with oracle primary key / trigger / sequence
Hello,

using the follwoing schema.yml with Doctrine 1.1.2

atest:
  columns:
    aname: string(255)

and

Doctrine::generateModelsFromYaml('schema.yml', 'models');
Doctrine::createTablesFromModels('models');

will create the trigger and sequence as followed below.

The trigger tries to select ATEST_seq but the sequence name ist
ATEST_SEQ. Trying to insert a record does cause

ORA-01403: no data found
ORA-06512: at "DOC.ATEST_AI_PK", line 9
ORA-04088: error during execution of trigger 'DOC.ATEST_AI_PK

After manualy changin the trigger code to ATEST_SEQ" everthing works
fine. Is there any way to solve this issue?

Kind regards
Tom

CREATE SEQUENCE   "ATEST_SEQ"  MINVALUE 1 MAXVALUE
999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE
NOORDER  NOCYCLE

create or replace TRIGGER ATEST_AI_PK
   BEFORE INSERT
   ON ATEST
   FOR EACH ROW
DECLARE
   last_Sequence NUMBER;
   last_InsertID NUMBER;
BEGIN
   SELECT ATEST_seq.NEXTVAL INTO :NEW.id FROM DUAL;
   IF (:NEW.id IS NULL OR :NEW.id = 0) THEN
      SELECT ATEST_seq.NEXTVAL INTO :NEW.id FROM DUAL;
   ELSE
      SELECT NVL(Last_Number, 0) INTO last_Sequence
        FROM User_Sequences
       WHERE Sequence_Name = 'ATEST_seq';
      SELECT :NEW.id INTO last_InsertID FROM DUAL;
      WHILE (last_InsertID > last_Sequence) LOOP
         SELECT ATEST_seq.NEXTVAL INTO last_Sequence FROM DUAL;
      END LOOP;
   END IF;
END;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile  
 More options Jun 19 2009, 6:14 am
From: Jonathan Wage <jonw...@gmail.com>
Date: Fri, 19 Jun 2009 05:14:23 -0500
Local: Fri, Jun 19 2009 6:14 am
Subject: Re: [doctrine-user] Problem with oracle primary key / trigger / sequence

I fixed this in the latest SVN. Can you try using the latest 1.1 branch of
Doctrine and let me know.

I've dedicated a lot of time recently to fine tuning the integration between
Doctrine and oracle and would love to work with you to help fix any other
small problems.

Thanks, Jon

--
Jonathan H. Wage (+1 415 992 5468)
Open Source Software Developer & Evangelist
sensiolabs.com | jwage.com | doctrine-project.org | symfony-project.org

You can contact Jonathan about Doctrine, Symfony and Open-Source or for
training, consulting, application development, or business related questions
at jonathan.w...@sensio.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom808  
View profile  
 More options Jun 19 2009, 9:09 am
From: Tom808 <thomas_80...@yahoo.com>
Date: Fri, 19 Jun 2009 06:09:26 -0700 (PDT)
Local: Fri, Jun 19 2009 9:09 am
Subject: Re: Problem with oracle primary key / trigger / sequence
Dear Jon,

thank you very much for your prompt response.

It took a moment to allow the server to connect to our proxy...

The problem (_seq vs. _SEQ) is now fixed with the last branch from SVN
- thanks a lot.

But i run in the next one:

Inserting a record i a table with actAs: Timestampable cause the
following error:

schema.yml:
atable:
  actAs: [Timestampable]
  columns:
    acolumn: string(255)

php:
$atable = new atable();
$atable->acolumn = 'foo';
$atable->save();

PHP Fatal error:  Uncaught exception
'Doctrine_Connection_Oracle_Exception' with message 'SQLSTATE[HY000]:
General error: 1861 OCIStmtExecute: ORA-01861: literal does not match
format string
 (/tmp/PDO_OCI-1.0/oci_statement.c:142)' in /srv/www/htdocs/test_doc/
svn/1.1/lib/Doctrine/Connection.php:1084
Stack trace:
#0 /srv/www/htdocs/test_doc/svn/1.1/lib/Doctrine/Connection/
Statement.php(253): Doctrine_Connection->rethrowException(Object
(PDOException), Object(Doctrine_Connection_Statement))
#1 /srv/www/htdocs/test_doc/svn/1.1/lib/Doctrine/Connection.php(1049):
Doctrine_Connection_Statement->execute(Array)
#2 /srv/www/htdocs/test_doc/svn/1.1/lib/Doctrine/Connection.php(693):
Doctrine_Connection->exec('INSERT INTO ata...', Array)
#3 /srv/www/htdocs/test_doc/svn/1.1/lib/Doctrine/Connection/
UnitOfWork.php(595): Doctrine_Connection->insert(Object
(Doctrine_Table), Array)
#4 /srv/www/htdocs/test_doc/svn/1.1/lib/Doctrine/Connection/
UnitOfWork.php(549): Doctrine_Connection_UnitOfWork-

>processSingleInsert(Object(atable))

#5 in /srv/www/htdocs/test_doc/svn/1.1/lib/Doctrine/Connection.php on
line 1084

Kind regards
Thomas

On Jun 19, 12:14 pm, Jonathan Wage <jonw...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan H. Wage  
View profile  
 More options Jun 20 2009, 8:30 pm
From: "Jonathan H. Wage" <jonw...@gmail.com>
Date: Sat, 20 Jun 2009 17:30:11 -0700 (PDT)
Local: Sat, Jun 20 2009 8:30 pm
Subject: Re: Problem with oracle primary key / trigger / sequence
What is the query that is failing? Can you debug it a bit and see
what  you can find?

Thanks, Jon

On Jun 19, 8:09 am, Tom808 <thomas_80...@yahoo.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vadik56  
View profile  
 More options Jun 21 2009, 9:55 pm
From: vadik56 <vadi...@gmail.com>
Date: Sun, 21 Jun 2009 18:55:30 -0700 (PDT)
Local: Sun, Jun 21 2009 9:55 pm
Subject: Re: Problem with oracle primary key / trigger / sequence
Most likely "ORA-01861: literal does not match format string."
happened because date format in database and doctrine is not the same.
In oracle default date format depends on your installation and most
likely it looks like this: 21-JUN-2009. So when doctrine inserts
atable object, it tries to set CREATED_AT column using 'Y-m-d H:i:s'
format and you get an exception. To get around this problem you can
create connection listener that sets default date format on connect:
ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS' or
$connection->setDateFormat(). Ideally doctrine should automatically
set oracle date on connect.

On Jun 20, 8:30 pm, "Jonathan H. Wage" <jonw...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom808  
View profile  
 More options Jun 22 2009, 1:07 pm
From: Tom808 <thomas_80...@yahoo.com>
Date: Mon, 22 Jun 2009 10:07:27 -0700 (PDT)
Local: Mon, Jun 22 2009 1:07 pm
Subject: Re: Problem with oracle primary key / trigger / sequence
Dear Jon,

thank you again.

$conn->setDateFormat() works well.

Kind regards
Tom


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vadim klimine  
View profile  
 More options Jun 22 2009, 1:32 pm
From: vadim klimine <vadi...@gmail.com>
Date: Mon, 22 Jun 2009 13:32:29 -0400
Local: Mon, Jun 22 2009 1:32 pm
Subject: Re: [doctrine-user] Re: Problem with oracle primary key / trigger / sequence

I posted this some time ago on Doctrine forum, but since forum is no longer
available I'll post Connection Listener that sets correct Oracle date format
here.

//define DoctrineOracleDateFormatSetter listener class
class DoctrineOracleDateFormatSetter extends Doctrine_EventListener{
    public function postConnect(Doctrine_Event $event) {
        $event->getInvoker()->setDateFormat("YYYY-MM-DD HH24:MI:SS");
    }

}

//attach listener to doctrine connection
$doctrineConnection->addListener(new DoctrineOracleDateFormatSetter());


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »