Solved

Need help converting some sql server sql to Oracle sql

Posted on 2016-10-09
9
88 Views
Last Modified: 2016-10-11
I need to convert the sql server sql below to Oracle sql. I am mostly stuck because I can't find an equivalent conversion for "syscolumns"
Does anyone know of an equivalent query for SELECT * FROM syscolumns ?


IF NOT EXISTS (SELECT * FROM syscolumns WHERE name =  @searchString)
BEGIN


END
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 41836283
to search for table or view columns try one of these:

select * from dba_tab_columns where column_name = :searchstring
or
select * from dba_tab_cols where column_name = :searchstring

to find stored procedure parameters try

select * from dba_arguments where argument_name = :searchstring
0
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41836315
May be this you are looking for..

--

DECLARE
    pawan integer; -- declare
BEGIN
    pawan := 30;  --assign <<Value you want to search for >>
    
    dbms_output.Put_line(pawan); --display
    
    IF NOT EXISTS (SELECT * FROM YourTable WHERE Colname = :pawan)
    BEGIN
           .................
    END
    
END; 

--

Open in new window

0
 
LVL 74

Expert Comment

by:sdstuber
ID: 41836334
if used inside a pl/sql block, don't put the colon (:) in front of the bind variable.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:Mark Geerlings
ID: 41837098
Since I don't know SQL Server, I have to guess at what "syscolumns" means in a SQL Server system.  From sdstuber's comments, it appears to contain data similar to what these three views contain in an Oracle system:
dba_tab_columns
all_tab_columns
user_tab_columns

Depending on which Oracle schema your Oracle procedure will be in, and on what privileges that schema has, you may want to use one or another of these "data dictionary views".  The dfference between these various views in Oracle is:
1. the "dba_..." objects include all objects in the database.
2. the "all_..." objects include the objects your schema is allowed to see
3. the "user_..." objects include only those objects in your schema

Oracle databases includes a number of these "data dictionary views" including:
dba/all/user_tables
dba/all/user_tab_columns
dba/all/user_indexes
dba/all/user_ind_columns
dba/all/user_objects
dba/all/user_constraints
etc.

(Your schema may or may not have permission to use these objects that start with "dba_...".)

Something to watch out for in converting SQL Server code to Oracle code is "temp" tables that are commonly created dynamically in SQL Server stored procedures.  This concept is usually not needed in Oracle stored procedures.  Oracle supports "global temporary tables".  These can be helpful for some data processing tasks.  But in Oracle these are not created dynamically at runtime.  In Oracle these are created once by a DBA, then stored procedures can be written that use them.
0
 
LVL 2

Author Comment

by:brgdotnet
ID: 41837562
Thank you.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 41837563
Pawan,

Still not Oracle syntax.  Please test against an actual database before posting.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 41837564
brgdotnet,

What accept a post that isn't even valid syntax?
0
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 41839453
THank you
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Developer 6 75
oracle forms question 22 48
What are the limitations of input parameters in oracle ? 5 67
MS SQL Server Management Studio R2 4 32
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question