Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 29th, 2005, 06:15 AM
Padmavathy Padmavathy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 Padmavathy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 3 sec
Reputation Power: 0
Unhappy Dynamic DML Query Formation in Stored Procedures

Hi all,
I'm new to Firebird.
I need to build an insert statement inside procedures based on the values of the parameters it receives.I'm able to create that but unable to execute it.

I'm unable to execute a simple DML statement inside the procedure.I dont know what mistake i'm making.This is the code snippet where i got error

CREATE TABLE "MYTABLE"
(
"ORDERID" INTEGER NOT NULL,
"ISBN" CHAR(13) NOT NULL,
"NO_OF_BOOKS" INTEGER NOT NULL
);

CREATE PROCEDURE MYPROC(ORDERID INTEGER,ISBN CHAR(13),NO_OF_BOOKS INTEGER)
AS
BEGIN
EXECUTE STATEMENT 'INSERT INTO MYTABLE(ORDERID,ISBN,NO_OF_BOOKS) VALUES(:ORDERID,:ISBN,:NO_OF_BOOKS)';
END

And the error i received when i tried to execute the MYPROC is

Error at line 1: Dynamic SQL Error
SQL error code = -206
Column unknown
ORDERID
At line 1, column 60

Done: 1 statements, 1 errors, 0.00 s

Thanks in advance

-Padmavathy

Reply With Quote
  #2  
Old August 30th, 2005, 12:25 AM
badukist badukist is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 62 badukist User rank is Corporal (100 - 500 Reputation Level)badukist User rank is Corporal (100 - 500 Reputation Level)badukist User rank is Corporal (100 - 500 Reputation Level)badukist User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 3 m 18 sec
Reputation Power: 7
Send a message via Yahoo to badukist
Quote:
Originally Posted by Padmavathy
Hi all,
I'm new to Firebird.
I need to build an insert statement inside procedures based on the values of the parameters it receives.I'm able to create that but unable to execute it.

I'm unable to execute a simple DML statement inside the procedure.I dont know what mistake i'm making.This is the code snippet where i got error

CREATE TABLE "MYTABLE"
(
"ORDERID" INTEGER NOT NULL,
"ISBN" CHAR(13) NOT NULL,
"NO_OF_BOOKS" INTEGER NOT NULL
);

CREATE PROCEDURE MYPROC(ORDERID INTEGER,ISBN CHAR(13),NO_OF_BOOKS INTEGER)
AS
BEGIN
EXECUTE STATEMENT 'INSERT INTO MYTABLE(ORDERID,ISBN,NO_OF_BOOKS) VALUES(:ORDERID,:ISBN,:NO_OF_BOOKS)';
END

And the error i received when i tried to execute the MYPROC is

Error at line 1: Dynamic SQL Error
SQL error code = -206
Column unknown
ORDERID
At line 1, column 60

Done: 1 statements, 1 errors, 0.00 s

Thanks in advance

-Padmavathy


Try
Statement = 'INSERT INTO MYTABLE( ORDERID, ISBN, NO_OF_BOOKS) VALUES(' || ORDERID ||','||ISBN || ',' ||NO_OF_BOOKS||')' ;
EXECUTE STATEMENT :Statement ;

Reply With Quote
  #3  
Old August 30th, 2005, 02:17 AM
Padmavathy Padmavathy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 Padmavathy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 44 m 3 sec
Reputation Power: 0
Quote:
Originally Posted by badukist
Try
Statement = 'INSERT INTO MYTABLE( ORDERID, ISBN, NO_OF_BOOKS) VALUES(' || ORDERID ||','||ISBN || ',' ||NO_OF_BOOKS||')' ;
EXECUTE STATEMENT :Statement ;


Hi,

Thanks for taking your time to reply.

Reply With Quote
  #4  
Old October 18th, 2005, 08:13 AM
kishore_zylog kishore_zylog is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 2 kishore_zylog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 15 sec
Reputation Power: 0
sp

Hi,

To use DML Statements in a Procedures ,no need to mention 'Execute Statement'. U can directly use insert statement.

CREATE PROCEDURE MYPROC(ORDERID INTEGER,ISBN CHAR(13),NO_OF_BOOKS INTEGER)
AS
BEGIN
INSERT INTO MYTABLE(ORDERID,ISBN,NO_OF_BOOKS) VALUES(:ORDERID,:ISBN,:NO_OF_BOOKS);
END

The above procedure will work fine.

Kishore



/*
Quote:
Originally Posted by Padmavathy
Hi all,
I'm new to Firebird.
I need to build an insert statement inside procedures based on the values of the parameters it receives.I'm able to create that but unable to execute it.

I'm unable to execute a simple DML statement inside the procedure.I dont know what mistake i'm making.This is the code snippet where i got error

CREATE TABLE "MYTABLE"
(
"ORDERID" INTEGER NOT NULL,
"ISBN" CHAR(13) NOT NULL,
"NO_OF_BOOKS" INTEGER NOT NULL
);

CREATE PROCEDURE MYPROC(ORDERID INTEGER,ISBN CHAR(13),NO_OF_BOOKS INTEGER)
AS
BEGIN
EXECUTE STATEMENT 'INSERT INTO MYTABLE(ORDERID,ISBN,NO_OF_BOOKS) VALUES(:ORDERID,:ISBN,:NO_OF_BOOKS)';
END

And the error i received when i tried to execute the MYPROC is

Error at line 1: Dynamic SQL Error
SQL error code = -206
Column unknown
ORDERID
At line 1, column 60

Done: 1 statements, 1 errors, 0.00 s

Thanks in advance

-Padmavathy
*/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Dynamic DML Query Formation in Stored Procedures


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT