Solved

Need help converting some sql server sql to Oracle sql

Posted on 2016-10-09
9
76 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
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 73

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 73

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 76

Expert Comment

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

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JDeveloper 12c for 32 bit 4 84
Getting a return value from an IN OUT parameter in Oracle? 7 53
Oracle Next Available Number 2 42
clob to char in oracle 3 39
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

773 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