?
Solved

Help with SQL pseudo-code

Posted on 2014-04-25
5
Medium Priority
?
3,486 Views
Last Modified: 2014-04-25
Hi,
  Could someone help me put basic SQL pseudo code to perform the following steps?  Can be general. I just need to get the syntax and functional logic in place then I can finish the specifics later.
Thanks in Advance...

- Put counts in temp table
      - 1 for bulk
      - 1 for others
- Verify temp table counts against imported counts
- If not bulk
      - export to mm table
      - Run mm job to import from sql to mm
      - Loop thru temp table for each PP
            - Edit mm job
            - Run mm job
      - Run mm job to export from mm to sql
- If not bulk update IMB for all but pp8
-      Insert records from mm table to live table
            - 1 for bulk
            - 1 for others
- Update live table
            - 1 for bulk
            - 1 for others
- If not bulk create signoff table
0
Comment
Question by:tesla764
[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
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40022864
as many of the "terms" are not clear to what they refer to, it's unlikely to get anything "good" without just guessing.

for example Put counts in temp table
      - 1 for bulk ...

what does " 1 for bulk " refer to?  I could guess 1 table named "bulk" ...

- Verify temp table counts against imported counts is not clear on what "imported counts" is meaning ? other table? ...

and so on and so forth...
0
 

Author Comment

by:tesla764
ID: 40022984
All I am trying to see is, for example, what would the SQL code look like to perform...

Put counts in temp table
      - 1 for bulk
      - 1 for others
- Verify temp table counts against imported counts

SQL code to create two temp tables - 1 temp table named bulk and a second named others.
SQL code to verify the temp table counts against counts that are imported, and so on. I need SQL code examples to perform everyone of the listed steps. I will do the fine tuning for our system once I can see how these steps can be coded correctly, including syntax.
Thanks.
0
 

Author Comment

by:tesla764
ID: 40023055
May be I should break this down into smaller individual functions.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 40023127
yes, good idea, to check out each individual sql syntax.

I mean, when you refer to "count", the number of rows of a table would be:
SELECT COUNT(*) FROM yourtable

however, if you want the count of distinct values, or counts as per some "value", the syntax will differ...
to insert that into a temp table INSERT INTO sometable SELECT ...


then: compare with ... in t-sql, you don't just "compare", but you do something ...
for example, if you have 2 rows (same table or different tables is just a matter of syntax...), and you want to "do something" if you have at least 1 "mismatch"
DECLARE @c INT
SELECT @c = COUNT(*) FROM table1 JOIN table2 ON ... WHERE table1.somefield <> table2.somefield
if @c <> 0
begin
   -- do something here
end 

Open in new window


or update some table from those temp tables:
http://www.experts-exchange.com/Database/Miscellaneous/A_1517-UPDATES-with-JOIN-for-everybody.html

reading the high-level description, you actually might want to run a MERGE statement, and not all that complex code:
http://msdn.microsoft.com/de-de/library/bb510625.aspx
0
 

Author Closing Comment

by:tesla764
ID: 40023359
Thanks for your help.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

765 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