• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Confusing with Stored Procedures in jdbc

 
Ranch Hand
Posts: 67
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I m confusing with CallableStatement interface... I know stored procedure with IN parameters but i don't know OUT parameters and even i do know the logic of stored procedure and the program too...






MyDoubt : STORED PROCEDURE
1. Will this stored procedure work with mysql?
2. What is the logic of this stored procedure ? (it copies the USERNAME, CREATED_BY,CREATED_DATE column and then inserted into o_username,o_createdby,o_date but i do know from which table to another table ?)
3. what is this ? (DBUSER has username column with some datatype right ?)

MyDoubt : JDBC JAVA PROGRAM
1.What is the flow of execution of this program ? ( it returns username,createdby,createddate in the form of specified datatype by giving id = 10 so that it retrieves "username,createdby,createddate values.... is this right?)

MyDoubt : TABLE CREATION
1.How many tables should i want to create ? One or Two table ?


Please anyone help me............. Thanks in advance
 
Ranch Hand
Posts: 624
9
BSD Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. It looks like Oracle syntax to me. It will definitely work with MySql but syntax has to be changed.
To check how syntax goes in MySql follow this link

2. It does not insert into any other table. It selects the column values and assigns them to the mentioned variables.
In the above PlSql statement, value of USERNAME column is assigned to o_username variable, CREATED_BY to o_createdby variable and so on which are declared while creating the stored procedure.

3. This is Oracle syntax and I guess does not work with MySql.
This statement tells MySql to declare a variable p_userid of type USER_ID column from DBUSER table.
So if USER_ID is a VARCHAR(20), the variable p_userid will be VARCHAR(20).


Flow of execution of JDBC program:
It initializes Statement to call the Stored Procedure.
It passes user id to the Stored Procedure as input parameter.
It gets user name, created by and created date as output parameters from Stored Procedure and prints them.


For this specific code, you have to create only 1 table, i.e., DBUSER.
 
vinoth vino
Ranch Hand
Posts: 67
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your explanation is very clear. Thank you so much It really helps me alot !!! @Tapas Chand
 
Tapas Chand
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic