Home » Developer & Programmer » Forms » getting value from db (oracle forms 10g, win 7)
getting value from db [message #588886] Sat, 29 June 2013 08:22 Go to next message
reallyoldturtle
Messages: 15
Registered: June 2013
Junior Member
hi, i am new to oracle forms builder. can anyone help me with this problem?

i want to retrieve a value from the database and then print in a display item. how can i do it?

this code is the retrieval part but it doesn't work:
DECLARE
num number(10);
BEGIN
SELECT ID_CD
INTO num
FROM cd_details
WHERE price=599;
end;

please help Sad
Re: getting value from db [message #588917 is a reply to message #588886] Sat, 29 June 2013 14:05 Go to previous messageGo to next message
Littlefoot
Messages: 19526
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It works, but doesn't do what you wanted it to. Select into an item directly, such as
select ic_id
  into :block.display_item_name
  from cd_details
  where price = 599;


P.S. Alternatively, in your code, you miss the following:
  select ...

  :block.display_item_name := num;
end;

[Updated on: Sat, 29 June 2013 14:06]

Report message to a moderator

Re: getting value from db [message #588918 is a reply to message #588886] Sat, 29 June 2013 14:06 Go to previous messageGo to next message
cookiemonster
Messages: 10929
Registered: September 2008
Location: Rainy Manchester
Senior Member
What makes you think that code doesn't work?
Of course you should probably be fetching the value into a display item rather than a local variable. There's not a lot of point selecting a value if you do nothing with it.
Re: getting value from db [message #588920 is a reply to message #588918] Sat, 29 June 2013 14:21 Go to previous messageGo to next message
reallyoldturtle
Messages: 15
Registered: June 2013
Junior Member
Thanks a lot for replying

how do i display the value of the var into a say, display item...?
Re: getting value from db [message #588921 is a reply to message #588920] Sat, 29 June 2013 14:22 Go to previous messageGo to next message
Littlefoot
Messages: 19526
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Really, how?
Re: getting value from db [message #588923 is a reply to message #588920] Sat, 29 June 2013 14:32 Go to previous messageGo to next message
reallyoldturtle
Messages: 15
Registered: June 2013
Junior Member
thanks i could manage to get the value directly from the table into a display item..

but suppose i have a value in a var called num and i want to display it in a display item how do i do that?

ps - sorry, if i sound really stupid :/
Re: getting value from db [message #588924 is a reply to message #588923] Sat, 29 June 2013 14:34 Go to previous messageGo to next message
Littlefoot
Messages: 19526
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes, you do sound really stupid. You wouldn't if you read what I posted in my first answer to your question, which contains both how to select directly into an item, as well as how to put variable's value into an item.
Re: getting value from db [message #588925 is a reply to message #588924] Sat, 29 June 2013 14:36 Go to previous message
reallyoldturtle
Messages: 15
Registered: June 2013
Junior Member
oops my bad. I got it. thanks a lot. hehee
Previous Topic: Bad bind variable error
Next Topic: Getting date
Goto Forum:
  


Current Time: Sun Aug 31 01:59:35 CDT 2014

Total time taken to generate the page: 0.09597 seconds